:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #eaf2ff;
  --text: #17213a;
  --muted: #77829a;
  --blue: #1266e8;
  --blue-deep: #084fc8;
  --blue-light: #7db3ff;
  --border: #e3eafb;
  --shadow: 0 24px 70px rgba(48, 91, 164, .16);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-regular: 400;
  --font-medium: 500;
  --font-bold: 700;
  --font-extra: 800;
  font-family: Poppins, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body {
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(18, 102, 232, .25); outline-offset: 3px; }

#app { height: 100dvh; overflow: hidden; }
.screen {
  width: min(100%, 520px);
  height: 100dvh;
  margin: auto;
  padding: 22px 20px 118px;
  overflow: hidden;
}
.screen:not(.hidden) { animation: screen-in .38s cubic-bezier(.22, 1, .36, 1); }
.hidden { display: none !important; }
.centered { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.centered-text { text-align: center; }
.muted { color: var(--muted); }

.app-header { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark, .spark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: var(--blue);
  color: #fff;
  font-size: 19px;
  font-weight: var(--font-extra);
  box-shadow: 0 9px 24px rgba(18, 102, 232, .24);
}
.spark { width: 42px; background: var(--surface); color: var(--blue); box-shadow: 0 8px 28px rgba(48, 91, 164, .11); }

.hero { padding: 36px 2px 25px; }
.hero.compact { padding-top: 22px; }
.hero h1, #summary h1 { margin: 8px 0 10px; font-size: clamp(38px, 10vw, 54px); line-height: .99; font-weight: var(--font-extra); letter-spacing: -.055em; }
.hero h1 span { color: var(--blue); }
.hero .muted { max-width: 360px; margin: 15px 0 0; font-size: 15px; line-height: 1.55; }
.eyebrow, .card-label { margin: 0; color: var(--blue); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow { font-weight: var(--font-bold); }
.card-label { font-weight: var(--font-medium); }

.daily-stack, .study-deck { position: relative; isolation: isolate; }
.daily-stack::before, .daily-stack::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 7%;
  right: 7%;
  height: 100%;
  border-radius: 30px;
  background: #8cbcff;
  transform: translateY(-14px) scale(.96);
  opacity: .46;
}
.daily-stack::after { transform: translateY(-7px) scale(.98); background: #5e9cf5; opacity: .72; }
.daily-card {
  position: relative;
  overflow: hidden;
  padding: 25px 24px 18px;
  border-radius: 30px;
  background: linear-gradient(145deg, #2478f2 0%, #0757d8 72%);
  color: #fff;
  box-shadow: 0 28px 60px rgba(22, 100, 220, .28);
}
.daily-card::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  top: -118px;
  right: -95px;
  border: 42px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
}
.daily-head { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.daily-card .card-label { color: rgba(255, 255, 255, .7); }
.daily-chip { padding: 7px 10px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: 11px; }
.daily-card h2 { position: relative; z-index: 1; max-width: 290px; margin: 22px 0 24px; font-size: 30px; line-height: 1.08; letter-spacing: -.045em; }
.daily-metrics { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1px 1fr; align-items: center; margin-bottom: 20px; padding: 17px 8px; border-radius: 21px; background: rgba(255, 255, 255, .12); backdrop-filter: blur(12px); }
.divider { width: 1px; height: 38px; background: rgba(255, 255, 255, .2); }
.metric { display: grid; gap: 2px; text-align: center; }
.metric strong { font-size: 31px; line-height: 1; letter-spacing: -.05em; }
.metric span { color: rgba(255, 255, 255, .72); font-size: 12px; }

.primary, .quiet, .icon-button, .rating, .suspend-card, .tabs button { border: 0; }
.primary {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 17px;
  background: var(--blue);
  color: #fff;
  font-weight: var(--font-bold);
  box-shadow: 0 13px 30px rgba(18, 102, 232, .23);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.primary:active { transform: scale(.975); box-shadow: 0 8px 20px rgba(18, 102, 232, .2); }
.primary.large { width: 100%; min-height: 58px; font-size: 16px; }
.primary.light { background: #fff; color: var(--blue-deep); box-shadow: 0 12px 28px rgba(3, 49, 118, .2); }
.quiet { width: 100%; min-height: 46px; background: transparent; color: var(--muted); }
.quiet.on-blue { position: relative; z-index: 1; min-height: 42px; margin-bottom: -5px; color: rgba(255, 255, 255, .67); font-size: 12px; }
.home-note { display: flex; align-items: center; gap: 10px; margin: 26px 12px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.home-note span { display: grid; flex: 0 0 auto; place-items: center; width: 31px; height: 31px; border-radius: 11px; background: #dfeeff; color: var(--blue); font-weight: var(--font-extra); }

#study { height: 100dvh; padding-bottom: 14px; display: flex; flex-direction: column; }
.study-header { display: grid; grid-template-columns: 42px 1fr 42px; gap: 12px; align-items: center; }
.study-header > strong { text-align: center; font-size: 16px; font-weight: var(--font-bold); letter-spacing: -.02em; }
.icon-button { width: 42px; height: 42px; border-radius: 15px; background: #fff; color: var(--text); font-size: 25px; box-shadow: 0 8px 25px rgba(48, 91, 164, .12); transition: transform .18s ease; }
.icon-button:active { transform: scale(.94); }
.study-header .icon-button { background: transparent; box-shadow: none; font-size: 32px; text-align: left; }
.study-avatar { display: grid; place-items: center; width: 38px; height: 38px; justify-self: end; border: 3px solid #fff; border-radius: 50%; background: linear-gradient(145deg, #74adff, #1266e8); color: #fff; font-size: 13px; font-weight: var(--font-extra); box-shadow: 0 7px 18px rgba(18, 102, 232, .2); }
.study-stage { min-height: 0; flex: 1; margin: 14px -8px 0; padding: 12px 12px calc(12px + var(--safe-bottom)); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #f2f4f7; border-radius: 30px; background: #fafbfc; }
.study-progress { margin: 0; padding: 7px 6px 14px; }
.study-progress > div:first-child { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.progress-label, #session-counter { display: flex; align-items: center; gap: 5px; }
.progress-label b { color: var(--text); font-weight: var(--font-medium); }
.study-progress svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#session-counter { min-width: 58px; justify-content: end; color: var(--muted); font-size: 11px; font-weight: var(--font-regular); text-align: right; }
.study-progress-track { overflow: hidden; height: 5px; border-radius: 99px; background: #dfe8ed; }
.study-progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6ed793, #43bf75); box-shadow: 0 0 10px rgba(67, 191, 117, .35); transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.study-deck { position: relative; margin: 64px 0 108px; perspective: 1200px; }
.deck-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 32px;
  transform-origin: center;
}
.deck-layer-back {
  z-index: 0;
  background: #8ab8ff;
  box-shadow: 0 18px 42px rgba(48, 91, 164, .08);
  transform: translateY(-54px) scaleX(.82);
  opacity: .34;
}
.deck-layer-middle {
  z-index: 1;
  background: #4f8ef3;
  box-shadow: 0 18px 44px rgba(48, 91, 164, .11);
  transform: translateY(-28px) rotate(-3deg) scaleX(.91);
  opacity: .62;
}
.card-image {
  position: absolute;
  z-index: 5;
  top: -28px;
  left: -8px;
  width: 200px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(25, 55, 108, .28);
  transform: rotate(-7deg);
  pointer-events: none;
  transition: opacity .22s ease, transform .34s cubic-bezier(.22, 1, .36, 1);
}
.card-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.answer-shown .card-image { opacity: 0; transform: translate(-10px, -8px) rotate(-11deg) scale(.92); }
.study-card {
  position: relative;
  z-index: 2;
  aspect-ratio: 1;
  min-height: 0;
  border-radius: 32px;
  color: #fff;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2, .78, .22, 1);
}
.study-card.flipped { transform: rotateY(180deg); }
.study-card:focus-visible { outline: 3px solid rgba(18, 102, 232, .3); outline-offset: 5px; }
.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 34px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: #1266e8;
  color: #fff;
  text-align: center;
  box-shadow: 0 28px 64px rgba(18, 102, 232, .27);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card-face::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -145px;
  bottom: -135px;
  border: 44px solid rgba(255, 255, 255, .06);
  border-radius: 50%;
}
.card-back { transform: rotateY(180deg); background: #0b58d4; }
.card-face > * { position: relative; }
.study-card .card-label { align-self: center; padding: 7px 11px; border-radius: 99px; background: rgba(255, 255, 255, .13); color: rgba(255, 255, 255, .76); }
.study-card h2 { max-width: 400px; margin: 17px 0 14px; font-size: clamp(20px, 5.4vw, 28px); line-height: 1.25; font-weight: var(--font-bold); letter-spacing: -.03em; }
.example { position: relative; margin: 0; color: rgba(255, 255, 255, .72); font-size: 17px; font-weight: var(--font-regular); line-height: 1.5; }
.card-examples { display: grid; gap: 8px; }
.card-examples .example { font-size: 14px; line-height: 1.4; }
.hint-panel { position: absolute; z-index: 4; top: calc(100% - 7px); left: 3%; width: 94%; min-height: 66px; padding: 15px 17px 14px; border: 1px solid #f0f1f4; border-radius: 17px; background: #fff; color: #171b23; font: inherit; text-align: left; box-shadow: 0 15px 32px rgba(37, 58, 94, .14); opacity: 1; transform: rotate(-1.2deg); transform-origin: center; transition: opacity .22s ease, transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .28s ease; }
.hint-panel:active { transform: rotate(-1.2deg) scale(.985); }
.hint-panel.open { transform: translateY(-2px) rotate(-1.2deg); box-shadow: 0 18px 38px rgba(37, 58, 94, .17); }
.hint-panel-title { display: grid; grid-template-columns: 25px 1fr 20px; gap: 10px; align-items: center; }
.hint-panel-title svg { fill: none; stroke: #11151c; stroke-linecap: round; stroke-linejoin: round; }
.hint-bulb { width: 24px; height: 24px; stroke-width: 1.7; }
.hint-panel-title strong { color: #11151c; font-size: 14px; font-weight: var(--font-bold); }
.hint-chevron { width: 19px; height: 19px; justify-self: end; stroke-width: 2; transition: transform .25s ease; }
.hint-panel:not(.open) .hint-chevron { transform: rotate(180deg); }
.card-hint { display: block; margin-top: 11px; color: #7c8593; font-size: 15px; font-weight: var(--font-regular); line-height: 1.48; animation: hint-copy-in .25s ease; }
.answer-shown .hint-panel { pointer-events: none; opacity: 0; transform: translateY(24px) rotate(-1.2deg) scale(.96); }
@keyframes hint-copy-in { from { opacity: 0; transform: translateY(-4px); } }
.tap-hint { position: absolute; bottom: 24px; color: rgba(255, 255, 255, .56); font-size: 11px; }
.card-back h3 { margin: 10px 0 2px; color: #fff; font-size: clamp(34px, 9vw, 48px); font-weight: var(--font-extra); letter-spacing: -.045em; }
.phonetic { margin: 0 0 5px; color: rgba(255, 255, 255, .65); font-size: 13px; }
.translation { margin: 0; color: rgba(255, 255, 255, .82); font-size: 17px; font-weight: var(--font-medium); }
.word-in-use { width: 100%; margin-top: 17px; padding: 14px 16px; border-radius: 20px; background: #fff; color: var(--text); text-align: left; box-shadow: 0 14px 30px rgba(0, 35, 96, .18); }
.word-in-use strong { font-size: 12px; font-weight: var(--font-medium); }
.word-in-use .example { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.card-pattern { margin: 9px 0 0; padding-top: 8px; border-top: 1px solid var(--border); color: var(--blue-deep); font-size: 11px; font-weight: var(--font-medium); line-height: 1.35; }
.rating-grid { width: 100%; margin-top: auto; padding: 7px 0 3px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; border: 0; background: transparent; box-shadow: none; }
.rating, .suspend-card { position: relative; min-width: 0; min-height: 94px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 17px; background: transparent; color: var(--muted); transition: transform .15s ease, background .15s ease; }
.rating:active, .suspend-card:active { transform: scale(.92); }
.rating img, .suspend-card img { display: block; width: 75px; height: 75px; object-fit: contain; border-radius: 50%; transition: transform .18s ease, box-shadow .18s ease; }
.rating-icon { position: relative; flex: 0 0 75px; width: 75px; height: 75px; display: grid; place-items: center; }
.rating-label { min-height: 22px; display: grid; place-items: start center; font-size: 9px; font-weight: var(--font-medium); line-height: 1.1; text-align: center; }
.rating:hover img, .suspend-card:hover img { transform: translateY(-2px); }
.rating.easy .rating-icon::after, .suspend-card .rating-icon::after { content: ""; position: absolute; z-index: 1; top: 50%; left: 50%; width: 58px; height: 58px; border: 3px solid; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.rating.easy .rating-icon::after { border-color: #5bd783; box-shadow: 0 6px 16px rgba(48, 155, 88, .2); }
.suspend-card .rating-icon::after { border-color: #72aaf6; box-shadow: 0 6px 16px rgba(18, 102, 232, .18); }

#summary { padding-inline: 35px; }
.summary-mark { display: grid; place-items: center; width: 92px; height: 92px; margin-bottom: 27px; border-radius: 32px; background: linear-gradient(145deg, #3183f5, #0756d4); color: #fff; font-size: 38px; box-shadow: 0 22px 45px rgba(18, 102, 232, .28); transform: rotate(-4deg); }
#summary h1 { margin-top: 12px; }
#summary .primary { margin-top: 28px; }

.stats-grid, .settings-card, .week-chart { border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .85); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 9px 0 22px; border-radius: 27px; }
.stats-grid div { display: grid; gap: 5px; padding: 24px 16px; text-align: center; }
.stats-grid div + div { border-left: 1px solid var(--border); }
.stats-grid strong { color: var(--blue); font-size: 32px; letter-spacing: -.04em; }
.stats-grid span { color: var(--muted); font-size: 12px; }
.week-chart { height: 220px; padding: 24px 14px 11px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; border-radius: 27px; }
.week-chart div { height: 100%; display: grid; grid-template-rows: 1fr 24px; gap: 9px; align-items: end; text-align: center; }
.week-chart i { width: 62%; max-height: 100%; min-height: 5px; margin: auto; border-radius: 9px 9px 4px 4px; background: linear-gradient(180deg, #5b9cf8, var(--blue)); box-shadow: 0 7px 15px rgba(18, 102, 232, .18); transition: height .45s cubic-bezier(.22, 1, .36, 1); }
.week-chart span { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.settings-card { display: grid; gap: 2px; padding: 10px 20px 20px; border-radius: 27px; }
.settings-card label { display: grid; grid-template-columns: 1fr minmax(100px, 38%); align-items: center; gap: 16px; min-height: 67px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: var(--font-medium); }
.settings-card input { width: 100%; padding: 11px; border: 0; border-radius: 12px; background: var(--surface-soft); color: var(--blue-deep); text-align: right; font-weight: 700; }
.settings-card .primary { margin-top: 18px; }

.tabs {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  width: min(calc(100% - 28px), 460px);
  min-height: 70px;
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 25px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 18px 55px rgba(48, 91, 164, .2);
  backdrop-filter: blur(20px);
  transform: translateX(-50%);
}
.tabs button { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 19px; background: transparent; color: #929cb1; font-size: 11px; font-weight: var(--font-medium); transition: color .2s ease, background .2s ease, transform .2s ease; }
.tabs button:active { transform: scale(.96); }
.tabs button.active { background: var(--blue); color: #fff; box-shadow: 0 9px 22px rgba(18, 102, 232, .26); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(98px + var(--safe-bottom)); transform: translateX(-50%); padding: 13px 18px; border-radius: 15px; background: #17213a; color: #fff; box-shadow: 0 12px 35px rgba(23, 33, 58, .24); white-space: nowrap; animation: toast-in .25s ease-out; }
.loader { width: 38px; height: 38px; border: 3px solid #dbe7fb; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes answer-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes actions-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 380px) {
  .screen { padding-inline: 15px; }
  .hero { padding-top: 26px; }
  .hero h1 { font-size: 38px; }
  .daily-card { padding-inline: 19px; }
  .study-deck { margin-top: 62px; }
  .card-face { padding-inline: 18px; }
  .tabs button { gap: 4px; }
  .tabs button span { font-size: 10px; }
}
@media (max-height: 760px) {
  .screen:not(#study) { padding-top: 12px; padding-bottom: calc(92px + var(--safe-bottom)); }
  .hero { padding: 18px 2px 15px; }
  .hero.compact { padding-top: 10px; }
  .hero h1, #summary h1 { font-size: clamp(32px, 9vw, 42px); }
  .hero .muted { margin-top: 10px; font-size: 13px; line-height: 1.4; }
  .daily-card { padding: 18px 20px 12px; }
  .daily-card h2 { margin: 12px 0 14px; font-size: 26px; }
  .daily-metrics { margin-bottom: 12px; padding: 10px 8px; }
  .quiet.on-blue { min-height: 38px; }
  .home-note { margin-top: 14px; font-size: 12px; }
  .stats-grid { margin-bottom: 14px; }
  .stats-grid div { padding: 15px 12px; }
  .week-chart { height: 150px; padding-top: 15px; }
  .settings-card label { min-height: 58px; }
  .settings-card .primary { margin-top: 10px; }

  #study { padding: 10px 15px 8px; }
  .study-stage { margin-top: 6px; padding: 8px 10px calc(8px + var(--safe-bottom)); }
  .study-progress { padding: 2px 4px 8px; }
  .study-progress > div:first-child { margin-bottom: 6px; }
  .study-deck {
    width: min(100%, calc(100dvh - 377px - var(--safe-bottom)));
    margin: 34px auto 108px;
  }
  .card-face { padding: 20px 17px; }
  .study-card h2 { margin: 10px 0; }
  .tap-hint { bottom: 14px; }
  .card-back h3 { margin-top: 6px; font-size: clamp(30px, 8vw, 40px); }
  .word-in-use { margin-top: 10px; padding: 10px 12px; }
  .word-in-use .example { margin-top: 4px; font-size: 11px; }
  .card-pattern { margin-top: 6px; padding-top: 6px; }
  .rating-grid { padding-top: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
