/* Flashcards
   System type and controls; the one signature is the flashcard itself, drawn as a
   ruled index card (red header rule, blue lines, text sitting on the lines). */

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light dark;
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #F7F7FA;
  --sheet-bg: #F2F2F7;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --label: #111114;
  --label-2: #5B5B62;       /* 6.0:1 on --bg, 6.7:1 on --surface */
  --label-3: #6E6E76;       /* 5.1:1 on --surface; placeholders and hints */
  --sep: rgba(60, 60, 67, 0.16);
  --sep-strong: rgba(60, 60, 67, 0.3);

  --accent: #1C62CC;        /* 5.7:1 on white */
  --accent-bg: #1C62CC;     /* white text on it: 5.7:1 */
  --accent-soft: #E8F0FC;   /* accent text on it: 5.0:1 */
  --on-accent: #FFFFFF;
  --red: #C21F2C;
  --red-soft: #FBE9EA;
  --orange: #A84A00;
  --orange-soft: #FBEEE3;
  --green: #1B7A36;
  --green-soft: #E6F4EA;
  --yellow: #B98900;
  --switch-on: #248A3D;

  /* the index card */
  --card: #FFFFFF;
  --card-ink: #1B1B1F;
  --card-edge: rgba(0, 0, 0, 0.06);
  --card-rule: rgba(28, 98, 204, 0.16);
  --card-margin: rgba(214, 51, 72, 0.55);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 30px -12px rgba(16, 24, 40, 0.18);
  --rule: 2rem;             /* one ruled line */
  --head: 3.5rem;           /* header area above the red rule */

  /* charts (validated: ordinal blue ramp, light) */
  --viz-0: rgba(118, 118, 128, 0.14);
  --viz-1: #B7D3F6;
  --viz-2: #6DA7EC;
  --viz-3: #2A78D6;
  --viz-4: #184F95;
  --viz-new: #86B6EF;
  --viz-learning: #3987E5;
  --viz-mastered: #1C5CAB;
  --viz-bar: #2A78D6;

  --focus: #1C62CC;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --tabbar-h: 3.25rem;
  --sidebar-w: 15rem;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1C1C1E;
    --surface-2: #232326;
    --sheet-bg: #1C1C1E;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.36);
    --label: #F2F2F5;
    --label-2: #A3A3AB;     /* 6.8:1 on --surface */
    --label-3: #9A9AA2;
    --sep: rgba(84, 84, 88, 0.6);
    --sep-strong: rgba(120, 120, 128, 0.6);

    --accent: #6AA8FF;      /* 7.0:1 on --surface */
    --accent-bg: #2A6FDB;   /* white text on it: 4.8:1 */
    --accent-soft: #1B2A42;
    --red: #FF7A7A;
    --red-soft: #3A1F21;
    --orange: #FFB15C;
    --orange-soft: #3A2A1A;
    --green: #5CD67E;
    --green-soft: #1D3324;
    --yellow: #FFD15C;
    --switch-on: #30A84E;

    --card: #1F1F23;
    --card-ink: #F2F2F5;
    --card-edge: rgba(255, 255, 255, 0.07);
    --card-rule: rgba(106, 168, 255, 0.14);
    --card-margin: rgba(255, 122, 138, 0.5);
    --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 30px -14px rgba(0, 0, 0, 0.8);

    --viz-0: rgba(118, 118, 128, 0.22);
    --viz-1: #184F95;
    --viz-2: #256ABF;
    --viz-3: #3987E5;
    --viz-4: #86B6EF;
    --viz-new: #184F95;
    --viz-learning: #3987E5;
    --viz-mastered: #86B6EF;
    --viz-bar: #3987E5;

    --focus: #6AA8FF;
    --shadow: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --label-2: #3A3A40;
    --sep: rgba(60, 60, 67, 0.4);
    --card-rule: rgba(28, 98, 204, 0.32);
  }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root {
    --label-2: #C8C8D0;
    --sep: rgba(160, 160, 168, 0.6);
    --card-rule: rgba(106, 168, 255, 0.3);
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

/* Safari: follow the system text size (Dynamic Type). */
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

html.has-sheet, html.is-practicing { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
img { display: block; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.icon { display: inline-flex; flex: none; line-height: 0; }
.icon--filled svg { fill: currentColor; }

.noscript { padding: 2rem; text-align: center; }
.boot-splash { min-height: 100vh; }

.kbd {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.35rem;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0.7;
}
@media (hover: none) and (pointer: coarse) { .kbd { display: none; } }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; }
.btn--primary { background: var(--accent-bg); color: var(--on-accent); }
.btn--secondary { background: var(--accent-soft); color: var(--accent); }
.btn--plain { background: transparent; color: var(--accent); }
.btn--destructive { background: var(--red); color: #fff; }
@media (prefers-color-scheme: dark) { .btn--destructive { background: #D9353F; } }
.btn--large { min-height: 52px; border-radius: var(--radius); font-size: 1.0625rem; }
.btn--block { width: 100%; }
@media (hover: hover) {
  .btn--primary:hover:not(:disabled) { filter: brightness(1.08); }
  .btn--secondary:hover:not(:disabled), .btn--plain:hover:not(:disabled) { background: var(--fill); }
}

.bar-btn {
  min-height: 44px;
  padding: 0 0.5rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
  white-space: nowrap;
}
.bar-btn--prominent { font-weight: 600; }
.bar-btn--destructive { color: var(--red); }
.bar-btn:disabled { opacity: 0.35; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--accent);
}
.icon-btn:disabled { opacity: 0.3; }
.icon-btn--tinted { background: var(--accent-soft); width: 40px; height: 40px; margin: 2px; }
.icon-btn--destructive { color: var(--red); }
@media (hover: hover) { .icon-btn:hover:not(:disabled) { background: var(--fill); } }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.9375rem;
}

/* ---------------------------------------------------------------- shell */
.shell__main {
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.view {
  max-width: 44rem;
  margin: 0 auto;
  outline: none;
}

.tabbar {
  position: fixed;
  z-index: 20;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 4px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tabbar__brand { display: none; }
.tab {
  flex: 1;
  max-width: 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--label-2);
  text-decoration: none;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 10px;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { fill: color-mix(in srgb, currentColor 18%, transparent); }

@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

html.is-selecting .tabbar { display: none; }

@media (min-width: 900px) {
  .tabbar {
    top: 0; bottom: 0; right: auto;
    width: var(--sidebar-w);
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 20px 12px;
    border-top: 0;
    border-right: 0.5px solid var(--sep);
    background: var(--surface-2);
  }
  @media (prefers-color-scheme: dark) { .tabbar { background: #121214; } }
  .tabbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 18px;
    font-weight: 700;
    font-size: 1.0625rem;
  }
  .tabbar__brand img { border-radius: 7px; }
  .tab {
    flex: none;
    max-width: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.9375rem;
    color: var(--label);
  }
  .tab .icon { color: var(--accent); }
  .tab[aria-current="page"] { background: var(--fill-strong); color: var(--label); font-weight: 600; }
  .tab:hover:not([aria-current="page"]) { background: var(--fill); }
  .shell__main { margin-left: var(--sidebar-w); padding: 0 40px 64px; }
  html.is-selecting .tabbar { display: flex; }
}

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 -16px;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
}

/* ---------------------------------------------------------------- page */
.page { padding-top: calc(12px + env(safe-area-inset-top)); }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 14px;
}
.page-title { font-size: 2.125rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.page-subtitle { margin-top: 2px; color: var(--label-2); font-size: 0.9375rem; }
.page-header__actions { display: flex; align-items: center; gap: 4px; margin-right: -6px; }

.panel {
  margin: 0 0 16px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel__title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.panel__text { margin-top: 4px; color: var(--label-2); font-size: 0.9375rem; }

.stack-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 16px; width: 100%; }

/* ---------------------------------------------------------------- grouped lists */
.group { margin: 0 0 24px; }
.group__header { padding: 0 16px 6px; color: var(--label-2); font-size: 0.8125rem; font-weight: 600; }
.group__footer { padding: 6px 16px 0; color: var(--label-2); font-size: 0.8125rem; line-height: 1.4; }
.group__list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.group__row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 16px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 1rem;
}
.group__row + .group__row::before, .group__list > * + *::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 16px;
  border-top: 0.5px solid var(--sep);
}
.group__row--button { color: var(--label); }
.group__row--button:active { background: var(--fill); }
@media (hover: hover) { .group__row--button:hover { background: var(--fill); } }
.group__row--destructive .group__label { color: var(--red); }
.group__row > .icon:last-child { color: var(--label-3); }
.group__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: #fff;
}
.tint-blue { background: #1C62CC; }
.tint-red { background: #D12F3A; }
.tint-orange { background: #C2570C; }
.tint-yellow { background: #B07D00; }
.tint-green { background: #1F8A3E; }
.tint-gray { background: #6B6B73; }
.group__label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.group__sublabel {
  color: var(--label-2);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group__detail { color: var(--label-2); font-variant-numeric: tabular-nums; text-align: right; }
.group__prose { padding: 14px 16px; display: grid; gap: 10px; font-size: 0.9375rem; color: var(--label-2); }
.group__prose strong { color: var(--label); }

/* ---------------------------------------------------------------- controls */
.segmented {
  display: flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
}
.segmented__input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__label {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--label);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.segmented__input:checked + .segmented__label {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) { .segmented__input:checked + .segmented__label { background: #5A5A5F; } }
.segmented__input:focus-visible + .segmented__label { outline: 3px solid var(--focus); outline-offset: 1px; }
.segmented--compact .segmented__label { min-height: 32px; padding: 0 12px; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px; height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--fill-strong);
  cursor: pointer;
  transition: background-color 0.2s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--switch-on); }
.switch:checked::before { transform: translateX(20px); }

.stepper { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fill); }
.stepper__btn {
  width: 40px; height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--label);
}
.stepper__btn:disabled { opacity: 0.3; }
.stepper__btn:active:not(:disabled) { background: var(--fill-strong); }
.stepper__value { min-width: 2.6rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.pulldown {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.group .pulldown { background: var(--fill); box-shadow: none; }
.pulldown__select {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
}
.pulldown:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.date-wrap { display: inline-flex; align-items: center; gap: 4px; }
.date-input {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  color: var(--accent);
  font-size: 0.9375rem;
}

.chips { display: flex; gap: 8px; }
.chips--scroll {
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 2px 16px;
  scroll-padding: 0 16px;
}
.chips--scroll::-webkit-scrollbar { display: none; }
.chips--static { flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--label);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.editor .chip, .detail .chip { background: var(--surface); }
.chip[aria-checked="true"], .chip[aria-selected="true"] { background: var(--accent-bg); color: var(--on-accent); }
.chip__count { font-variant-numeric: tabular-nums; opacity: 0.75; font-size: 0.8125rem; }
.chip--small { min-height: 28px; padding: 0 10px; font-size: 0.8125rem; background: var(--fill); box-shadow: none; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill--new { background: var(--accent-soft); color: var(--accent); }
.pill--learning { background: var(--orange-soft); color: var(--orange); }
.pill--mastered { background: var(--green-soft); color: var(--green); }

/* ---------------------------------------------------------------- forms */
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field__label { font-size: 0.9375rem; font-weight: 600; }
.field__optional { color: var(--label-3); font-weight: 400; font-size: 0.8125rem; }
.field__wrap { position: relative; }
.field__input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--sep-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1rem; /* never below 16px, so iOS doesn't zoom */
  line-height: 1.35;
}
textarea.field__input { min-height: 4.6rem; resize: vertical; }
.field__input::placeholder { color: var(--label-3); opacity: 0.85; }
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field__input--word { font-family: var(--serif); font-size: 1.375rem; font-weight: 700; }
.field__wrap .field__input { padding-right: 52px; }
.field__reveal {
  position: absolute;
  top: 50%; right: 2px;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--label-2);
}
.field__hint { color: var(--label-2); font-size: 0.8125rem; }
.field__hint.is-error { color: var(--red); }
.field__hint--warn { color: var(--orange); font-weight: 500; }
.form-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.9375rem;
}
.check-row { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 0.9375rem; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent-bg); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-input:focus-visible + * { outline: 3px solid var(--focus); }

/* ---------------------------------------------------------------- auth */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%;
  max-width: 25rem;
  padding: 32px 24px 24px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 20px 50px -24px rgba(16, 24, 40, 0.25);
}
.auth-logo { margin: 0 auto 14px; border-radius: 15px; }
.auth-title { text-align: center; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-lede { margin: 6px auto 24px; max-width: 30ch; text-align: center; color: var(--label-2); font-size: 0.9375rem; }
.auth-notice { margin: -8px 0 18px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 0.9375rem; }
.auth-reveal {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.28s var(--ease), visibility 0.28s;
}
.auth-reveal.is-open { grid-template-rows: 1fr; visibility: visible; }
.auth-reveal__inner { overflow: hidden; min-height: 0; }
.auth-status { min-height: 1.4em; margin: -8px 0 12px; color: var(--label-2); font-size: 0.875rem; }
.auth-status:empty { min-height: 0; margin: 0; }
.auth-foot { margin-top: 16px; color: var(--label-2); font-size: 0.8125rem; text-align: center; }
.auth .field__input { background: var(--surface-2); }
@media (prefers-color-scheme: dark) {
  .auth-card { background: var(--surface); }
  .auth .field__input { background: #2C2C2E; }
}

/* ---------------------------------------------------------------- sheets */
dialog { padding: 0; border: 0; color: inherit; }
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: none;
  max-height: 94vh;
  max-height: 94dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--sheet-bg);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
}
.sheet[open] { display: flex; }
.sheet.is-open { transform: translateY(0); }
.sheet.is-closing { transform: translateY(100%); transition-duration: 0.2s; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.35); }
.sheet__header { flex: none; padding-top: 6px; touch-action: none; }
.sheet__grabber { width: 36px; height: 5px; margin: 0 auto 2px; border-radius: 3px; background: var(--fill-strong); }
.sheet__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 48px;
  padding: 0 8px;
}
.sheet__lead { justify-self: start; }
.sheet__trail { justify-self: end; }
.sheet__title { font-size: 1.0625rem; font-weight: 600; text-align: center; }
.sheet__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet .group__list { background: var(--surface); }
@media (prefers-color-scheme: dark) {
  .sheet .field__input, .sheet .group__list { background: #2C2C2E; }
  .sheet .chip { background: #2C2C2E; }
  .sheet .chip[aria-checked="true"] { background: var(--accent-bg); }
}

@media (min-width: 700px) {
  .sheet {
    inset: 50% auto auto 50%;
    width: min(36rem, 92vw);
    max-height: 86vh;
    border-radius: 16px;
    transform: translate(-50%, -48%) scale(0.98);
    opacity: 0;
    transition: transform 0.22s var(--ease), opacity 0.22s;
  }
  .sheet.is-open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.is-closing { transform: translate(-50%, -48%) scale(0.98); opacity: 0; }
  .sheet__grabber { display: none; }
  .sheet__body { padding: 8px 24px 28px; }
}

/* alert / action sheet */
.alert {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
  background: transparent;
  overflow: visible;
  transform: translateY(110%);
  transition: transform 0.25s var(--ease);
}
.alert.is-open { transform: none; }
.alert::backdrop { background: rgba(0, 0, 0, 0.4); }
.alert__card { background: var(--surface); border-radius: 14px; overflow: hidden; }
@media (prefers-color-scheme: dark) { .alert__card { background: #2C2C2E; } }
.alert__card--cancel { margin-top: 8px; }
.alert__text { padding: 16px 20px 14px; text-align: center; }
.alert__title { font-size: 1.0625rem; font-weight: 600; }
.alert__msg { margin-top: 4px; color: var(--label-2); font-size: 0.875rem; }
.alert__actions { border-top: 0.5px solid var(--sep); }
.alert__btn {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 0;
  background: none;
  font-size: 1.125rem;
  color: var(--accent);
}
.alert__btn--destructive { color: var(--red); }
.alert__btn--cancel { font-weight: 600; }
.alert__btn:active { background: var(--fill); }
@media (min-width: 700px) {
  .alert {
    inset: 50% auto auto 50%;
    width: 20rem;
    padding: 0;
    transform: translate(-50%, -50%) scale(1.06);
    opacity: 0;
    transition: transform 0.18s var(--ease), opacity 0.18s;
  }
  .alert.is-open { transform: translate(-50%, -50%); opacity: 1; }
  .alert__card { border-radius: 14px 14px 0 0; }
  .alert__card--cancel { margin-top: 0; border-radius: 0 0 14px 14px; border-top: 0.5px solid var(--sep); }
  .alert__btn { min-height: 46px; font-size: 1rem; }
  @media (hover: hover) { .alert__btn:hover { background: var(--fill); } }
}

/* ---------------------------------------------------------------- toast */
.toast-host {
  position: fixed;
  z-index: 100;
  inset: auto 0 auto 0;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  color: inherit;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}
html.is-practicing .toast-host, html.is-selecting .toast-host { bottom: calc(env(safe-area-inset-bottom) + 96px); }
@media (min-width: 900px) { .toast-host { bottom: 24px; left: var(--sidebar-w); } }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 30rem;
  min-height: 48px;
  padding: 8px 8px 8px 18px;
  border-radius: 14px;
  background: rgba(32, 32, 36, 0.96);
  color: #fff;
  font-size: 0.9375rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.25s var(--ease), opacity 0.25s;
}
.toast.is-in { transform: none; opacity: 1; }
.toast__msg { flex: 1; padding: 6px 0; }
.toast--error { background: #8E1620; }
.toast__action {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 600;
}
.toast:not(:has(.toast__action)) { padding-right: 18px; }

/* ---------------------------------------------------------------- empty */
.empty { display: grid; justify-items: center; gap: 8px; padding: 40px 16px; text-align: center; }
.empty__icon { color: var(--label-3); margin-bottom: 4px; }
.empty__title { font-size: 1.25rem; font-weight: 700; }
.empty__msg { max-width: 34ch; color: var(--label-2); font-size: 0.9375rem; }
.empty .btn, .empty .stack-actions { margin-top: 12px; }

/* ---------------------------------------------------------------- today */
.today-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--label);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.meta-chip .icon { color: var(--orange); }
.meta-chip--quiet { color: var(--accent); }
.meta-chip--quiet .icon { color: inherit; }

.study .panel__title { margin-bottom: 14px; }
.due-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.due { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
@media (prefers-color-scheme: dark) { .due { background: #2C2C2E; } }
.due__n { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.due__label { color: var(--label-2); font-size: 0.8125rem; font-weight: 500; }
.due--again .due__n { color: var(--red); }
.due--review .due__n { color: var(--green); }
.due--new .due__n { color: var(--accent); }
.mode-pick { margin-bottom: 8px; }
.mode-help { min-height: 2.6em; margin-bottom: 12px; color: var(--label-2); font-size: 0.8125rem; }
.study__meta { margin-top: 10px; text-align: center; color: var(--label-2); font-size: 0.8125rem; }
.study--done { text-align: center; display: grid; justify-items: center; }
.study--done .panel__text { max-width: 36ch; margin-bottom: 4px; }
.study__done-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
}

.goal { display: flex; align-items: center; gap: 16px; }
.ring { flex: none; line-height: 0; }
.ring circle:last-child { transition: stroke-dasharray 0.6s var(--ease); }
.goal__title { font-weight: 600; }
.goal__detail { color: var(--label-2); font-size: 0.9375rem; }

/* ---------------------------------------------------------------- words */
.sticky-tools {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -16px;
  padding: 8px 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
@media (prefers-reduced-transparency: reduce) { .sticky-tools { background: var(--bg); } }
@media (min-width: 900px) { .sticky-tools { margin: 0 -8px; padding: 8px 8px 10px; } }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--fill);
  color: var(--label-2);
}
.search__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: 1rem;
  color: var(--label);
}
.search__input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.search__input::placeholder { color: var(--label-2); }
.filter-bar { margin-top: 10px; }
.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.list-tools .link-btn { margin-left: auto; }

.word-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.word-list:has(.empty) { background: none; box-shadow: none; }
.word-row-wrap { position: relative; display: flex; align-items: stretch; }
.word-row-wrap + .word-row-wrap::before {
  content: "";
  position: absolute;
  top: 0; right: 0; left: 16px;
  border-top: 0.5px solid var(--sep);
}
.word-row {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 4px 10px 16px;
  border: 0;
  background: none;
  text-align: left;
}
.word-row:active, .word-row.is-selected { background: var(--fill); }
@media (hover: hover) { .word-row:hover { background: var(--fill); } }
.row-check { color: var(--label-3); }
.row-check.is-on { color: var(--accent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.row-word { font-weight: 600; font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-pos { color: var(--label-2); font-family: var(--serif); font-style: italic; font-size: 0.875rem; }
.row-sub { color: var(--label-2); font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.row-missed { color: var(--red); font-size: 0.75rem; font-weight: 600; }
.row-days { color: var(--label-2); font-size: 0.8125rem; }
.star-btn {
  flex: none;
  width: 44px;
  border: 0;
  background: none;
  color: var(--label-3);
  display: grid;
  place-items: center;
}
.star-btn.is-on { color: var(--yellow); }
.list-more { display: flex; justify-content: center; padding: 14px 0; }

.select-bar {
  position: fixed;
  z-index: 25;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px max(10px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--sep);
}
.select-bar__count { flex: 1; text-align: center; font-size: 0.875rem; font-weight: 600; color: var(--label-2); }
@media (min-width: 900px) { .select-bar { left: var(--sidebar-w); } }

/* ---------------------------------------------------------------- detail */
.detail .index-card { margin-bottom: 14px; }
.detail__notes { margin: 0 4px 12px; color: var(--label-2); font-size: 0.9375rem; white-space: pre-line; }
.detail__tags { margin: 0 0 18px; }
.detail .group__header { padding-left: 16px; }

/* ---------------------------------------------------------------- index card */
.index-card {
  position: relative;
  padding: 0 22px 22px;
  border-radius: 16px;
  background: var(--card);
  color: var(--card-ink);
  border: 1px solid var(--card-edge);
  box-shadow: var(--card-shadow);
}
/* The ruled side: a red header rule and blue lines every --rule, with text set on the lines. */
.index-card--ruled {
  background:
    linear-gradient(var(--card-margin), var(--card-margin)) 0 calc(var(--head) - 2px) / 100% 1.5px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--rule) - 1px), var(--card-rule) calc(var(--rule) - 1px) var(--rule)) 0 calc(var(--head) + 0.3rem) / 100% 100% no-repeat,
    var(--card);
  background-clip: padding-box;
}
.index-card--static { box-shadow: var(--card-shadow); }
.index-card--compact { margin-top: 12px; }

.ruled { line-height: var(--rule); }
.ruled__head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--head);
  margin-bottom: 0.3rem;
  padding-top: 4px;
}
.ruled__word { font-family: var(--serif); font-weight: 700; font-size: 1.375rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ruled__pos { font-family: var(--serif); font-style: italic; color: var(--label-2); font-size: 0.9375rem; }
.ruled__head .icon-btn--speak { margin-left: auto; margin-right: -10px; }
.ruled__q { color: var(--label-2); font-size: 0.875rem; font-weight: 600; letter-spacing: 0.02em; }
.ruled p { margin: 0; }
.ruled__az { font-size: 1.25rem; font-weight: 600; }
.ruled__en { font-size: 1rem; }
.ruled__syn, .ruled__ex { font-size: 1rem; color: var(--label-2); }
.ruled__ex { font-family: var(--serif); font-style: italic; }
.ruled__label { color: var(--label-2); font-family: var(--font); font-style: normal; font-size: 0.8125rem; font-weight: 600; }
.ruled mark {
  background: none;
  color: var(--card-ink);
  font-weight: 700;
  text-decoration: underline 2px var(--card-margin);
  text-underline-offset: 3px;
}
.blank { color: var(--accent); font-style: normal; letter-spacing: 0.08em; font-weight: 600; }

/* ---------------------------------------------------------------- practice */
.practice {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.practice__bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 6px 8px;
}
.practice__bar .icon-btn { color: var(--label-2); }
.practice__mid { display: grid; gap: 6px; justify-items: center; }
.practice__count { font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--label-2); }
.practice__progress { width: 100%; height: 4px; border-radius: 2px; background: var(--fill-strong); overflow: hidden; }
.practice__progress-fill { height: 100%; width: 0; border-radius: 2px; background: var(--accent-bg); transition: width 0.3s var(--ease); }
.practice__main { overflow-y: auto; overscroll-behavior: contain; }
.practice__stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 8px 16px 16px;
}
.practice__foot {
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
}

/* flip card */
.flip {
  position: relative;
  perspective: 1600px;
  cursor: pointer;
  touch-action: pan-y;
  transition: transform 0.3s var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.flip:focus-visible { outline: none; }
.flip:focus-visible .flip__inner { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 18px; }
.flip__inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease);
}
.flip__face {
  grid-area: 1 / 1;
  min-height: clamp(16rem, 46vh, 26rem);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.flip__back { transform: rotateY(180deg); }
.flip.is-flipped .flip__inner { transform: rotateY(180deg); }
.flip__front:not(.index-card--ruled) { display: grid; place-items: center; padding-top: 22px; }
.flip__hint {
  position: absolute;
  left: 0; right: 0; bottom: 12px;
  text-align: center;
  color: var(--label-3);
  font-size: 0.8125rem;
}
.flip__front.index-card--ruled { padding-bottom: 44px; }

.card-front { display: grid; justify-items: center; gap: 4px; padding: 24px 8px; text-align: center; }
.card-front__word {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.25rem, 9vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.card-front__pos { font-family: var(--serif); font-style: italic; color: var(--label-2); font-size: 1.0625rem; }
.card-front__speak { margin-top: 6px; }

.swipe-tag {
  position: absolute;
  top: 18px;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9375rem;
  opacity: 0;
  pointer-events: none;
}
.swipe-tag--left { right: 18px; background: var(--red-soft); color: var(--red); }
.swipe-tag--right { left: 18px; background: var(--green-soft); color: var(--green); }

@media (prefers-reduced-motion: reduce) {
  .flip__inner { transition: none; transform: none !important; }
  .flip__back { transform: none; opacity: 0; visibility: hidden; transition: opacity 0.2s; }
  .flip__front { transition: opacity 0.2s; }
  .flip.is-flipped .flip__front { opacity: 0; visibility: hidden; }
  .flip.is-flipped .flip__back { opacity: 1; visibility: visible; }
  .sheet, .alert, .toast, .auth-reveal, .practice__progress-fill { transition: none !important; }
}

/* rating buttons */
.ratings { display: grid; gap: 8px; }
.ratings--4 { grid-template-columns: repeat(4, 1fr); }
.ratings--2 { grid-template-columns: repeat(2, 1fr); }
.rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 62px;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  transition: transform 0.1s, filter 0.15s;
}
.rate:active { transform: scale(0.97); }
.rate__when { font-size: 0.8125rem; font-weight: 500; opacity: 0.9; font-variant-numeric: tabular-nums; }
.rate .kbd { margin: 2px 0 0; }
.rate--1 { background: var(--red-soft); color: var(--red); }
.rate--2 { background: var(--orange-soft); color: var(--orange); }
.rate--3 { background: var(--green-soft); color: var(--green); }
.rate--4 { background: var(--accent-soft); color: var(--accent); }
@media (hover: hover) { .rate:hover { filter: brightness(0.97); } }
@media (hover: hover) and (prefers-color-scheme: dark) { .rate:hover { filter: brightness(1.2); } }

/* quiz */
.quiz-card { margin-bottom: 14px; }
.quiz-card .card-front { padding: 28px 8px 22px; }
.quiz-card.index-card--ruled { padding-bottom: 14px; }
.quiz-q { margin: 2px 4px 10px; color: var(--label-2); font-size: 0.875rem; font-weight: 600; }
.quiz-options { display: grid; gap: 8px; }
.quiz-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 44px 10px 12px;
  border: 1.5px solid var(--sep);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  font-size: 1rem;
  line-height: 1.3;
  transition: border-color 0.15s, background-color 0.15s;
}
@media (hover: hover) { .quiz-option:hover:not(:disabled) { border-color: var(--accent); } }
.quiz-option:disabled { opacity: 1; color: var(--label); }
.quiz-option__key {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  font-size: 0.8125rem;
  font-weight: 700;
}
.quiz-option.is-right { border-color: var(--green); background: var(--green-soft); }
.quiz-option.is-wrong { border-color: var(--red); background: var(--red-soft); }
.quiz-option.is-right::after, .quiz-option.is-wrong::after {
  position: absolute;
  right: 14px;
  font-weight: 700;
  font-size: 1.125rem;
}
.quiz-option.is-right::after { content: "✓"; color: var(--green); }
.quiz-option.is-wrong::after { content: "✕"; color: var(--red); }
.quiz-option:disabled:not(.is-right):not(.is-wrong) { opacity: 0.55; }
.quiz-reveal { margin-top: 12px; }

/* typing */
.type-hint {
  min-height: 1.6em;
  margin: 12px 0 4px;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.125rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.type-form { margin: 4px 0 0; }
.type-input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border: 2px solid var(--sep-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}
.type-input:focus { outline: none; border-color: var(--accent); }
.type-input.is-correct { border-color: var(--green); background: var(--green-soft); }
.type-input.is-close { border-color: var(--orange); background: var(--orange-soft); }
.type-input.is-wrong { border-color: var(--red); background: var(--red-soft); text-decoration: line-through 2px var(--red); }
.type-feedback { margin-top: 12px; }
.type-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.type-actions .btn { min-height: 52px; }
.type-actions--done { grid-template-columns: 1fr; }
.type-actions--done:has(> :nth-child(2)) { grid-template-columns: 1fr 1.4fr; }

.feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 600; font-size: 1rem; }
.feedback strong { font-family: var(--serif); font-size: 1.125rem; }
.feedback--right { color: var(--green); }
.feedback--close { color: var(--orange); }
.feedback--wrong { color: var(--red); }

/* summary */
.summary { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 24px 0; }
.summary__mark {
  display: grid;
  place-items: center;
  width: 72px; height: 72px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
}
.summary__title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.summary__lede { color: var(--label-2); }
.summary__goal { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--orange); font-weight: 600; }
.summary__missed { width: 100%; margin-top: 18px; text-align: left; }
.summary__list { margin: 0; padding: 0; list-style: none; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.summary__list li { display: flex; flex-direction: column; padding: 10px 16px; border-top: 0.5px solid var(--sep); }
.summary__list li:first-child { border-top: 0; }
.summary__actions { display: grid; gap: 8px; }

/* ---------------------------------------------------------------- progress / charts */
.viz { position: relative; }
.viz .panel__text { margin-bottom: 14px; }
.viz-tip {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, calc(-100% - 8px));
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--label);
  color: var(--bg);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
.viz-note { margin-top: 10px; color: var(--label-2); font-size: 0.8125rem; }

.heat { position: relative; }
.heat__months, .heat__grid { display: grid; grid-template-columns: repeat(var(--weeks), minmax(0, 1fr)); gap: 3px; min-width: 0; }
.heat__months { margin-left: 2rem; margin-bottom: 4px; color: var(--label-2); font-size: 0.6875rem; }
.heat__months span { white-space: nowrap; overflow: visible; min-width: 0; }
.heat__body { display: flex; gap: 6px; }
.heat__days { flex: none; display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; width: calc(2rem - 6px); color: var(--label-2); font-size: 0.6875rem; }
.heat__days span { display: flex; align-items: center; }
.heat__grid { flex: 1; grid-auto-flow: column; grid-template-rows: repeat(7, auto); }
.heat__cell { aspect-ratio: 1; border-radius: 3px; background: var(--viz-0); }
.heat__cell--1 { background: var(--viz-1); }
.heat__cell--2 { background: var(--viz-2); }
.heat__cell--3 { background: var(--viz-3); }
.heat__cell--4 { background: var(--viz-4); }
.heat__cell--future { background: none; }
.heat__cell.is-today { box-shadow: 0 0 0 1.5px var(--label); }
.heat__legend { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 10px; color: var(--label-2); font-size: 0.75rem; }
.heat__legend .heat__cell { width: 12px; }

.stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; background: var(--surface); }
.stack__seg { min-width: 4px; }
.stack__seg--new { background: var(--viz-new); }
.stack__seg--learning { background: var(--viz-learning); }
.stack__seg--mastered { background: var(--viz-mastered); }
.legend { display: grid; gap: 2px; margin: 12px 0 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 0.9375rem; }
.legend__swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend__label { flex: 1; }
.legend__value { color: var(--label-2); font-variant-numeric: tabular-nums; }

.fc__bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 10rem; }
.fc__col { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 4px; cursor: default; }
.fc__value { min-height: 1.2em; color: var(--label); font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc__track { position: relative; width: 100%; border-bottom: 1px solid var(--sep-strong); }
.fc__bar {
  position: absolute;
  left: 18%; right: 18%; bottom: 0;
  border-radius: 4px 4px 0 0;
  background: var(--viz-bar);
}
.fc__label { color: var(--label-2); font-size: 0.75rem; }

.about { padding: 0 16px 24px; color: var(--label-2); font-size: 0.8125rem; text-align: center; }

/* ---------------------------------------------------------------- editor & import */
.editor { padding-top: 4px; }
.editor .btn--secondary { margin-top: 4px; }
.import-preview { margin-top: 8px; }
.import-preview__count { font-weight: 600; margin-bottom: 6px; }
.import-preview__list { margin: 0; padding-left: 18px; color: var(--label-2); font-size: 0.9375rem; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 360px) {
  .page-title { font-size: 1.875rem; }
  .rate { font-size: 0.8125rem; }
  .due__n { font-size: 1.5rem; }
  .segmented__label { font-size: 0.8125rem; padding: 0 4px; }
  .segmented__label .icon { display: none; }
}
