:root {
  color-scheme: light;
  --bg-top: #edf5ed;
  --bg-bottom: #dce8da;
  --panel: rgba(251, 253, 249, 0.84);
  --panel-strong: rgba(255, 255, 253, 0.95);
  --line: rgba(41, 56, 43, 0.1);
  --line-strong: rgba(41, 56, 43, 0.18);
  --ink: #203128;
  --muted: #5f7265;
  --accent: #294433;
  --accent-soft: rgba(41, 68, 51, 0.08);
  --gold: #c59b52;
  --shadow-lg: 0 24px 52px rgba(52, 76, 58, 0.12);
  --shadow-md: 0 8px 22px rgba(52, 76, 58, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-pill: 999px;
}

* {
  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.7), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 245, 227, 0.32), transparent 30%),
    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: -5rem;
  left: -5rem;
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.background-bottom {
  right: -3rem;
  bottom: -3rem;
  width: 11rem;
  height: 11rem;
  border-radius: 50%;
  background: rgba(197, 155, 82, 0.12);
}

.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.72);
  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: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.35rem 0;
}

.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, 255, 253, 0.84);
  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, #fffef9, #f2f7f0);
  border: 1px solid rgba(34, 42, 58, 0.08);
}

.cimbor-icon {
  width: 46px;
  height: 46px;
}

.bubble-fill {
  fill: rgba(255, 255, 255, 0.98);
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linejoin: round;
}

.bubble-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bubble-dot {
  fill: var(--gold);
}

.eyebrow {
  margin: 10px 0 0.18rem;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(95, 114, 101, 0.86);
}

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

h1 {
  font-size: clamp(1.45rem, 4vw, 2.25rem);
}

h2 {
  font-size: 1.35rem;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
}

.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;
}

.saved-toggle,
.ghost-button,
.saved-item-actions button {
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(52, 76, 58, 0.05);
}

.saved-toggle {
  min-height: 3rem;
  padding: 0.72rem 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: center;
  font-size: 0.96rem;
  font-weight: 600;
}

.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: rgba(224, 234, 223, 0.95);
  color: var(--accent);
  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 auto;
  gap: 0.85rem;
  min-height: 0;
}

.phrase-card {
  position: relative;
  min-height: 29rem;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.phrase-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 29rem;
}

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

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

.phrase-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.6rem;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 254, 251, 0.98), rgba(246, 250, 243, 0.96));
  border: 1px solid rgba(93, 105, 96, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 12px 32px rgba(52, 76, 58, 0.07);
  overflow: hidden;
  transition:
    opacity 260ms ease,
    transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.phrase-face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(223, 235, 222, 0.7));
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
}

.phrase-face::after {
  content: "";
  position: absolute;
  right: -2rem;
  bottom: -2rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(228, 240, 227, 0.58), transparent 67%);
}

.phrase-face-back {
  opacity: 0;
  transform: rotateY(-90deg) scale(0.98);
  pointer-events: none;
}

.phrase-face-front {
  opacity: 1;
  transform: rotateY(0deg) scale(1);
}

.phrase-card.is-flipped .phrase-face-front {
  opacity: 0;
  transform: rotateY(90deg) scale(0.98);
  pointer-events: none;
}

.phrase-card.is-flipped .phrase-face-back {
  opacity: 1;
  transform: rotateY(0deg) scale(1);
  pointer-events: auto;
}

.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: #607668;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.phrase-text,
.phrase-meaning {
  position: relative;
  z-index: 1;
  margin: 0;
  text-align: center;
  color: #223629;
}

.phrase-text {
  max-width: 12ch;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(2.35rem, 6vw, 4.9rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.phrase-meaning {
  max-width: 16ch;
  font-size: clamp(1.6rem, 4.6vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.card-hint {
  margin: 0;
  text-align: center;
  color: rgba(95, 114, 101, 0.92);
  font-size: 0.96rem;
}

.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(52, 76, 58, 0.05);
}

.action-primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(41, 68, 51, 0.92);
  box-shadow:
    0 10px 20px rgba(41, 68, 51, 0.14),
    0 0 0 3px rgba(197, 155, 82, 0.18);
}

.action-primary .button-dot {
  background: rgba(247, 241, 228, 0.92);
  color: var(--accent);
}

.feedback {
  min-height: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-align: center;
  color: rgba(95, 114, 101, 0.95);
  font-weight: 500;
  opacity: 0;
  transition: opacity 180ms ease;
}

.feedback.is-visible,
.drawer-feedback.is-visible {
  opacity: 1;
}

.drawer-feedback {
  display: none;
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 3;
  min-height: 0;
  margin: 0;
  padding: 0.72rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 253, 0.94);
  box-shadow: 0 12px 28px rgba(52, 76, 58, 0.14);
  backdrop-filter: blur(14px);
  color: rgba(95, 114, 101, 0.95);
  font-size: 0.93rem;
  line-height: 1.35;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.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-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

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

.saved-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.saved-item-text,
.saved-item-meaning {
  margin: 0;
}

.saved-item-text {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
}

.saved-item-meaning {
  margin-top: 0.32rem;
  color: var(--muted);
  line-height: 1.45;
}

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

.saved-item-actions button {
  min-height: 2.4rem;
  padding: 0.55rem 0.86rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.phrase-card:focus-visible,
.saved-toggle:focus-visible,
.action-button:focus-visible,
.ghost-button:focus-visible,
.saved-item-actions button:focus-visible {
  outline: 3px solid rgba(197, 155, 82, 0.42);
  outline-offset: 3px;
}

.saved-toggle:hover,
.action-button:hover,
.ghost-button:hover,
.saved-item-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(52, 76, 58, 0.08);
}

.phrase-card:hover .phrase-card-inner {
  filter: drop-shadow(0 14px 24px rgba(52, 76, 58, 0.08));
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem);
    gap: 1rem;
  }

  .saved-drawer {
    position: relative;
    inset: auto;
    max-height: none;
    min-height: calc(100vh - 2rem);
    min-height: calc(100dvh - 2rem);
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .phrase-card,
  .phrase-card-inner {
    min-height: 35rem;
  }

  .phrase-text {
    max-width: 13ch;
  }
}

@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(2.8rem, calc(env(safe-area-inset-top, 0px) + 1rem))
      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;
    padding: 0.85rem;
  }

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

  .brand-lockup {
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    padding: 0.3rem 0.72rem 0.3rem 0.3rem;
  }

  .mascot-badge {
    width: 2.8rem;
    height: 2.8rem;
  }

  .cimbor-icon {
    width: 40px;
    height: 40px;
  }

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

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

  .header-actions {
    width: 100%;
  }

  .saved-toggle {
    width: 100%;
    margin-top: 0.65rem;
    min-height: 2.9rem;
  }

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

  .phrase-card,
  .phrase-card-inner {
    min-height: 0;
    flex: 1 1 auto;
  }

  .phrase-face {
    padding: 1.15rem;
    border-radius: 22px;
  }

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

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

  .phrase-text {
    max-width: 11ch;
    font-size: clamp(2rem, 11vw, 3.05rem);
  }

  .phrase-meaning {
    max-width: 14ch;
    font-size: clamp(1.3rem, 6vw, 2.05rem);
  }

  .card-hint {
    font-size: 0.92rem;
  }

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

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

  .feedback {
    min-height: 1.2rem;
    height: 1.2rem;
    font-size: 0.92rem;
    margin-bottom: 0.35rem;
  }

  .saved-drawer {
    left: 0.85rem;
    right: 0.85rem;
    top: calc(7.7rem + 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;
  }

  .drawer-feedback {
    left: 0.9rem;
    right: 0.9rem;
    bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.9rem;
  }

  .saved-drawer-header {
    flex-direction: row;
    align-items: start;
    padding-bottom: 0;
  }

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

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

  .saved-toggle:hover,
  .action-button:hover,
  .ghost-button:hover,
  .saved-item-actions button:hover {
    transform: none;
    box-shadow: 0 6px 16px rgba(52, 76, 58, 0.05);
  }
}
