/* 단어랑 — playful "sticker" look, colors drawn from 오방색 and 단청 painting. */
:root {
  --cream: #FFF8EA;
  --paper: #FFFFFF;
  --ink: #1C2333;
  --muted: #5A6173;
  --hairline: #E6DFCF;
  --red: #E5383B;
  --blue: #1F6FEB;
  --blue-deep: #1654B8;
  --yellow: #FFC531;
  --green: #1B8A3A;
  --green-soft: #DDF5E3;
  --red-soft: #FDE3E3;
  --purple: #7B3FE4;
  --border: 2.5px solid var(--ink);
  --radius: 20px;
  --font-ko: 'Jua', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

[lang="ko"] { word-break: keep-all; }
a { color: inherit; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); font-weight: 700; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Band of traditional colors along the top of each main page. */
.dancheong {
  height: 8px;
  background: linear-gradient(90deg,
    var(--blue) 0 20%, var(--red) 20% 40%, var(--yellow) 40% 60%, var(--green) 60% 80%, var(--ink) 80% 100%);
}

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 24px;
}

.card-sticker {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 10px 20px;
  border: var(--border);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font: inherit;
  font-weight: 900;
  font-size: 17px;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn-block { display: flex; width: 100%; }
.btn-small { min-height: 42px; padding: 6px 14px; font-size: 15px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-yellow { background: var(--yellow); }
.btn-ghost { background: var(--paper); }
.btn-again { background: var(--red); color: #fff; }
.btn-hard { background: var(--yellow); }
.btn-good { background: var(--green); color: #fff; }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 19px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn[aria-pressed="true"]#swap { background: var(--yellow); }

.link-btn {
  align-self: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* --- Forms ------------------------------------------------------------- */
.field-label { display: block; margin-bottom: 6px; font-weight: 800; }
.text-input, .select-input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border: var(--border);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* Below 16px, iOS zooms the page on focus. */
}
.form-error { margin: 12px 0 0; color: #B3261E; font-weight: 800; }
.form-ok { margin-bottom: 10px; color: var(--green); font-weight: 800; }

/* --- Login and centered pages ------------------------------------------- */
.page-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login { width: 100%; max-width: 380px; padding: 28px 22px; text-align: center; }
.login form { margin-top: 18px; text-align: left; }
.login .btn { margin-top: 14px; }
.logo-big { font-family: var(--font-ko); font-size: 56px; line-height: 1.1; color: var(--blue); }

/* --- Page header -------------------------------------------------------- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px 10px;
}
.logo { font-family: var(--font-ko); font-size: 30px; line-height: 1; color: var(--blue); }
.page-title { font-family: var(--font-ui); font-size: 26px; font-weight: 900; }
.streak-pill {
  padding: 6px 12px;
  border: var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}
.streak-pill.is-on { background: var(--yellow); color: var(--ink); }

/* --- Home hero ---------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 20px 18px;
  background: var(--blue);
  color: #fff;
}
.hero.is-done { background: var(--green); }
.hero-glyph {
  position: absolute;
  right: -6px;
  top: -24px;
  font-family: var(--font-ko);
  font-size: 150px;
  line-height: 1;
  color: rgba(255, 255, 255, .14);
  pointer-events: none;
}
.hero-title { position: relative; font-size: 15px; font-weight: 900; letter-spacing: .02em; }
.hero.is-done .hero-title { font-size: 24px; }
.hero-count { position: relative; margin-top: 2px; font-size: 20px; font-weight: 800; }
.hero-count strong { font-size: 46px; font-weight: 900; line-height: 1.1; }
.hero-detail { position: relative; margin: 2px 0 14px; font-weight: 700; color: #EAF1FF; }
.hero.is-done .hero-detail { margin-bottom: 0; color: #fff; }
.hero .btn { position: relative; }

/* --- Practice ----------------------------------------------------------- */
.section-title { margin: 24px 0 10px; font-size: 21px; font-weight: 900; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: var(--border);
  border-radius: 16px;
  background: var(--paper);
}
.segmented input, .chip input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block;
  padding: 10px 6px;
  border-radius: 11px;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span, .chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px;
}
.chip { --accent: var(--ink); position: relative; }
.chip span {
  display: block;
  min-height: 40px;
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.chip b { color: var(--accent); font-weight: 900; }
.chip input:checked + span { background: var(--accent); color: #fff; }
.chip input:checked + span b { color: #fff; }

.random-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--yellow);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.random-tile:active, .cat-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.random-dice { font-size: 36px; line-height: 1; }
.random-tile:hover .random-dice { transform: rotate(-12deg); }
.tile-name { display: block; font-weight: 900; line-height: 1.2; }
.random-tile .tile-name { font-size: 18px; }
.tile-meta { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; color: var(--muted); }
.random-tile .tile-meta { color: var(--ink); }
.tough-tile { margin-top: 12px; background: var(--red-soft); }
.tough-tile:disabled { background: var(--paper); box-shadow: none; opacity: .7; cursor: default; transform: none; }
.tough-tile:disabled:hover .random-dice { transform: none; }
.tough-tile:disabled .tile-meta { color: var(--muted); }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.cat-tile {
  --accent: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 132px;
  padding: 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.cat-emoji {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: var(--accent);
  font-size: 23px;
  line-height: 1;
}
.cat-tile .tile-name { font-size: 15px; }
.cat-tile .tile-meta { margin-top: auto; padding-top: 4px; color: var(--ink); opacity: .78; }
.mini-track {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 5px;
  border-radius: 999px;
  background: rgba(28, 35, 51, .14);
  overflow: hidden;
}
.mini-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.voice-notice {
  margin-top: 18px;
  padding: 12px 14px;
  border: 2px dashed var(--muted);
  border-radius: 14px;
  color: var(--muted);
  font-size: 14px;
}

/* --- Bottom navigation -------------------------------------------------- */
.has-nav { padding-bottom: calc(76px + var(--safe-bottom)); }
.bottom-nav {
  position: fixed;
  z-index: 10;
  inset: auto 0 0;
  display: flex;
  justify-content: center;
  padding-bottom: var(--safe-bottom);
  border-top: var(--border);
  background: var(--paper);
}
.bottom-nav a {
  flex: 1;
  max-width: 187px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}
.nav-icon { font-size: 22px; line-height: 1.2; }
.bottom-nav a.is-active { color: var(--ink); font-weight: 900; box-shadow: inset 0 4px 0 var(--red); }

/* --- Sessions ----------------------------------------------------------- */
.session {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.session-bar {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
}
.progress-track {
  flex: 1;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  overflow: hidden;
}
.progress-fill {
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width .25s ease;
}
.session-count { flex: none; min-width: 48px; font-size: 14px; font-weight: 900; text-align: center; }
.combo { flex: none; font-size: 14px; font-weight: 900; }

.stage {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 16px calc(18px + var(--safe-bottom));
}
.stage.is-end { justify-content: center; }
.session-bar:has(+ .is-end) button { display: none; }

/* --- Flash card --------------------------------------------------------- */
.flash-wrap { position: relative; flex: 1; min-height: 340px; max-height: 540px; display: flex; }
.flash {
  --accent: var(--blue);
  position: relative;
  flex: 1;
  perspective: 1400px;
  cursor: pointer;
  border-radius: var(--radius);
  outline-offset: 4px;
}
.flash-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.3, 1.25, .5, 1);
}
.flash.is-flipped .flash-inner { transform: rotateY(180deg); }
.flash.no-anim .flash-inner { transition: none; }
.flash-face {
  position: absolute;
  inset: 0 0 5px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.flash-front { background: var(--accent); color: #fff; }
.flash-back { background: var(--paper); transform: rotateY(180deg); border-top: 10px solid var(--accent); overflow-y: auto; }
.flash-tags { display: flex; flex-wrap: wrap; gap: 6px; padding-right: 48px; }
.tag {
  padding: 3px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
.tag-new { background: var(--yellow); }
.flash-main {
  margin: auto 0;
  padding: 8px 0;
  font-family: var(--font-ko);
  font-size: clamp(56px, 19vw, 84px);
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}
.flash-main[lang="en"] { font-family: var(--font-ui); font-weight: 900; font-size: clamp(34px, 10vw, 46px); }
.flash-main.is-long { font-size: clamp(40px, 13vw, 58px); }
.flash-main[lang="en"].is-long { font-size: clamp(26px, 7.5vw, 34px); }
.flash-main[lang="en"].is-xlong { font-size: clamp(21px, 6vw, 26px); }
.flash-hint { font-size: 13px; font-weight: 800; text-align: center; color: rgba(255, 255, 255, .92); }
.flash-answer {
  margin-top: auto;
  padding-top: 12px;
  font-weight: 900;
  font-size: clamp(26px, 8vw, 36px);
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.flash-answer.is-long { font-size: clamp(22px, 6.5vw, 28px); }
.flash-answer.is-xlong { font-size: clamp(18px, 5vw, 22px); }
.flash-answer[lang="ko"] { font-family: var(--font-ko); font-weight: 400; font-size: clamp(44px, 14vw, 60px); }
.flash-sub { margin-top: 4px; font-family: var(--font-ko); font-size: 26px; text-align: center; color: var(--accent); }
.flash-sub:empty { display: none; }
.flash-example {
  margin-top: auto;
  padding-top: 12px;
  border-top: 2px dashed var(--hairline);
}
.example-ko { font-size: 18px; font-weight: 800; line-height: 1.5; }
.example-en { margin-top: 2px; font-size: 15px; font-weight: 600; color: var(--muted); }
mark { padding: 0 2px; border-radius: 4px; background: var(--yellow); color: var(--ink); }

.speak-btn {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: var(--border);
  border-radius: 50%;
  background: var(--paper);
  font-size: 20px;
  cursor: pointer;
}
.flash-wrap:has(.is-flipped) .speak-btn { top: 16px; }

.actions { min-height: 60px; }
.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade-row .btn { flex-direction: column; gap: 0; min-height: 66px; padding: 6px 4px; font-size: 15px; }
.grade-row .btn span { font-size: 22px; line-height: 1.2; }

/* --- Quiz --------------------------------------------------------------- */
.quiz-prompt {
  --accent: var(--blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 180px;
  padding: 14px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--accent);
  box-shadow: 0 5px 0 var(--ink);
  color: #fff;
  transition: background-color .15s ease;
}
.quiz-prompt .flash-tags { padding-right: 0; justify-content: center; }
.quiz-prompt.is-right { background: var(--green); }
.quiz-prompt.is-wrong { background: var(--red); }
.quiz-word {
  margin: auto 0;
  padding: 8px 0;
  font-family: var(--font-ko);
  font-size: clamp(48px, 15vw, 68px);
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}
.quiz-word[lang="en"] { font-family: var(--font-ui); font-weight: 900; font-size: clamp(28px, 8vw, 38px); }
.quiz-word.is-long { font-size: clamp(36px, 11vw, 50px); }
.quiz-word[lang="en"].is-long { font-size: clamp(22px, 6.5vw, 30px); }
.quiz-word[lang="en"].is-xlong { font-size: clamp(19px, 5vw, 24px); }
.speak-big {
  margin: auto 0;
  width: 84px;
  height: 84px;
  border: var(--border);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 36px;
  cursor: pointer;
}
.speak-big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 14px 8px 10px;
  border: var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.choice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.choice:disabled { cursor: default; color: var(--ink); opacity: .55; }
.choice-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 900;
}
.choice-ko { font-family: var(--font-ko); font-size: 24px; font-weight: 400; }
.choice.is-right { background: var(--green-soft); border-color: var(--green); box-shadow: 0 4px 0 var(--green); opacity: 1; }
.choice.is-right .choice-num { background: var(--green); border-color: var(--green); color: #fff; }
.choice.is-right .choice-num::before { content: '✓'; }
.choice.is-right .choice-num { font-size: 0; }
.choice.is-right .choice-num::before { font-size: 17px; }
.choice.is-wrong { background: var(--red-soft); border-color: var(--red); box-shadow: 0 4px 0 var(--red); opacity: 1; }
.choice.is-wrong .choice-num { background: var(--red); border-color: var(--red); font-size: 0; color: #fff; }
.choice.is-wrong .choice-num::before { content: '✕'; font-size: 16px; }

.type-form { display: grid; gap: 12px; }
.type-input { min-height: 62px; font-family: var(--font-ko); font-size: 26px; text-align: center; }
.type-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.feedback {
  padding: 14px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  animation: pop .22s ease;
}
.feedback-title { font-size: 20px; font-weight: 900; }
.feedback-title.is-right { color: var(--green); }
.feedback-title.is-wrong { color: #B3261E; }
.feedback-word { margin: 2px 0 8px; font-weight: 800; }
.feedback-word [lang="ko"] { font-family: var(--font-ko); font-size: 21px; font-weight: 400; }
.feedback .btn { margin-top: 12px; }

/* --- End of session ------------------------------------------------------ */
.end-card { width: 100%; max-width: 480px; margin: 0 auto; padding: 24px 18px; text-align: center; animation: pop .3s ease; }
.end-emoji { font-size: 66px; line-height: 1.1; }
.end-title { margin-top: 6px; font-size: 27px; font-weight: 900; line-height: 1.2; }
.end-summary { margin-top: 6px; font-size: 17px; color: var(--muted); }
.end-card > .muted { margin: 8px 0 18px; }
.end-subtitle { margin: 18px 0 6px; font-size: 16px; font-weight: 900; text-align: left; }
.end-card > .btn { margin-top: 12px; }
.missed-list {
  max-height: 34vh;
  margin: 0 0 8px;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  text-align: left;
}
.missed-list li { display: flex; align-items: baseline; gap: 10px; padding: 7px 2px; border-top: 2px dashed var(--hairline); }

.confetti { position: fixed; z-index: 30; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(var(--spin)); } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  transform: translateX(-50%);
}

/* --- Word list ----------------------------------------------------------- */
.word-filters { display: grid; gap: 10px; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.select-input { padding-inline: 10px; font-size: 14px; font-weight: 700; }
.empty-note { margin-top: 24px; color: var(--muted); text-align: center; }
.word-list { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.word-row { border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); }
.word-row summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}
.word-row summary::-webkit-details-marker { display: none; }
.word-main { min-width: 0; display: block; }
.word-ko { font-family: var(--font-ko); font-size: 21px; line-height: 1.2; }
.word-main .word-ko { display: block; }
.word-en { color: var(--muted); font-size: 14px; font-weight: 700; }
.status-tag { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-new { background: #EEE9DC; color: #4F5566; }
.status-learning { background: #FFF0C4; color: #6B4E00; }
.status-done { background: var(--green-soft); color: #0F6228; }
.word-detail { padding: 2px 12px 12px; border-top: 2px dashed var(--hairline); margin-top: 2px; padding-top: 10px; }
.word-meta { margin: 6px 0 8px; font-size: 13px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; }

/* --- Stats --------------------------------------------------------------- */
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-tile { display: block; padding: 12px 14px; box-shadow: 0 4px 0 var(--ink); }
.stat-value { display: block; font-size: 32px; font-weight: 900; line-height: 1.1; }
.stat-label { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.panel { margin-top: 16px; padding: 14px; box-shadow: 0 4px 0 var(--ink); }
.panel-title { margin-bottom: 10px; font-size: 17px; font-weight: 900; }
.panel-note { margin-top: 8px; font-size: 13px; }

.level-row { --accent: var(--blue); margin-bottom: 12px; }
.level-head { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 8px; font-size: 13px; }
.level-name { font-size: 15px; font-weight: 900; }
.stack-track {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-top: 4px;
  border-radius: 7px;
  background: #EEE9DC;
  overflow: hidden;
}
.stack-track span { display: block; height: 100%; }
.stack-track span:first-child { border-radius: 4px 0 0 4px; }
.stack-done { background: var(--ink); }
.stack-learning { background: var(--muted); opacity: .55; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

.bars { margin: 18px 0 0; }
.bars-plot { display: flex; gap: 2px; align-items: stretch; height: 124px; }
.bar-col {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  outline-offset: 0;
}
.bar-area {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--hairline);
}
.bar-mark { width: min(100%, 24px); max-width: 24px; border-radius: 4px 4px 0 0; background: var(--blue); }
.bars-forecast .bar-mark { background: var(--purple); }
.bar-value { position: absolute; left: 0; right: 0; font-size: 12px; font-weight: 800; text-align: center; color: var(--muted); }
.bar-day { padding-top: 4px; font-size: 11px; font-weight: 800; text-align: center; color: var(--muted); }
.bar-tip {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + 2px);
  left: 50%;
  display: none;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.bar-col:first-child .bar-tip, .bar-col:nth-child(2) .bar-tip { left: 0; transform: none; }
.bar-col:last-child .bar-tip, .bar-col:nth-last-child(2) .bar-tip { left: auto; right: 0; transform: none; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: block; }

.setting-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.logout-btn { margin-top: 14px; }
.credits { margin-top: 18px; font-size: 12px; font-weight: 600; color: var(--muted); }
.credits p + p { margin-top: 6px; }

/* --- Accounts ------------------------------------------------------------ */
.login-password { margin-top: 12px; }
.user-submit { margin-top: 12px; }
.user-name { display: block; font-size: 17px; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.logout-btn { text-decoration: none; }

/* --- Ideas -------------------------------------------------------------- */
.idea-fab {
  position: fixed;
  z-index: 20;
  /* Sits in the corner of the centered column, above the navigation if there is one. */
  right: max(12px, calc(50% - 268px));
  bottom: calc(10px + var(--safe-bottom));
  width: 46px;
  height: 46px;
  padding: 0;
  border: var(--border);
  border-radius: 50%;
  background: var(--ink); /* A yellow bulb disappears on a yellow background. */
  box-shadow: 0 3px 0 rgba(28, 35, 51, .35);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.idea-fab:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.has-nav .idea-fab { bottom: calc(74px + var(--safe-bottom)); }
/* Keeps the last button of a session from sitting under the lightbulb. */
.session .stage { padding-bottom: calc(66px + var(--safe-bottom)); }

.idea-dialog {
  width: calc(100% - 32px);
  max-width: 480px;
  margin: 10vh auto auto;
  padding: 18px 16px 14px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
}
.idea-dialog::backdrop { background: rgba(28, 35, 51, .55); }
.idea-title { margin-bottom: 10px; font-size: 20px; font-weight: 900; }
.idea-input { display: block; resize: vertical; line-height: 1.4; }
.idea-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.idea-actions .btn:disabled { opacity: .6; }
.idea-all { display: block; margin-top: 12px; padding: 6px; color: var(--muted); font-size: 14px; text-align: center; }

.ideas-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
}
.ideas-link .panel-title { margin: 0; }

.idea-add { display: grid; gap: 10px; }
.idea-list { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.idea-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
}
.idea-text { flex: 1; min-width: 0; }
.idea-body { overflow-wrap: anywhere; }
.idea-meta { margin-top: 2px; color: var(--muted); font-size: 13px; }
.idea-check {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.idea-delete { width: 36px; height: 36px; color: var(--muted); font-size: 15px; }
.idea-row.is-done { opacity: .75; }
.idea-row.is-done .idea-check { background: var(--green); border-color: var(--green); }
.idea-row.is-done .idea-body { text-decoration: line-through; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
