:root {
  color-scheme: light;
  --bg-top: #f5f0e8;
  --bg-bottom: #eee7de;
  --panel: rgba(255, 251, 245, 0.82);
  --panel-strong: rgba(255, 252, 248, 0.94);
  --line: rgba(32, 37, 45, 0.09);
  --line-strong: rgba(32, 37, 45, 0.16);
  --ink: #1e2430;
  --muted: #6c7482;
  --gold: #b69a71;
  --shadow-lg: 0 22px 52px rgba(82, 61, 44, 0.1);
  --shadow-md: 0 8px 22px rgba(82, 61, 44, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --accent: #1f232b;
  --accent-soft: rgba(31, 35, 43, 0.06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.72), transparent 28%),
    radial-gradient(circle at bottom left, rgba(255, 247, 238, 0.4), transparent 26%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

button {
  font: inherit;
  cursor: pointer;
}

.background {
  position: fixed;
  pointer-events: none;
  filter: blur(20px);
  z-index: 0;
}

.background-top {
  top: -6rem;
  left: -5rem;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.background-bottom {
  right: -3rem;
  bottom: -3rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: rgba(214, 191, 160, 0.09);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.15rem;
  padding: 1rem;
}

.hero-panel,
.saved-drawer {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
}

.hero-panel {
  border-radius: var(--radius-xl);
  padding: 1rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1.2rem;
  min-height: 0;
}

.hero-header {
  display: grid;
  gap: 1rem;
  padding: 0.35rem 0.35rem 0;
  position: relative;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.34rem 0.72rem 0.34rem 0.34rem;
  width: fit-content;
  border-radius: var(--radius-pill);
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-md);
}

.mascot-badge {
  display: grid;
  place-items: center;
  width: 3.1rem;
  height: 3.1rem;
  flex-shrink: 0;
  border-radius: 1.05rem;
  background: linear-gradient(180deg, #fffdfa, #f7efe6);
  border: 1px solid rgba(34, 42, 58, 0.08);
}

.stork-icon {
  width: 46px;
  height: 46px;
  fill: rgba(255, 255, 255, 0.95);
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stork-line {
  fill: none;
}

.beak {
  fill: none;
  stroke: #f07b49;
}

.eye {
  fill: var(--ink);
  stroke: none;
}

.eyebrow {
  margin: 0 0 0.18rem;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(108, 116, 130, 0.82);
}

h1,
h2 {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(1.4rem, 3.8vw, 2.2rem);
}

h2 {
  font-size: 1.35rem;
}

.saved-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.mobile-language {
  display: none;
  position: relative;
  z-index: 5;
}

.mobile-language-toggle {
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(34, 42, 58, 0.1);
  border-radius: 50%;
  background: rgba(255, 252, 248, 0.96);
  box-shadow: 0 6px 16px rgba(82, 61, 44, 0.06);
}

.mobile-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-language-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  min-width: 11rem;
  padding: 0.4rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(34, 42, 58, 0.08);
  box-shadow: 0 18px 38px rgba(117, 93, 75, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    visibility 160ms ease;
  z-index: 20;
}

.mobile-language-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mobile-language-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border: 0;
  border-radius: 0.8rem;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.mobile-language-option.is-active {
  background: rgba(35, 35, 38, 0.08);
}

.mobile-language-emoji {
  font-size: 1.05rem;
  line-height: 1;
}

.language-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.language-pill,
.saved-toggle,
.action-button,
.ghost-button,
.saved-item-actions button {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.language-pill,
.saved-toggle,
.ghost-button,
.saved-item-actions button {
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(82, 61, 44, 0.04);
}

.language-pill,
.saved-toggle {
  min-height: 3rem;
  padding: 0.72rem 1.05rem;
  font-size: 0.96rem;
  font-weight: 600;
}

.language-pill {
  position: relative;
}

.language-pill.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 16px 30px rgba(29, 29, 31, 0.2);
}

.saved-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: center;
}

.saved-toggle span:last-child {
  display: inline-flex;
}

.button-dot {
  display: inline-flex;
  min-width: 1.65rem;
  min-height: 1.65rem;
  justify-content: center;
  align-items: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border-radius: 50%;
  background: #efe7dc;
  color: #2d3441;
  font-size: 0.9rem;
  font-weight: 700;
}

.button-dot-icon svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.phrase-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0.85rem;
  min-height: 0;
}

.phrase-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 29rem;
  padding: 1.6rem;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 254, 251, 0.98), rgba(251, 247, 241, 0.96));
  border: 1px solid rgba(93, 96, 105, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 12px 32px rgba(82, 61, 44, 0.06);
  overflow: hidden;
}

.phrase-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(237, 225, 216, 0.7));
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
}

.phrase-card::after {
  content: "";
  position: absolute;
  right: -2rem;
  bottom: -2rem;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 251, 245, 0.5), transparent 67%);
}

.phrase-card.is-animating {
  animation: card-rise 260ms ease;
}

@keyframes card-rise {
  0% {
    opacity: 0.3;
    transform: translateY(12px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.phrase-card-top {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  justify-content: flex-start;
}

.page-label {
  margin: 0;
  color: #6c7b90;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.phrase-text {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 10ch;
  text-align: center;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
  color: #24313f;
}

.primary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  padding: 0.15rem 0;
}

.action-button,
.ghost-button {
  min-height: 2.95rem;
  padding: 0.68rem 0.95rem;
  font-size: 0.96rem;
  font-weight: 600;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(82, 61, 44, 0.05);
}

.action-primary {
  background: #232127;
  color: #fff;
  border-color: rgba(47, 47, 50, 0.92);
  box-shadow:
    0 10px 20px rgba(29, 29, 31, 0.12),
    0 0 0 3px rgba(182, 154, 113, 0.16);
}

.action-primary .button-dot {
  background: rgba(255, 247, 238, 0.9);
  color: #232326;
}

.feedback {
  min-height: 1.5rem;
  margin: 0;
  text-align: center;
  color: rgba(108, 82, 89, 0.82);
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.92;
  transition: opacity 180ms ease, transform 180ms ease;
}

.saved-drawer {
  position: fixed;
  right: 1rem;
  left: 1rem;
  bottom: 1rem;
  max-height: min(74vh, 44rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-xl);
  transform: translateY(calc(100% + 2rem));
  opacity: 0;
  visibility: hidden;
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 240ms ease,
    visibility 240ms ease;
}

.saved-drawer.is-open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.saved-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.2rem;
  flex-shrink: 0;
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: auto;
  min-height: 0;
}

.saved-item {
  padding: 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid var(--line);
}

.saved-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved-item-text {
  margin: 0 0 0.9rem;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.08;
  color: #24313f;
}

.saved-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.saved-item-actions button {
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
}

button:active {
  transform: none;
}

button:focus-visible {
  outline: 2px solid rgba(29, 183, 255, 0.28);
  outline-offset: 2px;
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1.42fr) minmax(22rem, 0.9fr);
    align-items: start;
    gap: 1rem;
    padding: 1rem;
  }

  .hero-panel {
    min-height: calc(100vh - 2rem);
    padding: 0.95rem;
  }

  .hero-header {
    grid-template-columns: auto 1fr;
    align-items: start;
  }

  .header-actions {
    justify-self: end;
    align-items: flex-end;
  }

  .phrase-stage {
    gap: 0.7rem;
  }

  .phrase-card {
    min-height: 26rem;
    padding: 1.45rem;
  }

  .phrase-card-top {
    top: 1.25rem;
    left: 1.25rem;
    right: 1.25rem;
  }

  .page-label {
    font-size: 0.94rem;
  }

  .primary-actions {
    grid-template-columns: repeat(4, minmax(0, max-content));
    justify-content: flex-start;
    gap: 0.55rem;
  }

  .action-button {
    min-height: 2.7rem;
    padding: 0.64rem 0.9rem;
    font-size: 0.92rem;
  }

  .saved-drawer-header {
    padding-bottom: 0;
  }

  .saved-empty {
    font-size: 0.96rem;
  }

  .saved-drawer {
    position: relative;
    inset: 0;
    max-height: none;
    transform: none;
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 640px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100dvh;
    height: 100dvh;
    display: block;
    overflow: hidden;
    padding:
      max(3rem, calc(env(safe-area-inset-top, 0px) + 1.25rem))
      0.85rem
      calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }

  .hero-panel {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 1.7rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 1.7rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    gap: 0.8rem;
  }

  .hero-header {
    display: block;
    padding-top: 0.15rem;
  }

  .brand-lockup {
    width: fit-content;
    max-width: calc(100% - 5.1rem);
    min-width: 0;
    padding: 0.34rem 0.8rem 0.34rem 0.34rem;
  }

  .eyebrow {
    display: block;
    font-size: 0.58rem;
    line-height: 1;
    margin-bottom: 0.16rem;
  }

  h1 {
    font-size: 1.9rem;
    line-height: 0.95;
  }

  .mobile-language {
    display: block;
    position: absolute;
    top: 1.7rem;
    right: 0.25rem;
    transform: translateY(-50%);
  }

  .language-switcher {
    display: none;
  }

  .saved-toggle {
    margin-top: 0.65rem;
  }

  .primary-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.62rem;
  }

  .saved-toggle {
    width: 100%;
    justify-content: center;
  }

  .phrase-stage {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    gap: 0.65rem;
  }

  .phrase-card {
    min-height: 0;
    flex: 1 1 auto;
    padding: 1.15rem;
    border-radius: 22px;
  }

  .feedback {
    min-height: 1.2rem;
    font-size: 0.84rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding-bottom: 0.45rem;
    color: rgba(108, 82, 89, 0.72);
  }

  .phrase-card-top {
    top: 0.95rem;
    left: 0.95rem;
    right: 0.95rem;
  }

  .page-label {
    font-size: 0.8rem;
  }

  .phrase-text {
    max-width: 10ch;
    font-size: clamp(2.1rem, 8.4vw, 3.25rem);
  }

  .action-button,
  .saved-toggle {
    min-height: 3.3rem;
  }

  .action-button {
    padding: 0.42rem 0.82rem;
    font-size: 0.96rem;
    min-height: 3.48rem;
    align-items: center;
  }

  .action-button span:first-child {
    display: block;
    max-width: none;
    line-height: 1;
    white-space: nowrap;
  }

  .action-button .button-dot {
    min-width: 1.55rem;
    min-height: 1.55rem;
    width: 1.55rem;
    height: 1.55rem;
    flex-shrink: 0;
  }

  .mobile-language-toggle {
    width: 3.25rem;
    height: 3.25rem;
    min-height: 3.25rem;
    min-width: 3.25rem;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    padding: 0;
  }

  .mobile-flag {
    font-size: 1.15rem;
  }

  .saved-drawer {
    left: 0.85rem;
    right: 0.85rem;
    top: calc(8.35rem + env(safe-area-inset-top, 0px));
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    max-height: none;
    padding: 0.95rem;
    border-radius: 26px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .saved-drawer-header {
    align-items: start;
  }

  .saved-list {
    flex: 0 0 auto;
    overflow: visible;
    padding-bottom: 0.25rem;
  }

  .saved-empty {
    flex-shrink: 0;
  }

  .saved-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .saved-item-actions button {
    width: auto;
    min-height: 2.35rem;
    padding: 0.42rem 0.72rem;
    font-size: 0.8rem;
    justify-content: center;
    white-space: nowrap;
  }
}
