:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f7f7fa;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.32);
  --separator: rgba(60, 60, 67, 0.16);
  --fill: rgba(120, 120, 128, 0.12);
  --tint: #007aff;
  --red: #ff3b30;
  --orange: #ff9500;
  --green: #34c759;
  --blue: #007aff;
  --indigo: #5856d6;
  --bar: rgba(249, 249, 251, 0.78);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.05), 0 18px 48px rgba(0, 0, 0, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(56px + var(--safe-bottom));
  --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
  --spring: cubic-bezier(0.32, 1.25, 0.5, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(118, 118, 128, 0.24);
    --tint: #0a84ff;
    --red: #ff453a;
    --orange: #ff9f0a;
    --green: #30d158;
    --blue: #0a84ff;
    --indigo: #5e5ce6;
    --bar: rgba(22, 22, 24, 0.72);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%; /* stop Chrome on Android from inflating text */
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.view { min-height: 100%; animation: viewIn 0.28s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content {
  padding: calc(var(--safe-top) + 44px) 20px calc(var(--tabbar-h) + 28px);
  max-width: 560px;
  margin: 0 auto;
}
.large-title {
  font-size: 34px; font-weight: 700; letter-spacing: 0.37px; line-height: 41px;
  margin: 6px 0 20px;
}

/* ---------- frosted navigation bar ---------- */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(44px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border-bottom: 0.5px solid transparent;
  transition: background 0.25s, border-color 0.25s;
}
.navbar.scrolled {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--separator);
}
.navbar-title { font-size: 17px; font-weight: 600; opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; }
.navbar.scrolled .navbar-title { opacity: 1; transform: none; }
.navbar-right { position: absolute; right: 16px; bottom: 0; height: 44px; display: flex; align-items: center; font-size: 17px; color: var(--label-2); }
.nav-btn { color: var(--tint); font-size: 17px; font-weight: 400; }
.nav-btn:active { opacity: 0.4; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--tabbar-h);
  padding-bottom: var(--safe-bottom);
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #999; font-size: 10.5px; font-weight: 500; letter-spacing: 0.1px;
  transition: color 0.2s;
}
.tab svg { width: 27px; height: 27px; stroke-width: 1.9; transition: transform 0.25s var(--spring); }
.tab.active { color: var(--tint); }
.tab:active svg { transform: scale(0.88); }
.tab .badge {
  position: absolute; top: 5px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 12px; font-style: normal; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.tab .dot { position: absolute; top: 7px; left: calc(50% + 10px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
h2 { font-size: 22px; font-weight: 700; letter-spacing: 0.35px; margin: 0 0 8px; }
p { font-size: 17px; line-height: 1.4; color: var(--label-2); margin: 0; }

.hero { text-align: center; padding: 32px 24px 30px; margin-bottom: 22px; }
.hero-art { position: relative; height: 128px; margin: 0 auto 22px; width: 190px; }
.mini-card {
  position: absolute; left: 50%; top: 50%;
  width: 118px; height: 84px; margin: -42px 0 0 -59px;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.mini-card.c1 { background: linear-gradient(135deg, #ffb340, #ff6b6b); transform: rotate(-14deg) translate(-26px, 6px); }
.mini-card.c2 { background: linear-gradient(135deg, #64d2ff, #5e5ce6); transform: rotate(10deg) translate(26px, 4px); }
.mini-card.c3 {
  background: var(--card); border: 0.5px solid var(--separator);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--label);
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-5px); } }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 600; letter-spacing: -0.2px;
  transition: transform 0.15s var(--ease), opacity 0.15s, background 0.2s;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-large { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn-primary { background: var(--tint); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--tint) 30%, transparent); }
.btn-primary svg { width: 22px; height: 22px; stroke-width: 2.4; }
.btn-plain { color: var(--tint); font-weight: 500; margin-top: 8px; }
.btn-link { display: block; margin: 18px auto 0; color: var(--tint); font-size: 16px; padding: 10px; }
.btn-link:active { opacity: 0.4; }
.btn-danger { background: var(--fill); color: var(--red); }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 18px; padding: 14px 14px 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 18px; cursor: pointer;
  animation: pop 0.4s var(--spring);
}
.banner:active { transform: scale(0.98); }
.banner-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.banner-icon svg { width: 22px; height: 22px; }
.banner-text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.banner-text span { color: var(--label-2); font-size: 14px; }
.chev { width: 16px; height: 16px; color: var(--label-3); stroke-width: 2.5; flex: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

/* ---------- working ---------- */
.working-card, .done-card { text-align: center; padding: 40px 24px 34px; margin-bottom: 18px; }
.ring { width: 76px; height: 76px; margin: 0 auto 22px; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring-bg { stroke: var(--fill); }
.ring-fg { stroke: var(--tint); stroke-dasharray: 176; stroke-dashoffset: 176; transition: stroke-dashoffset 0.5s var(--ease); }
.ring.spin svg { animation: spin 1.1s linear infinite; }
.ring.spin .ring-fg { stroke-dashoffset: 125; }
@keyframes spin { to { transform: rotate(270deg); } }

.check svg { width: 76px; height: 76px; margin-bottom: 18px; }
.check circle { stroke: var(--green); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.6s var(--ease) forwards; }
.check path { stroke: var(--green); stroke-width: 4; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.4s 0.4s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.err-icon { width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); font-size: 34px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* ---------- lists ---------- */
.list.inset { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 22px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 56px; padding: 11px 16px; position: relative;
  background: var(--card); transition: background 0.15s;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.row.with-icon + .row::before, .settings .row + .row::before { left: 60px; }
.row-button:active, .row.tappable:active { background: var(--fill); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 17px; }
.row-title { font-size: 17px; font-weight: 600; }
.row-title .art { font-weight: 400; color: var(--label-2); }
.row-sub { font-size: 15px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 13px; color: var(--label-3); flex: none; }
.row-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.row-icon svg { width: 18px; height: 18px; stroke-width: 2.2; }
.row-icon.blue { background: var(--blue); }
.row-icon.green { background: var(--green); }

.toggle {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--label-3);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--spring);
}
.toggle svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; opacity: 0; transform: scale(0.5); transition: 0.2s var(--spring); }
.row.on .toggle { background: var(--tint); border-color: var(--tint); }
.row.on .toggle svg { opacity: 1; transform: none; }
#results-list .row:not(.on) .row-main { opacity: 0.45; }

.section-note { font-size: 15px; margin: -8px 4px 12px; }
.captions { margin: 0 0 22px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 0 16px; }
.captions summary { list-style: none; padding: 16px 0; font-size: 17px; color: var(--tint); cursor: pointer; }
.captions summary::-webkit-details-marker { display: none; }
.captions[open] summary { border-bottom: 0.5px solid var(--separator); }
#caption-lines p { font-size: 15px; padding: 10px 0; border-bottom: 0.5px solid var(--separator); color: var(--label); -webkit-user-select: text; user-select: text; }
#caption-lines p:last-child { border: 0; }
.sticky-action {
  position: sticky; bottom: var(--tabbar-h); z-index: 5;
  margin: 0 -20px; padding: 28px 20px 14px;
  background: linear-gradient(to bottom, transparent, var(--bg) 38%);
}
#discard-results { margin: 0 0 8px; }

/* ---------- search / stats ---------- */
.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--label-2); }
.search input {
  width: 100%; height: 38px; border: 0; border-radius: 11px; padding: 0 12px 0 36px;
  background: var(--fill); color: var(--label); font: inherit; font-size: 17px; outline: none;
}
.search input::placeholder { color: var(--label-2); }
.stats { display: flex; gap: 10px; margin-bottom: 18px; }
.stat { flex: 1; background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; font-weight: 700; letter-spacing: 0.3px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--label-2); font-weight: 500; }
.footnote { font-size: 13px; color: var(--label-3); text-align: center; padding: 0 12px; }
.empty { text-align: center; padding: 70px 20px 20px; }
.empty.small { padding: 24px; }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 20px; border-radius: 50%; background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); display: flex; align-items: center; justify-content: center; }
.empty-icon svg { width: 38px; height: 38px; stroke-width: 2.6; }
.empty .btn { margin-top: 28px; }

/* ---------- review ---------- */
.review-content { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
#review-area { display: flex; flex-direction: column; flex: 1; }
.progress { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; margin: -6px 0 18px; }
.progress-bar { height: 100%; width: 0; background: var(--tint); border-radius: 2px; transition: width 0.4s var(--ease); }
.stage { perspective: 1400px; flex: 1; display: flex; min-height: 340px; max-height: 480px; position: relative; }
.flashcard {
  position: relative; flex: 1;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--spring);
  cursor: pointer; touch-action: pan-y;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard.dragging { transition: none; }
.flashcard.fly { transition: transform 0.35s var(--ease), opacity 0.35s; }
.flashcard.enter { animation: cardIn 0.4s var(--spring); }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 26px; text-align: center; overflow: hidden;
}
.face.back { transform: rotateY(180deg); justify-content: flex-start; padding-top: 40px; }
.face .pos { position: absolute; top: 22px; left: 0; right: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--label-3); }
.word { font-size: 40px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.15; word-break: break-word; }
.word .article { font-weight: 400; color: var(--label-2); margin-right: 10px; }
.word.small { font-size: 22px; color: var(--label-2); font-weight: 600; margin-top: 14px; }
.hint { position: absolute; bottom: 22px; font-size: 14px; color: var(--label-3); }
.meaning { font-size: 26px; font-weight: 600; line-height: 1.25; margin: 22px 0 0; }
.example {
  margin: auto 0 4px; padding: 16px 18px; width: 100%;
  background: var(--card-2); border-radius: 16px;
  font-size: 17px; line-height: 1.4; color: var(--label-2); text-align: left; font-style: italic;
}
.example b { color: var(--label); font-weight: 600; font-style: normal; }
.swipe-tag {
  position: absolute; top: 26px; padding: 6px 12px; border-radius: 10px;
  font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  border: 2.5px solid; opacity: 0; pointer-events: none; z-index: 2; transition: opacity 0.1s;
}
.swipe-tag.left { right: 22px; color: var(--red); transform: rotate(8deg); }
.swipe-tag.right { left: 22px; color: var(--green); transform: rotate(-8deg); }

.grade-area { padding: 22px 0 10px; min-height: 100px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; animation: pop 0.3s var(--spring); }
.grade {
  min-height: 64px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 16px; font-weight: 600;
  transition: transform 0.15s var(--ease);
}
.grade:active { transform: scale(0.94); }
.grade small { font-size: 12px; font-weight: 500; opacity: 0.75; }
.grade.again { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.grade.hard { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.grade.good { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.grade.easy { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.35); animation: fade 0.3s; }
.sheet-backdrop.out { animation: fade 0.25s reverse forwards; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: calc(100% - var(--safe-top) - 16px);
  background: var(--bg); border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
  animation: sheetIn 0.45s var(--spring);
  max-width: 640px; margin: 0 auto;
}
.sheet.out { animation: sheetOut 0.28s var(--ease) forwards; }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; }
.sheet-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 16px 10px; }
.sheet-header .nav-btn { justify-self: start; font-weight: 600; }
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 8px 20px calc(var(--safe-bottom) + 28px); -webkit-overflow-scrolling: touch; }
.sheet-body h3 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; color: var(--label-2); margin: 22px 16px 8px; }
.field { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; background: var(--card); position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.field label { font-size: 13px; color: var(--label-2); }
.field input, .field textarea { border: 0; background: none; font: inherit; font-size: 17px; color: var(--label); outline: none; padding: 0; resize: none; width: 100%; }
.detail-word { text-align: center; padding: 18px 0 6px; }
.detail-word .word { font-size: 34px; }
.detail-word p { font-size: 15px; margin-top: 6px; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 14px 16px 14px 56px; background: var(--card); font-size: 16px; line-height: 1.42; }
.steps li + li::after { content: ""; position: absolute; top: 0; left: 56px; right: 0; border-top: 0.5px solid var(--separator); }
.steps li::before {
  content: counter(step); position: absolute; left: 16px; top: 13px;
  width: 26px; height: 26px; border-radius: 50%; background: var(--tint); color: #fff;
  font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.steps b { font-weight: 600; }
.copy-box {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  background: var(--card-2); border-radius: 10px; padding: 8px 8px 8px 12px;
}
.copy-box code { flex: 1; font: 13px/1.35 ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; color: var(--label); -webkit-user-select: all; user-select: all; }
.copy-box button { flex: none; background: var(--tint); color: #fff; font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 8px; }
.copy-box button:active { opacity: 0.7; }
.note { font-size: 14px; color: var(--label-2); margin: 10px 16px 0; line-height: 1.4; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); z-index: 60;
  transform: translateX(-50%);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  color: var(--label); font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: 30px; box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s var(--spring);
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) scale(0.95); } }

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

/* ---------- sets & direction ---------- */
.navbar-left { position: absolute; left: 16px; bottom: 0; height: 44px; display: flex; align-items: center; }
.row-icon.indigo { background: var(--indigo); }
.row-value { color: var(--label-2); font-size: 17px; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results-set-wrap .row-main { flex: 1; }

.review-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -8px 0 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px 0 14px;
  border-radius: 18px; background: var(--fill); font-size: 15px; font-weight: 600; max-width: 48%;
  transition: transform 0.15s var(--ease);
}
.pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill svg { width: 18px; height: 18px; flex: none; color: var(--label-2); }
.pill:active { transform: scale(0.96); }
.segmented { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; position: relative; }
.segmented button {
  min-height: 32px; padding: 0 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--label-2);
  transition: background 0.25s var(--ease), color 0.25s, box-shadow 0.25s;
}
.segmented button.on { background: var(--card); color: var(--label); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.word.en { font-size: 30px; line-height: 1.25; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px 16px; padding: 2px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card);
  box-shadow: var(--shadow); font-size: 15px; font-weight: 600; color: var(--label);
  display: inline-flex; align-items: center; gap: 6px; transition: background 0.2s, color 0.2s, transform 0.15s var(--ease);
}
.chip small { font-weight: 500; opacity: 0.6; font-size: 13px; }
.chip.on { background: var(--tint); color: #fff; }
.chip.add { color: var(--tint); }
.chip:active { transform: scale(0.95); }

#library-list.selecting .row .chev, #library-list.selecting .row-meta { display: none; }
.row .toggle.sel { margin-right: 2px; }
.row.picked .toggle { background: var(--tint); border-color: var(--tint); }
.row.picked .toggle svg { opacity: 1; transform: none; }
.select-bar {
  position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 31;
  display: flex; align-items: center; justify-content: space-between; padding: 12px 20px;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator); font-size: 15px; color: var(--label-2);
  animation: pop 0.25s var(--ease);
}
.nav-btn.danger { color: var(--red); }
.nav-btn:disabled { opacity: 0.35; }

.set-list .row .tick { width: 22px; height: 22px; color: var(--tint); stroke-width: 2.6; flex: none; }
body.selecting .content { padding-bottom: calc(var(--tabbar-h) + 90px); }
.set-list .row .count { color: var(--label-2); font-size: 15px; }
.new-set { display: flex; gap: 8px; align-items: center; background: var(--card); border-radius: 14px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.new-set input { flex: 1; border: 0; background: none; font: inherit; font-size: 17px; color: var(--label); outline: none; min-width: 0; height: 40px; }
.new-set button { background: var(--tint); color: #fff; font-weight: 600; font-size: 15px; border-radius: 10px; padding: 0 14px; height: 38px; }
.new-set button:disabled { opacity: 0.4; }
.set-edit { display: flex; align-items: center; gap: 10px; }
.set-edit input { flex: 1; border: 0; background: none; font: inherit; font-size: 17px; color: var(--label); outline: none; min-width: 0; }
.set-edit .del { color: var(--red); font-size: 15px; font-weight: 500; }

/* ---------- profile: "clear" liquid-glass card ---------- */
.tab-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--fill); box-shadow: 0 0 0 1.5px transparent; transition: box-shadow 0.2s, transform 0.25s var(--spring); }
.tab.active .tab-avatar { box-shadow: 0 0 0 2px var(--tint); }
.tab:active .tab-avatar { transform: scale(0.88); }

.glass-stage {
  position: relative; border-radius: 34px; overflow: hidden; padding: 22px 16px 16px;
  background: linear-gradient(160deg, #5e8bff 0%, #8f6bff 45%, #ff6b8b 100%);
  isolation: isolate; margin-bottom: 26px; box-shadow: var(--shadow-lg);
}
@media (prefers-color-scheme: dark) { .glass-stage { background: linear-gradient(160deg, #1d3a8a 0%, #4b2a9a 50%, #8a1f45 100%); } }
.blob { position: absolute; border-radius: 50%; filter: blur(28px); opacity: 0.85; z-index: -1; animation: drift 14s ease-in-out infinite alternate; }
.blob.b1 { width: 220px; height: 220px; background: #ff9f43; top: -60px; left: -50px; }
.blob.b2 { width: 240px; height: 240px; background: #ef233c; bottom: -90px; right: -60px; animation-duration: 18s; }
.blob.b3 { width: 180px; height: 180px; background: #06d6a0; top: 40%; left: 55%; animation-duration: 22s; opacity: 0.6; }
@keyframes drift { to { transform: translate(30px, 24px) scale(1.12); } }

.glass-card {
  position: relative; border-radius: 28px; padding: 26px 18px 18px; text-align: center; color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,0.24), rgba(40,20,90,0.10));
  text-shadow: 0 1px 3px rgba(20,10,50,0.35);
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid rgba(255,255,255,0.45);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(255,255,255,0.15), 0 10px 30px rgba(20,10,60,0.25);
}
.glass-card::before { /* specular highlight */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 60% at 20% 0%, rgba(255,255,255,0.45), transparent 55%);
  mix-blend-mode: soft-light;
}
.avatar-btn { position: relative; width: 116px; height: 116px; border-radius: 50%; margin: 0 auto 12px; display: block;
  background: rgba(255,255,255,0.35); border: 1px solid rgba(255,255,255,0.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 8px 20px rgba(0,0,0,0.18); transition: transform 0.25s var(--spring); }
.avatar-btn:active { transform: scale(0.95); }
.avatar-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-edit { position: absolute; right: 0; bottom: 2px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.85); color: #3a3a8c; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.avatar-edit svg { width: 16px; height: 16px; stroke-width: 2.4; }
.glass-name { font-size: 26px; font-weight: 700; letter-spacing: 0.3px; text-shadow: 0 1px 8px rgba(0,0,0,0.18); }
.glass-sub { font-size: 15px; opacity: 0.95; font-weight: 500; margin-top: 3px; min-height: 18px; }
.glass-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.glass-pill { border-radius: 18px; padding: 10px 4px; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4); }
.glass-pill b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.glass-pill span { font-size: 12px; opacity: 0.9; font-weight: 500; }
.goal { margin-top: 14px; text-align: left; }
.goal-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; opacity: 0.95; margin: 0 4px 6px; }
.goal-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.25); overflow: hidden; }
.goal-fill { height: 100%; width: 0; border-radius: 4px; background: #fff; transition: width 0.8s var(--ease); }

.section-title { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; color: var(--label-2); margin: 0 16px 8px; }

/* ---------- activity heatmap (GitHub-style), one sequential blue ramp ---------- */
:root { --h0: rgba(120,120,128,0.14); --h1: #86b6ef; --h2: #3987e5; --h3: #256abf; --h4: #104281; }
@media (prefers-color-scheme: dark) { :root { --h0: rgba(118,118,128,0.22); --h1: #184f95; --h2: #256abf; --h3: #3987e5; --h4: #86b6ef; } }
.activity-card { padding: 16px 14px 14px; margin-bottom: 26px; }
.activity-head { font-size: 15px; color: var(--label); margin: 0 2px 12px; }
.activity-head b { font-weight: 700; }
.heatmap-wrap { display: flex; gap: 6px; }
.heatmap-days { display: grid; grid-template-rows: 16px repeat(7, var(--cell)); row-gap: var(--gap); font-size: 10px; color: var(--label-2); }
.heatmap-days span:first-child { height: 16px; }
.heatmap-days span { line-height: var(--cell); }
.heatmap-scroll { flex: 1; min-width: 0; }
.heatmap-months { position: relative; height: 16px; font-size: 10px; color: var(--label-2); }
.heatmap-months span { position: absolute; top: 0; white-space: nowrap; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell)); grid-auto-columns: var(--cell); gap: var(--gap); }
.heatmap i { border-radius: 3px; background: var(--h0); position: relative; cursor: pointer; }
.heatmap i.l1 { background: var(--h1); } .heatmap i.l2 { background: var(--h2); }
.heatmap i.l3 { background: var(--h3); } .heatmap i.l4 { background: var(--h4); }
.heatmap i.today { box-shadow: 0 0 0 1.5px var(--label-2); }
.heatmap i.future { visibility: hidden; }
.heatmap i.sel { box-shadow: 0 0 0 2px var(--label); z-index: 1; }
.heatmap i::after { content: ""; position: absolute; inset: -2px; } /* bigger hit target */
.heatmap-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--label-2); }
.heat-tip { color: var(--label); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .l0 { background: var(--h0); } .legend .l1 { background: var(--h1); } .legend .l2 { background: var(--h2); }
.legend .l3 { background: var(--h3); } .legend .l4 { background: var(--h4); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 26px; }
.stat-grid .stat { padding: 14px 16px; }
.stat-grid .stat b { font-size: 26px; }
.stat-grid .stat em { font-style: normal; font-size: 12px; color: var(--label-3); display: block; margin-top: 2px; }

/* ---------- about-me form rows ---------- */
.field-row { cursor: text; }
.field-row input, .field-row select, .field-row textarea {
  border: 0; background: none; font: inherit; font-size: 17px; color: var(--label-2); text-align: right; outline: none;
  min-width: 0; max-width: 55%; -webkit-appearance: none; appearance: none;
}
.field-row input:focus, .field-row textarea:focus { color: var(--label); }
.field-row select { color: var(--tint); text-align-last: right; }
.field-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.field-row.col textarea { text-align: left; max-width: none; resize: none; }
.about .row + .row::before { left: 16px; }

/* ---------- avatar picker ---------- */
.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 8px 4px 4px; }
.avatar-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--label-2); }
.avatar-opt img { width: 92px; height: 92px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); object-fit: cover;
  border: 3px solid transparent; transition: transform 0.2s var(--spring), border-color 0.2s; }
.avatar-opt.on img { border-color: var(--tint); }
.avatar-opt.on { color: var(--label); }
.avatar-opt:active img { transform: scale(0.93); }

/* ---------- mascot (the beret dachshund) on the Add screen ---------- */
.mascot-card { position: relative; margin-top: 104px; }
.mascot { position: relative; height: 150px; margin: -118px auto 14px; display: flex; justify-content: center; align-items: flex-end; pointer-events: none; }
.mascot::before { /* soft glow so the dog sits "in" the card, not pasted on it */
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 190px; height: 190px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tint) 18%, transparent) 0%, transparent 68%); z-index: 0;
}
.mascot::after { /* little ground shadow */
  content: ""; position: absolute; left: 50%; bottom: -2px; width: 110px; height: 14px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(ellipse, rgba(0,0,0,0.16), transparent 70%);
}
.mascot img { position: relative; z-index: 1; height: 100%; width: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.12)); transform-origin: 50% 100%; }
.m-coffee img { animation: sway 5s ease-in-out infinite; }
.m-standing { height: 172px; margin-top: -140px; }
.m-standing img { animation: hop 1.1s ease-in-out infinite; }
.m-sleeping { height: 104px; margin-top: -76px; }
.m-sleeping img { animation: breathe 3.2s ease-in-out infinite; }
.m-cool img { animation: popIn 0.6s var(--spring) both; }
.m-belly { height: 96px; margin-top: -66px; }
.m-belly img { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(-2deg) translateY(-2px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-9px) rotate(1deg); } 60% { transform: translateY(0) scaleY(0.97); } }
@keyframes breathe { 50% { transform: scale(1.025, 1.04); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes popIn { from { transform: scale(0.6) translateY(20px); opacity: 0; } }

.bubble {
  position: absolute; z-index: 2; top: 2px; left: calc(50% + 40px); max-width: min(150px, calc(50% - 30px));
  background: var(--card); color: var(--label); font-size: 14px; font-weight: 600; line-height: 1.25;
  padding: 8px 12px; border-radius: 16px 16px 16px 5px; box-shadow: var(--shadow);
  border: 0.5px solid var(--separator); text-align: left; animation: bubbleIn 0.5s 0.25s var(--spring) both;
}
.m-sleeping .bubble, .m-belly .bubble { top: -34px; }
@keyframes bubbleIn { from { opacity: 0; transform: scale(0.6) translateY(8px); transform-origin: 0 100%; } }

.steam { position: absolute; z-index: 2; bottom: 72px; width: 6px; height: 22px; border-radius: 6px;
  background: linear-gradient(to top, rgba(160,160,170,0.55), transparent); animation: steam 2.6s ease-out infinite; opacity: 0; }
.steam.s1 { left: calc(50% + 6px); } .steam.s2 { left: calc(50% + 16px); animation-delay: 0.8s; } .steam.s3 { left: calc(50% + 26px); animation-delay: 1.6s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(0) scaleX(1); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px) scaleX(1.8); } }

.twinkle { position: absolute; z-index: 2; color: #f5b83d; font-size: 18px; animation: twinkle 1.8s ease-in-out infinite; }
.twinkle.t1 { left: calc(50% - 96px); top: 40px; } .twinkle.t2 { left: calc(50% + 70px); top: 88px; animation-delay: 0.6s; font-size: 14px; }
.twinkle.t3 { left: calc(50% - 70px); top: 108px; animation-delay: 1.2s; font-size: 12px; }
@keyframes twinkle { 0%, 100% { transform: scale(0.5) rotate(0); opacity: 0.3; } 50% { transform: scale(1.1) rotate(20deg); opacity: 1; } }

.work-bar { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin: 22px 8px 0; }
.work-fill { height: 100%; width: 3%; border-radius: 3px; background: var(--tint); transition: width 0.5s var(--ease); }
.work-bar.indeterminate .work-fill { width: 35%; animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-110%); } to { transform: translateX(320%); } }
.hero.mascot-card { padding-top: 22px; }
.working-card.mascot-card, .done-card.mascot-card { padding-top: 22px; }

/* ---------- small phones (and Chrome's narrow device sizes) ---------- */
.segmented button, .stat span, .glass-pill span, .btn { white-space: nowrap; }
.stat span, .glass-pill span { display: block; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: 0 1 auto; min-width: 0; }
.segmented { flex: none; }
@media (max-width: 374px) {
  .link-row { flex-direction: column; }
  .link-row .btn-link { padding: 6px; }
  .link-dot { display: none; }
  .content { padding-left: 14px; padding-right: 14px; }
  .chips { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .sticky-action { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .large-title { font-size: 30px; line-height: 36px; }
  .card { padding: 22px 16px; }
  .hero h2, .done-card h2, .working-card h2 { font-size: 20px; }
  p { font-size: 16px; }
  .btn-large { font-size: 16px; }
  .review-controls { gap: 8px; }
  .pill { font-size: 14px; padding: 0 10px; }
  .segmented button { padding: 0 8px; font-size: 13px; }
  .word { font-size: 34px; }
  .meaning { font-size: 22px; }
  .grades { gap: 6px; }
  .grade { font-size: 15px; min-height: 58px; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 24px; }
  .stat span { font-size: 12px; }
  .stat-grid { gap: 8px; }
  .stat-grid .stat b { font-size: 22px; }
  .glass-name { font-size: 22px; }
  .glass-pills { gap: 6px; }
  .glass-pill b { font-size: 19px; }
  .glass-pill span { font-size: 11px; }
  .bubble { font-size: 12.5px; left: calc(50% + 34px); max-width: calc(50% - 36px); padding: 6px 9px; }
  .avatar-grid { gap: 10px; }
  .avatar-opt img { width: 76px; height: 76px; }
}
@media (max-width: 300px) {
  .large-title { font-size: 28px; }
  .btn-large { font-size: 15px; padding: 0 12px; }
  .segmented button { font-size: 12px; padding: 0 6px; }
  .pill { font-size: 13px; }
  .stat { padding: 10px; }
  .stat b { font-size: 21px; }
  .stat span { font-size: 11px; }
  .grade { font-size: 14px; }
  .grade small { font-size: 11px; }
  .bubble { font-size: 12px; }
}

/* ---------- import words ---------- */
.link-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0 2px; margin-top: 14px; }
.link-row .btn-link { margin: 0; padding: 10px 6px; font-size: 15px; white-space: nowrap; }
.link-dot { color: var(--label-3); }
.row-icon.orange { background: var(--orange); }
.import-box { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.import-box textarea { width: 100%; min-height: 180px; border: 0; background: none; resize: vertical; outline: none;
  font: 16px/1.45 ui-monospace, "SF Mono", Menlo, monospace; color: var(--label); }
.import-box textarea::placeholder { color: var(--label-3); }
.import-actions { display: flex; gap: 10px; margin: 12px 0 4px; }
.import-actions .btn { flex: 1; }
.btn-secondary { background: var(--fill); color: var(--tint); }
.import-count { font-size: 14px; color: var(--label-2); margin: 10px 4px 0; min-height: 18px; }
.row-sub.missing { color: var(--orange); font-style: italic; }

/* ---------- verbs (conjugation) ---------- */
.verb-search { margin-bottom: 10px; }
.verb-suggest { margin: -2px 0 14px; }
.verb-suggest .row { min-height: 46px; font-size: 17px; }
.verb-suggest .row b { font-weight: 600; }
.verb-recent { margin-bottom: 18px; }
.verb-recent:empty { display: none; }
.verb-empty { text-align: center; padding: 40px 8px 0; }
.verb-empty .mascot { margin: 0 auto 18px; }
.verb-empty p { font-size: 16px; max-width: 300px; margin: 0 auto; }
.verb-empty p b { color: var(--label); }
.verb-head { padding: 24px 20px 18px; margin-bottom: 18px; animation: pop 0.35s var(--spring); }
.verb-inf { font-size: 34px; font-weight: 700; letter-spacing: 0.2px; }
.verb-meaning { font-size: 17px; color: var(--label-2); margin-top: 4px; }
.verb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.verb-tags span { font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 12px; background: var(--fill); color: var(--label-2); }
.verb-tags span.aux { background: color-mix(in srgb, var(--indigo) 16%, transparent); color: var(--indigo); }
.verb-parts { margin-top: 14px; font-size: 15px; color: var(--label-2); display: grid; gap: 4px; }
.verb-parts b { color: var(--label); font-weight: 600; }
.verb-note { font-size: 14px; margin-top: 10px; }
.verb-actions { display: flex; gap: 10px; margin-top: 16px; }
.verb-actions .btn { min-height: 44px; font-size: 16px; min-width: 0; padding: 0 12px; overflow: hidden; text-overflow: ellipsis; }
.verb-actions .btn-primary { flex: 1.4; }
.verb-actions .btn-secondary { flex: 1; }
.verb-actions .btn-secondary.on { background: var(--tint); color: #fff; }
.mood-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px 14px; padding: 2px 20px; scrollbar-width: none; }
.mood-tabs::-webkit-scrollbar { display: none; }
.mood-tabs button { flex: none; min-height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card); box-shadow: var(--shadow);
  font-size: 15px; font-weight: 600; transition: background 0.2s, color 0.2s; }
.mood-tabs button.on { background: var(--tint); color: #fff; }
.tense-list { display: grid; gap: 12px; margin-bottom: 22px; }
@media (min-width: 600px) { .tense-list { grid-template-columns: 1fr 1fr; } }
.tense { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px 10px; animation: pop 0.3s var(--ease) both; }
.tense h4 { margin: 0 0 8px; font-size: 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tense h4 small { font-size: 12px; font-weight: 500; color: var(--label-3); text-transform: none; }
.tense ul { list-style: none; margin: 0; padding: 0; }
.tense li { font-size: 17px; line-height: 1.5; padding: 3px 0; border-top: 0.5px solid var(--separator); -webkit-user-select: text; user-select: text; }
.tense li:first-child { border-top: 0; }
.tense li .pr { color: var(--label-2); }
.tense li .vb { font-weight: 600; }
.tense li .alt { font-size: 13px; color: var(--label-3); margin-left: 6px; }
@media (max-width: 374px) {
  .mood-tabs { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .verb-inf { font-size: 28px; }
  .tense li { font-size: 16px; }
  .tab span { font-size: 10px; }
}
.tab span { white-space: nowrap; }

/* ---------- Learn tab: grammar practice, vocab decks ---------- */
.gram-seg { margin: -8px 0 18px; }
.gram-seg button { flex: 1; }
.quizzing .gram-chrome { display: none; }
.quizzing .navbar .navbar-title { opacity: 1; transform: none; }

.meter { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--tint); transition: width 0.5s var(--ease); }

/* topic categories: one accent for fills, one darker ink for text on a tinted tile */
.cat-verbs, [data-cat="verbs"] { --cat: #1f7bff; --ink: #0a5fd1; --g1: #3d8bff; --g2: #6a5cff; }
.cat-nouns, [data-cat="nouns"] { --cat: #ff8f1f; --ink: #a85400; --g1: #ffa23d; --g2: #ff5c7a; }
.cat-pronouns, [data-cat="pronouns"] { --cat: #6c5ce7; --ink: #4a3fc4; --g1: #7a5cff; --g2: #c04bff; }
.cat-sentence, [data-cat="sentence"] { --cat: #12a878; --ink: #0b7a55; --g1: #14b88f; --g2: #2f80ed; }
.cat-linking, [data-cat="linking"] { --cat: #f0357a; --ink: #c2185b; --g1: #ff5c8a; --g2: #a24bff; }
@media (prefers-color-scheme: dark) {
  .cat-verbs { --ink: #74b4ff; } .cat-nouns { --ink: #ffb65c; } .cat-pronouns { --ink: #aaa4ff; }
  .cat-sentence { --ink: #5fe0a8; } .cat-linking { --ink: #ff86b0; }
}

/* progress ring that works on any background (the track is masked, not painted over) */
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
.pring { --p: 0; --w: 5px; position: relative; display: grid; place-items: center; border-radius: 50%; flex: none; transition: --p 0.9s var(--ease); }
.pring::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring, var(--tint)) calc(var(--p) * 1%), var(--track, var(--fill)) 0);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - var(--w) - 1px), #000 calc(100% - var(--w)));
  mask: radial-gradient(closest-side, transparent calc(100% - var(--w) - 1px), #000 calc(100% - var(--w))); }
.pring > b { position: relative; font-variant-numeric: tabular-nums; }

/* the clear glass card at the top of Grammar and Vocab */
.learn-stage { padding: 12px; border-radius: 30px; margin-bottom: 16px; }
.g-grammar { background: linear-gradient(155deg, #4f7dff 0%, #7a5cff 48%, #c04bff 100%); }
.g-grammar .blob.b1 { background: #38d6ff; } .g-grammar .blob.b2 { background: #ff5fa2; } .g-grammar .blob.b3 { background: #ffd166; opacity: 0.45; }
.g-vocab { background: linear-gradient(155deg, #ff9a3d 0%, #ff5c7a 50%, #a24bff 100%); }
.g-vocab .blob.b1 { background: #ffd166; } .g-vocab .blob.b2 { background: #7a5cff; } .g-vocab .blob.b3 { background: #2fe0b0; opacity: 0.5; }
@media (prefers-color-scheme: dark) {
  .g-grammar { background: linear-gradient(155deg, #1c3a9a 0%, #3f2a9a 50%, #6b1f9a 100%); }
  .g-vocab { background: linear-gradient(155deg, #9a4a12 0%, #96233f 50%, #4b2a9a 100%); }
  .learn-stage .blob { opacity: 0.5; }
}
.learn-glass { padding: 16px 16px 14px; text-align: left; border-radius: 22px; }
.lg-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.lg-label { font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; }
.lg-level { font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 9px; background: rgba(255,255,255,0.22); border: 1px solid rgba(255,255,255,0.4); }
.lg-level:empty { display: none; }
.lg-main { display: flex; align-items: center; gap: 14px; }
.lg-ring { width: 74px; height: 74px; --w: 7px; --ring: #fff; --track: rgba(255,255,255,0.28); }
.lg-ring b { font-size: 17px; font-weight: 700; }
.lg-text { min-width: 0; }
.lg-text h2 { font-size: 24px; line-height: 1.15; letter-spacing: -0.2px; margin: 0 0 4px; color: #fff; overflow-wrap: anywhere; }
.lg-text p { font-size: 15px; line-height: 1.3; color: rgba(255,255,255,0.94); }
.lg-reason { font-size: 14px; font-weight: 500; line-height: 1.35; color: #fff; margin: 12px 2px 0; }
.lg-reason:empty { display: none; }
.lg-actions { display: flex; gap: 8px; margin-top: 14px; }
.glass-btn { min-height: 48px; padding: 0 16px; border-radius: 15px; font-size: 16px; font-weight: 600; color: #fff;
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.42); box-shadow: inset 0 1px 0 rgba(255,255,255,0.45);
  transition: transform 0.15s var(--ease), opacity 0.2s; white-space: nowrap; }
.glass-btn.primary { flex: 1; background: #fff; color: #3b2a8c; text-shadow: none; border-color: #fff; box-shadow: 0 6px 16px rgba(20,10,60,0.25); }
.glass-btn:active { transform: scale(0.97); }
.glass-btn:disabled { opacity: 0.55; }
.learn-glass .glass-pills { margin-top: 12px; }
.learn-glass .glass-pill { text-align: center; padding: 9px 4px; border-radius: 15px; }
.learn-glass .glass-pill b { font-size: 19px; }
.learn-glass .glass-pill span { font-size: 11px; }

/* level picker: a ring per level */
.level-path { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-bottom: 14px; }
.lvl { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 2px 8px; border-radius: 16px; min-width: 0;
  transition: background 0.25s var(--ease), box-shadow 0.25s, transform 0.15s; }
.lvl:active { transform: scale(0.95); }
.lvl.on { background: var(--card); box-shadow: var(--shadow); }
.lvl-ring { width: 44px; height: 44px; --w: 4px; }
.lvl-ring b { font-size: 14px; font-weight: 700; color: var(--label-2); }
.lvl.on .lvl-ring b { color: var(--label); }
.lvl.full .lvl-ring { --ring: var(--green); }
.lvl small { font-size: 11px; font-weight: 600; color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.quick { display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 11px 12px; border-radius: 16px; text-align: left;
  background: var(--card); box-shadow: var(--shadow); transition: transform 0.15s var(--ease), opacity 0.2s; min-width: 0; }
.quick:active:not(:disabled) { transform: scale(0.97); }
.quick:disabled { opacity: 0.5; cursor: default; }
.quick-icon { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; }
.quick-icon svg { width: 20px; height: 20px; stroke-width: 2.2; }
.quick-icon.mix { background: linear-gradient(135deg, #5e8bff, #8f6bff); }
.quick-icon.fix { background: linear-gradient(135deg, #ff9f43, #ff6b8b); }
.quick-main { min-width: 0; }
.quick-main b { display: block; font-size: 15px; font-weight: 600; }
.quick-main small { display: block; font-size: 12px; line-height: 1.25; color: var(--label-2); }

.topics-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.topics-head .section-title { margin: 0; }
.topics-meta { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }

.topic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.topic { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 12px 14px 12px 12px; text-align: left;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); border: 1.5px solid transparent;
  transition: transform 0.15s var(--ease); animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }
.topic:active { transform: scale(0.98); }
.topic.is-rec { border-color: color-mix(in srgb, var(--cat) 45%, transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.glyph { flex: none; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; padding: 0 3px; text-align: center;
  font-size: 15px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.05; overflow: hidden;
  color: var(--ink); background: color-mix(in srgb, var(--cat) 15%, transparent); }
.glyph.sm { font-size: 12px; letter-spacing: -0.4px; }
.glyph.big { width: 62px; height: 62px; border-radius: 18px; font-size: 17px; }
.glyph.big.sm { font-size: 14px; }
.topic-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.topic-title { font-size: 16px; font-weight: 600; line-height: 1.2; }
.topic-title em { font-style: normal; margin-left: 8px; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; vertical-align: 2px;
  white-space: nowrap; color: var(--ink); background: color-mix(in srgb, var(--cat) 15%, transparent); }
.topic-sub { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic .meter { height: 4px; margin-top: 5px; }
.topic .meter i { background: var(--cat); }
.topic-new { flex: none; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 7px; color: var(--label-2); background: var(--fill); }
.topic-pct { flex: none; min-width: 34px; text-align: right; font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.topic-check, .deck-check { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; }
.topic-check svg, .deck-check svg { width: 15px; height: 15px; stroke-width: 3; }
.cat-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin: 0 8px 14px; font-size: 12px; color: var(--label-2); }
.cat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cat-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--cat); }

/* lesson sheet */
.lesson-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.lesson-head b { display: block; font-size: 20px; line-height: 1.2; }
.lesson-head small { display: block; font-size: 14px; color: var(--label-2); margin-top: 2px; }
.lesson-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lesson-stats div { background: var(--card); border-radius: 14px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); }
.lesson-stats b { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lesson-stats b i { font-style: normal; font-size: 13px; font-weight: 600; color: var(--label-2); }
.lesson-stats span { font-size: 12px; color: var(--label-2); }
.lesson-points { margin: 0; padding: 14px 16px 14px 34px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.lesson-points li { font-size: 16px; line-height: 1.4; -webkit-user-select: text; user-select: text; }
.lesson-points li + li { margin-top: 8px; }
.lesson-points li::marker { color: var(--cat); }
.lesson-examples { display: flex; flex-direction: column; gap: 8px; }
.lesson-examples div { background: var(--card); border-radius: 14px; padding: 11px 14px; box-shadow: var(--shadow); border-left: 4px solid var(--cat); }
.lesson-examples b { display: block; font-size: 16px; font-weight: 600; line-height: 1.3; -webkit-user-select: text; user-select: text; }
.lesson-examples span { display: block; font-size: 14px; color: var(--label-2); margin-top: 2px; }
.len-seg button { flex: 1; min-height: 38px; }
.lesson-start { margin-top: 18px; width: 100%; }

/* quiz */
.quiz-top { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; min-height: 30px; }
.quiz-dots { flex: 1; display: flex; gap: 4px; }
.quiz-dots i { flex: 1; height: 6px; border-radius: 3px; background: var(--fill); transition: background 0.3s; }
.quiz-dots i.now { background: color-mix(in srgb, var(--tint) 45%, var(--fill)); }
.quiz-dots i.ok { background: var(--green); }
.quiz-dots i.no { background: var(--red); }
.quiz-streak { flex: none; font-size: 14px; font-weight: 700; padding: 3px 9px; border-radius: 12px; font-variant-numeric: tabular-nums;
  color: #b25a00; background: color-mix(in srgb, var(--orange) 18%, transparent); }
@media (prefers-color-scheme: dark) { .quiz-streak { color: #ffb65c; } }
.quiz-streak.bump { animation: pop 0.3s var(--spring); }
.quiz-stage { padding: 10px; border-radius: 26px; margin-bottom: 16px; background: linear-gradient(155deg, var(--g1, #5e8bff), var(--g2, #8f6bff)); box-shadow: var(--shadow); }
.quiz-stage .blob { opacity: 0.55; }
.quiz-stage .blob.b1 { width: 160px; height: 160px; top: -70px; left: -40px; background: rgba(255,255,255,0.55); }
.quiz-stage .blob.b2 { width: 180px; height: 180px; bottom: -100px; right: -50px; background: rgba(20,10,70,0.35); }
.quiz-glass { padding: 14px 16px 22px; text-align: left; border-radius: 19px; }
.quiz-topic { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 12px; }
.quiz-topic span:last-child { flex: none; font-variant-numeric: tabular-nums; }
.quiz-q { font-size: 22px; line-height: 1.42; font-weight: 600; color: #fff; overflow-wrap: anywhere; }
.quiz-q.long { font-size: 18px; }
.blank { display: inline-block; min-width: 64px; padding: 0 6px; border-bottom: 2.5px solid var(--tint); color: var(--tint); text-align: center; line-height: 1.25; }
.blank.filled { border-radius: 6px 6px 0 0; font-weight: 700; background: color-mix(in srgb, var(--tint) 10%, transparent); }
.quiz-q .blank { border-bottom-color: rgba(255,255,255,0.95); color: #fff; }
.quiz-q .blank.filled { border-radius: 8px; border-bottom-color: transparent; background: rgba(255,255,255,0.95); color: #33247f; text-shadow: none; padding: 0 9px; }
.quiz-q.pop .blank.filled { animation: popIn 0.4s var(--spring) both; }

.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: left;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); border: 2px solid transparent;
  font-size: 17px; line-height: 1.3; transition: transform 0.15s var(--ease), opacity 0.2s, border-color 0.2s, background 0.2s;
  animation: rise 0.3s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.opt:active:not(:disabled) { transform: scale(0.98); }
.opt:disabled { cursor: default; color: var(--label); }
.opt-key { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--fill);
  font-size: 13px; font-weight: 700; color: var(--label-2); transition: background 0.2s, color 0.2s; }
.opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt.right { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--card)); }
.opt.right .opt-key { background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--card)); animation: shake 0.35s; }
.opt.wrong .opt-key { background: var(--red); color: #fff; }
.opt.dim { opacity: 0.45; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.quiz-feedback { margin: 16px 0 0; padding: 14px 16px; border-radius: 16px; animation: viewIn 0.25s var(--ease); }
.quiz-feedback b { display: block; font-size: 17px; margin-bottom: 4px; }
.quiz-feedback p { font-size: 15px; color: var(--label); }
.quiz-feedback.good { background: color-mix(in srgb, var(--green) 13%, transparent); }
.quiz-feedback.good b { color: #1a8f3c; }
.quiz-feedback.bad { background: color-mix(in srgb, var(--red) 10%, transparent); }
.quiz-feedback.bad b { color: #d92d20; }
@media (prefers-color-scheme: dark) { .quiz-feedback.good b { color: var(--green); } .quiz-feedback.bad b { color: var(--red); } }
.feedback-link { margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--tint); padding: 4px 0; }
.quiz-next { margin-top: 18px; width: 100%; scroll-margin-bottom: calc(var(--tabbar-h) + 16px); }

/* results */
.gram-done-card { text-align: center; overflow: visible; }
.score-row { display: flex; align-items: center; gap: 16px; text-align: left; margin: 2px 2px 20px; }
.score-ring { width: 88px; height: 88px; --w: 8px; --ring: var(--orange); }
.score-ring.great { --ring: var(--green); }
.score-ring b { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.score-ring b i { font-style: normal; font-size: 15px; font-weight: 600; color: var(--label-2); letter-spacing: 0; }
.score-text { min-width: 0; }
.score-text h2 { margin: 0 0 4px; }
.score-text p { font-size: 15px; line-height: 1.35; }
.gram-done-card .btn { width: 100%; }
.gram-done-card .btn-secondary { margin-top: 10px; }
.gram-done-card .btn-link { margin-top: 8px; }
#gram-next-topic { white-space: normal; line-height: 1.25; padding: 8px 16px; min-height: 48px; }
#gram-missed { margin-top: 26px; }
.row.missed { align-items: flex-start; padding: 13px 16px; }
.missed-q { font-size: 16px; line-height: 1.5; font-weight: 500; -webkit-user-select: text; user-select: text; }
.missed-q .blank { min-width: 0; }
.missed-ans { display: block; margin-top: 4px; font-weight: 700; color: var(--tint); }
.missed-why { font-size: 14px; line-height: 1.35; color: var(--label-2); }
.missed-topic { font-size: 12px; font-weight: 600; color: var(--label-3); text-transform: uppercase; letter-spacing: 0.3px; }
.confetti { position: absolute; inset: -110px 0 0; overflow: hidden; pointer-events: none; border-radius: var(--radius); }
.confetti i { position: absolute; top: -12px; left: var(--x); width: 8px; height: 12px; border-radius: 2px; opacity: 0;
  animation: confetti 1.8s var(--d) cubic-bezier(0.2, 0.6, 0.4, 1) forwards; }
@keyframes confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--dx), 340px) rotate(calc(var(--r) + 540deg)); } }

/* vocab decks */
.deck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.deck { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; min-height: 132px; padding: 14px 14px 13px;
  text-align: left; background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  transition: transform 0.15s var(--ease); animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }
.deck:active { transform: scale(0.97); }
.deck-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; line-height: 1; margin-bottom: 8px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--orange) 16%, transparent), color-mix(in srgb, var(--indigo) 14%, transparent)); }
.deck-icon.big { flex: none; width: 62px; height: 62px; border-radius: 18px; font-size: 34px; margin: 0; }
.deck b { font-size: 15px; font-weight: 600; line-height: 1.2; }
.deck small { font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.deck .meter { width: 100%; height: 4px; margin-top: auto; }
.deck.full .meter i { background: var(--green); }
.deck-check { position: absolute; top: 12px; right: 12px; }
.deck-sheet .btn { width: 100%; }
.deck-sheet .btn + .btn { margin-top: 10px; }
.word-list { margin-top: 18px; }
.word-row { align-items: flex-start; padding: 12px 10px 12px 16px; }
.word-row .row-sub { white-space: normal; }
.word-ex { font-size: 14px; line-height: 1.3; color: var(--label-2); font-style: italic; }
.word-add { flex: none; width: 36px; height: 36px; margin-top: 2px; border-radius: 50%; display: grid; place-items: center;
  color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, transparent); transition: transform 0.15s var(--ease); }
.word-add:active:not(:disabled) { transform: scale(0.9); }
.word-add svg { width: 18px; height: 18px; stroke-width: 2.6; }
.word-add:disabled { color: #fff; background: var(--green); cursor: default; }

/* Library shortcut to the starter decks */
.starter { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; margin-bottom: 16px; text-align: left; color: #fff;
  border-radius: 18px; background: linear-gradient(135deg, #ff9a3d 0%, #ff5c7a 55%, #a24bff 100%); box-shadow: var(--shadow);
  transition: transform 0.15s var(--ease); }
.starter:active { transform: scale(0.98); }
.starter-art { flex: none; position: relative; width: 58px; height: 44px; }
.starter-art i { position: absolute; left: 12px; top: 6px; width: 38px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-style: normal; font-size: 12px; font-weight: 800; color: #5b3fd6; background: rgba(255,255,255,0.96); box-shadow: 0 3px 8px rgba(20,10,60,0.2); }
.starter-art i:nth-child(1) { transform: rotate(-14deg) translate(-9px, 2px); opacity: 0.75; }
.starter-art i:nth-child(2) { transform: rotate(9deg) translate(9px, 1px); opacity: 0.85; }
.starter-main { flex: 1; min-width: 0; }
.starter-main b { display: block; font-size: 17px; font-weight: 700; }
.starter-main small { display: block; font-size: 13px; opacity: 0.95; }
.starter .chev { color: rgba(255,255,255,0.85); }
body.selecting .starter { display: none; }

@media (max-width: 374px) {
  .learn-stage { padding: 10px; }
  .lg-ring { width: 62px; height: 62px; --w: 6px; }
  .lg-ring b { font-size: 15px; }
  .lg-text h2 { font-size: 21px; }
  .lvl-ring { width: 38px; height: 38px; }
  .lvl small { font-size: 10px; }
  .quick-main small { display: none; }
  .glyph { width: 46px; height: 46px; border-radius: 14px; font-size: 13px; }
  .glyph.sm { font-size: 11px; }
  .quiz-q { font-size: 20px; }
  .quiz-q.long { font-size: 17px; }
  .opt { font-size: 16px; min-height: 52px; padding: 10px 12px; }
  .score-ring { width: 76px; height: 76px; }
  .score-ring b { font-size: 24px; }
  .deck { min-height: 124px; padding: 12px; }
}
@media (max-width: 300px) {
  .deck-grid, .quick-row { grid-template-columns: 1fr; }
  .lg-actions { flex-direction: column; }
  .quiz-q { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .topic, .deck, .opt { animation: none; }
  .pring { transition: none; }
}
