:root {
  --bg: #f5f6f8;
  --fg: #1c2430;
  --muted: #6b7684;
  --accent: #2f6fed;
  --ok: #1a9e5c;
  --bad: #d3453b;
  --card: #ffffff;
  --border: #e2e6ec;
  /* Greek word display — Noto Sans has clear, learner-friendly Greek letterforms. */
  --greek-font: "Noto Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 16px; }

header h1 { margin: 0; font-size: 28px; font-weight: 800; display: inline-flex; align-items: center; gap: 10px; }
.brand-logo { flex: 0 0 auto; }

main { max-width: 1040px; margin: 24px auto; padding: 0 16px; }
/* Reading/answering views stay comfortably narrow; the words table uses the full width. */
#card-view, #drill-view { max-width: 640px; margin-left: auto; margin-right: auto; }

.card, section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

h2 { margin-top: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.space-between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }

input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
button:hover { opacity: 0.92; }
button.link { background: none; color: var(--accent); padding: 4px 0; }
button.ghost { background: #eef1f6; color: var(--fg); }
button.ok { background: var(--ok); }
button.bad { background: var(--bad); }

.user-bar { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.profile-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px;
}
.profile-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-lg { width: 64px; height: 64px; }

.profile-head { display: flex; gap: 16px; align-items: center; margin: 16px 0; }
.profile-fields { flex: 1; min-width: 0; }
.profile-fields input { max-width: 320px; }

.menu { margin: 20px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.menu-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; background: none; color: var(--fg); padding: 12px 14px; border-radius: 0;
  border-bottom: 1px solid var(--border); text-align: left; font-size: 15px;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: #f6f8fb; opacity: 1; }
.menu-arrow { color: var(--muted); }

/* Landing (login screen): the section itself is transparent, its pieces are cards. */
/* The landing breaks out of main's max-width to use the full viewport, so the two sliders get room. */
section.landing {
  background: none; border: none; box-shadow: none;
  width: 100vw; margin-left: calc(50% - 50vw); padding: 0 24px; box-sizing: border-box;
}

/* Landing: word slider | text + auth | features slider — everything on one screen. */
.hero3 {
  display: grid; grid-template-columns: 1fr minmax(300px, 340px) 1fr; gap: 32px; align-items: center;
  max-width: 1700px; margin: 24px auto;
}
.hero-side { min-width: 0; }
.hero-center { min-width: 0; text-align: center; }

.hero-pupa { margin: 0 auto 8px; }

/* Drill finished: a big celebrating Pupa + "Закончить". */
.drill-done { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px 0 44px; }
.drill-done h2 { font-size: 28px; margin: 0; }
.drill-done-pupa { margin: 26px auto 18px; }
.hero-brand { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 10px; }
.hero-greet { margin-bottom: 14px; }
.hero-greet-word { display: block; font-family: var(--greek-font); font-size: 26px; font-weight: 700; color: var(--accent); }

.hero-sub { margin: 0 0 20px; font-size: 16px; line-height: 1.55; color: var(--muted); }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: var(--fg); border: 1px solid var(--border);
  padding: 12px 22px; font-weight: 600; font-size: 15px;
}
.google-btn:hover { background: #f6f8fb; opacity: 1; }
.auth-error { color: var(--bad); font-size: 14px; margin: 12px 0 0; }
.auth-legal { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.auth-legal a { color: var(--muted); }

#app-footer {
  padding: 20px 24px 24px; text-align: center;
  font-size: 12px; color: var(--muted);
}
#app-footer a { color: var(--muted); text-decoration: none; }
#app-footer a:hover { color: var(--accent); text-decoration: underline; }

.feature { padding: 20px; text-align: center; }
.feature-icon { font-size: 30px; }
.feature h4 { margin: 10px 0 6px; font-size: 16px; }
.feature p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eef1f6; color: var(--muted); font-size: 12px; white-space: nowrap;
}
.badge.ok { background: #e5f6ec; color: var(--ok); }

.profile-actions { margin-top: 16px; }

/* ---- Generic slider (used twice on the landing) ---- */
.slider { display: flex; align-items: center; gap: 6px; }
.slider-viewport { flex: 1; min-width: 0; overflow: hidden; }
.slider-track { display: flex; transition: transform 0.4s ease; height: 100%; }
/* Fixed-size slides: switching never shifts width or height. A rare taller card scrolls inside. */
.slider-slide { flex: 0 0 100%; min-width: 0; overflow-y: auto; }
/* Both sliders share one tall height so the two flanking cards read as a balanced pair. */
.slider.words .slider-viewport,
.slider.feats .slider-viewport { height: 600px; }
/* Center content vertically so short cards (an invariable word, a feature) sit balanced, not top-heavy. */
.slider-slide .card {
  width: 100%; min-width: 0; margin: 0; min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
}
.slider.feats .slider-slide .card { align-items: center; }
.slider .demo-card { text-align: center; }
/* Badges wrap and center instead of clipping off the card edge; a wide forms table scrolls inside. */
.slider .card-top { flex-wrap: wrap; justify-content: center; }
.slider .demo-card .forms-block { overflow-x: auto; }
.slider-nav {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 20px; line-height: 1;
  background: var(--card); color: var(--fg); border: 1px solid var(--border);
}
.slider-nav:hover { background: #f6f8fb; opacity: 1; }
.slider-dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.slider-dots button {
  width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--border); border: none; cursor: pointer;
}
.slider-dots button.active { background: var(--accent); }

/* Stack the three columns on narrow screens: text+auth first, then the two sliders. */
@media (max-width: 900px) {
  .hero3 { grid-template-columns: 1fr; gap: 20px; max-width: 460px; margin: 24px auto; }
  .hero-center { order: -1; }
}

/* ---- Active sessions (Telegram-style list) ---- */
.sess-section-label {
  text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; color: var(--muted);
  margin: 20px 0 8px;
}
.sess-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  margin-bottom: 8px;
}
.sess-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* Faint monospace uid tag (last 4 chars); click to copy the full id — debug aid. */
.copy-uid {
  background: none; border: none; padding: 2px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
  color: var(--muted); opacity: 0.5; cursor: pointer; line-height: 1;
}
.copy-uid:hover { opacity: 1; color: var(--accent); }
.sess-icon { font-size: 22px; flex: none; }
.sess-info { flex: 1; min-width: 0; }
.sess-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sess-action { flex: none; background: #eef1f6; color: var(--fg); padding: 6px 14px; }
.sess-action:hover { opacity: 0.92; }
.sess-action.logout { background: none; color: var(--bad); padding: 6px 8px; }
.sess-terminate {
  width: 100%; text-align: left; background: none; color: var(--bad);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; font-size: 15px;
}
.sess-terminate:hover { background: #fdf0ef; opacity: 1; }
.sess-hint { color: var(--muted); font-size: 13px; margin: 6px 2px 0; }

.modal-actions { margin-top: 20px; }

.words-table { width: 100%; border-collapse: collapse; }
.words-table th {
  text-align: left; font-size: 11px; letter-spacing: 0.3px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.words-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.words-table tbody tr:hover { background: #f9fafc; }
.words-table .c-open { width: 30px; text-align: center; padding-left: 4px; padding-right: 4px; }
.row-open {
  width: 22px; height: 22px; padding: 0; border: none; background: transparent;
  color: var(--muted); font-size: 17px; line-height: 22px; text-align: center;
  border-radius: 50%; cursor: pointer; transition: background 0.1s, color 0.1s;
}
.row-open:hover { background: #eef1f6; color: var(--accent); }
.words-table .c-word { width: 26%; }
.words-table .c-ipa  { width: 17%; }
.words-table .c-tr   { width: 23%; }
.words-table .c-descr{ width: 34%; }
.w-lemma { font-size: 18px; font-family: var(--greek-font); }
/* Keep the part-of-speech + gender badges together as one group that wraps below the word as a unit
   (instead of the gender badge dropping to its own line). */
.w-badges { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; vertical-align: middle; margin-left: 8px; }
.w-badges .pos-tag, .w-badges .gender-tag { margin-left: 0; }
.w-ipa { font-family: ui-monospace, monospace; color: var(--accent); font-size: 15px; }
.c-tr { font-weight: 500; }
.c-descr { color: var(--muted); font-style: italic; font-size: 13px; }
#list-status { padding: 14px 0; }

.pos-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-style: normal;
  padding: 1px 8px; border-radius: 20px; background: #eef1f6; color: var(--muted);
  vertical-align: middle; white-space: nowrap;
}
.pos-tag[data-pos="noun"]      { background: #e7f0ff; color: #2f6fed; }
.pos-tag[data-pos="verb"]      { background: #e6f6ec; color: #1a9e5c; }
.pos-tag[data-pos="adjective"] { background: #f3ecfb; color: #7b3fe4; }
.pos-tag[data-pos="adverb"]    { background: #eafaf5; color: #0f9d8f; }
.pos-tag[data-pos="pronoun"]   { background: #fff1e6; color: #c9871f; }
/* Card top bar — part-of-speech + gender badges and the report flag, aligned top-right. */
.card-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 26px; margin-bottom: 2px; }
.card-top.center { justify-content: center; }

/* Related-words blocks under a card (derivational family now; inflected forms later). */
.rel-block { margin-top: 16px; }
.rel-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
/* Uniform grid — every mini-card is the same width and stretches to the same height. */
.mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mini-card {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; text-align: left; font: inherit; color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); transition: border-color 0.1s;
}
.mini-card:hover { border-color: var(--accent); }
.mini-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.mini-head .gender-tag { margin-left: 0; }
.mini-lemma { font-size: 16px; font-weight: 600; }
.mini-role { font-size: 11px; color: var(--muted); }
.mini-tr { font-size: 13px; color: var(--muted); }
/* Example sentences as quote cards; the word's form is highlighted. */
/* Compact by default, sitting among the header buttons; widens when focused or holding a query. */
.word-search {
  width: 130px; box-sizing: border-box; padding: 6px 12px;
  font: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--fg); transition: width 0.15s ease;
}
.word-search:focus, .word-search:not(:placeholder-shown) { width: 260px; max-width: 60vw; }
.word-search:focus { outline: none; border-color: var(--accent); }
.examples { display: flex; flex-direction: column; gap: 8px; }
.example-quote {
  border-left: 3px solid var(--accent); background: var(--bg);
  padding: 8px 12px; border-radius: 0 8px 8px 0; line-height: 1.5; font-size: 15px;
}
.example-quote b { font-weight: 700; color: var(--accent); }
/* Interactive word inside an example — clickable link to its card; the target form is emphasised. */
.ex-word {
  font: inherit; background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); border-bottom: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.ex-word:hover { border-bottom-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ex-target { font-weight: 700; border-bottom-style: solid; }
.example-quote.ex-hidden { display: none; }
.ex-show-all {
  align-self: flex-start; margin-top: 2px; padding: 4px 10px; font-size: 13px;
  background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--accent); cursor: pointer;
}
.ex-show-all:hover { border-color: var(--accent); }
.ex-pop-badges { display: flex; gap: 6px; margin-bottom: 4px; justify-content: center; }
.ex-pop-lemma { font-family: var(--greek-font); font-size: 22px; font-weight: 600; text-align: center; }
.ex-pop-ipa { font-family: ui-monospace, monospace; font-size: 15px; color: var(--accent); text-align: center; }
.ex-pop-hint { font-size: 13px; color: var(--muted); text-align: center; }
.ex-pop-tr { font-size: 15px; margin-top: 4px; text-align: center; }
.ex-pop-descr { font-size: 13px; margin-top: 2px; text-align: center; }
/* "?" hint next to a section title, with an instant CSS tooltip (no slow native title). */
.rel-hint {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; font-size: 11px; font-weight: 700;
  background: var(--border); color: var(--muted); cursor: help; vertical-align: middle;
}
.rel-hint::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: 260px;
  padding: 8px 10px; border-radius: 8px; background: var(--fg); color: #fff;
  font-size: 12px; font-weight: 400; line-height: 1.45; text-transform: none;
  letter-spacing: normal; white-space: normal; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity 0.12s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.rel-hint:hover::after { opacity: 1; visibility: visible; }
/* Sets the word is in: clickable chips coloured by set type. */
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.set-chip {
  padding: 3px 10px; border-radius: 20px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); font: inherit;
  transition: border-color 0.1s;
}
.set-chip:hover { border-color: var(--accent); }
.set-chip[data-set="level"]          { background: #e7f0ff; color: #2f6fed; border-color: #d4e2ff; }
.set-chip[data-set="topic"]          { background: #e6f6ec; color: #1a9e5c; border-color: #cdeed9; }
.set-chip[data-set="part_of_speech"] { background: #f3ecfb; color: #7b3fe4; border-color: #e5d8f7; }
.set-chip[data-set="pronunciation"]  { background: #fff3e8; color: #c9871f; border-color: #f6e2c8; }
/* Sets index: groups of set cards. */
.set-group { margin-bottom: 20px; }
.set-group-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.set-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.set-card {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; cursor: pointer; text-align: left; font: inherit;
  background: var(--card); border: 1px solid var(--border); color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); transition: border-color 0.1s;
}
.set-card:hover { border-color: var(--accent); }
.set-card { position: relative; }
.set-card-title { font-size: 16px; font-weight: 600; padding-right: 26px; }
.set-card-train {
  position: absolute; top: 8px; right: 8px; padding: 2px 8px; font-size: 12px; line-height: 1.5;
  background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); cursor: pointer;
}
.set-card-train:hover { border-color: var(--accent); color: var(--accent); }
.set-card-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.set-due { color: #c9871f; font-weight: 600; }
/* Pin the progress bar to the bottom so cards of different title heights line up. */
.set-progress { width: 100%; height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: auto; }
.set-progress-fill { height: 100%; background: var(--ok); border-radius: 4px; transition: width 0.2s; }
/* Virtual "Все слова" card — a normal-width card sitting above the grouped sets. */
.set-card-all { width: 260px; max-width: 100%; margin-bottom: 20px; border-color: var(--accent); background: linear-gradient(180deg, #eef5ff, var(--card)); }
.set-card-all .set-card-title { color: var(--accent); font-size: 18px; }
.set-card[data-set="level"] .set-card-title          { color: #2f6fed; }
.set-card[data-set="topic"] .set-card-title          { color: #1a9e5c; }
.set-card[data-set="part_of_speech"] .set-card-title { color: #7b3fe4; }
.set-card[data-set="pronunciation"] .set-card-title  { color: #c9871f; }
/* Inflection table (textbook-style paradigm). */
.forms-table { border-collapse: collapse; width: 100%; }
.forms-table th, .forms-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.forms-table thead th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
.forms-table th.frow { font-size: 13px; color: var(--muted); white-space: nowrap; background: var(--bg); }
.fcell .fc-word { font-size: 15px; font-weight: 600; }
.fcell .fc-ipa { font-size: 12px; color: var(--muted); margin-left: 6px; }
.fcell.empty { color: var(--border); text-align: center; }
/* The inflection ending (part that changes across the paradigm): thick coloured underline + popover. */
.form-ending { position: relative; cursor: help; color: var(--accent); }
.form-ending::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px;
  height: 3px; border-radius: 2px; background: var(--accent);
}
.card-top .pos-tag, .card-top .gender-tag { margin-left: 0; font-size: 12px; }
.card-top .flag-btn { position: static; top: auto; right: auto; margin-left: 2px; }

/* Grammatical gender pill (article ο/η/το + colour). */
.gender-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-style: normal; font-weight: 600;
  padding: 1px 8px; border-radius: 20px; background: #eef1f6; color: var(--muted);
  vertical-align: middle; white-space: nowrap;
}
.gender-tag[data-gender="masculine"] { background: #e7f0ff; color: #2f6fed; }
.gender-tag[data-gender="feminine"]  { background: #fdeaf1; color: #d23f7d; }
.gender-tag[data-gender="neuter"]    { background: #eafaf5; color: #0f9d8f; }
/* Marking ending (gender for nouns, POS for verbs/adverbs). Hovering its badge draws a thick coloured
   underline under the ending — same look as the pronunciation-rule underlines. */
.word-ending { position: relative; border-radius: 3px; transition: background 0.12s; }
.word-ending::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px;
  height: 3px; border-radius: 2px; opacity: 0; transition: opacity 0.12s;
}
.word-ending.active::after { opacity: 1; }
.word-ending.active[data-tone="masculine"] { background: #e7f0ff; }
.word-ending.active[data-tone="feminine"]  { background: #fdeaf1; }
.word-ending.active[data-tone="neuter"]    { background: #eafaf5; }
.word-ending.active[data-tone="verb"]      { background: #e6f6ec; }
.word-ending.active[data-tone="adverb"]    { background: #eafaf5; }
.word-ending[data-tone="masculine"]::after { background: #2f6fed; }
.word-ending[data-tone="feminine"]::after  { background: #d23f7d; }
.word-ending[data-tone="neuter"]::after    { background: #0f9d8f; }
.word-ending[data-tone="verb"]::after      { background: #1a9e5c; }
.word-ending[data-tone="adverb"]::after    { background: #0f9d8f; }

/* ✨ on a badge whose ending can be highlighted/explained on hover. */
.hint-star { font-size: 9px; vertical-align: 1px; }

.tag-row { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 2px; }
.tag-row .gender-tag, .tag-row .pos-tag { margin-left: 0; font-size: 12px; }

.row-unhide {
  padding: 4px 10px; font-size: 12px; background: #eef1f6; color: var(--accent);
  border-radius: 6px; white-space: nowrap;
}
.row-unhide:hover { background: #e0e7f5; }
.row-unhide:disabled { opacity: 0.5; cursor: default; }

.word-head { text-align: center; padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.lemma-big { font-family: var(--greek-font); font-size: 44px; font-weight: 600; margin: 4px 0 6px; letter-spacing: 0.5px; }
.ipa-line { font-family: ui-monospace, monospace; font-size: 20px; color: var(--accent); margin: 0 0 4px; }
/* Pronunciation hint (кириллица) — always visible inline, so it never overlaps other content. */
.pron-hint { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.w-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
/* Pronunciation-rule group inside the lemma: a thick coloured underline at one of several levels
   (so adjacent/overlapping groups stay distinguishable), hover/focus reveals the description. */
/* Reserve just enough space below the word for the deepest underline level actually used. */
.lemma-segs { display: inline-block; padding-bottom: calc(10px + var(--maxlvl, 0) * 6px); }
.rule-seg { position: relative; cursor: pointer; outline: none; }
.rule-seg::after {
  content: ""; position: absolute; left: 0; right: 0;
  bottom: calc(-5px - var(--lvl, 0) * 6px);
  height: 3px; border-radius: 2px; background: var(--rule-color, var(--accent));
  transition: height 0.1s;
}
.rule-seg:hover::after, .rule-seg:focus::after { height: 5px; }
.rule-seg:hover, .rule-seg:focus { background: color-mix(in srgb, var(--rule-color) 10%, transparent); border-radius: 3px; }
.rule-popover {
  position: absolute; z-index: 200; width: 280px; max-width: calc(100vw - 16px);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 28, 40, 0.18); padding: 12px 14px; text-align: left;
}
.rule-pop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rule-pop-title { font-weight: 600; font-size: 15px; }
.rule-pop-ipa { font-family: ui-monospace, monospace; color: var(--accent); font-size: 14px; }
.rule-pop-hint { color: var(--muted); font-size: 13px; margin-top: 3px; }
.rule-pop-expl { font-size: 14px; margin-top: 8px; line-height: 1.45; }

.pos { display: inline-block; font-size: 12px; color: var(--muted); background: #eef1f6; border-radius: 20px; padding: 3px 12px; text-transform: lowercase; }
.ipa { color: var(--muted); font-family: monospace; }
.translation-big { font-size: 30px; font-weight: 600; text-align: center; margin: 6px 0 8px; }
.descr { color: var(--muted); text-align: center; font-style: italic; margin-bottom: 14px; }
.hint { text-align: center; color: var(--fg); margin-bottom: 14px; }
.hint-label { color: var(--muted); font-size: 13px; }
.field { margin: 10px 0; }
.field .label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
audio { width: 100%; margin: 8px 0 4px; }

.progress {
  margin-top: 16px; padding: 12px; background: #f9fafc; border-radius: 8px; font-size: 14px;
}
.progress .stage { font-weight: 600; }
.prog-row { padding: 8px 0; border-top: 1px solid var(--border); }
.prog-row:first-child { border-top: none; }
.prog-type { font-weight: 600; margin-bottom: 4px; }
.prog-line { margin-top: 3px; }

/* Mastery bar: a red→green track with an emoji marker sitting at the learner's position. */
.mastery { margin: 6px 0 10px; }
.mastery-cap { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.mastery-bar {
  position: relative; height: 10px; border-radius: 6px;
  background: linear-gradient(to right, #d3453b, #e6b02e 55%, #1a9e5c);
}
.mastery-dot {
  position: absolute; top: 50%; width: 15px; height: 15px; border-radius: 50%;
  transform: translate(-50%, -50%); background: #fff; border: 2px solid var(--fg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.mastery-emoji {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: 18px; line-height: 1; pointer-events: none;
}
.mastery-scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); }
.mastery-scale span:nth-child(2) { font-weight: 600; color: var(--fg); }

/* Drill: the card frame is #drill-content itself, so related words can sit below it, outside the frame. */
#drill-view { background: none; border: none; border-radius: 0; padding: 0; }
#drill-content {
  position: relative;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
}
#drill-family:not(:empty) { margin-top: 16px; }
.reveal-hidden { visibility: hidden; }
/* Countdown sits between the two answer buttons; its slot is always reserved (min-width) so the
   buttons never resize when it clears. Muted grey so it doesn't pull the eye off the word. */
.drill-countdown {
  flex: 0 0 auto; min-width: 52px; text-align: center;
  font-size: 34px; font-weight: 700; line-height: 1;
  color: var(--muted); opacity: 0.2; pointer-events: none; user-select: none;
}
.drill-count { margin-bottom: 24px; }
.drill-actions { display: flex; gap: 16px; align-items: center; margin-top: 28px; }
.drill-actions button { flex: 1; padding: 20px 16px; font-size: 20px; font-weight: 600; }
/* After answering the buttons stay in place, just inactive — keeps the layout stable. */
.drill-actions button:disabled { opacity: 0.4; cursor: default; }
.center { text-align: center; }
.right { text-align: right; }
.badge-new { color: var(--accent); }
.badge-learning { color: #c9871f; }
.badge-known { color: var(--ok); }

/* Report/hide — a muted flag tucked in the card corner, visually apart from the drill actions. */
#card-content, #drill-content { position: relative; }
.flag-btn {
  position: absolute; top: 6px; right: 6px; z-index: 5;
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 15px; line-height: 30px;
  opacity: 0.5; transition: opacity 0.1s, background 0.1s, color 0.1s;
}
.flag-btn:hover { opacity: 1; background: #fdecec; color: var(--bad); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 28, 40, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-card {
  position: relative;
  background: var(--card); border-radius: 12px; padding: 22px;
  width: 100%; max-width: 420px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.modal-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; padding: 0;
  background: none; border: none; border-radius: 8px;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: #f0f2f5; color: var(--fg); }
.modal-card h3 { margin: 0 0 6px; padding-right: 28px; }
.modal-card input[type="text"], .modal-card textarea {
  width: 100%; margin-top: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px; font-family: inherit;
}
.modal-card textarea { min-height: 60px; resize: vertical; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.warn { color: var(--bad); font-size: 13px; margin: 0 0 10px; }
.reason-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.reason-tile {
  background: #f3f5f8; color: var(--fg); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 13px 10px; font-size: 14px; font-weight: 500; text-align: center;
  cursor: pointer; transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.reason-tile:hover { border-color: var(--ok); opacity: 1; }
.reason-tile.selected {
  background: #e6f6ec; border-color: var(--ok); color: var(--ok); font-weight: 600;
  box-shadow: 0 0 0 1px var(--ok) inset;
}
.msg { margin-top: 12px; font-size: 14px; min-height: 18px; }
.msg.ok-msg { color: var(--ok); }
.msg.bad-msg { color: var(--bad); }

/* ---- Custom sets ---- */
button.danger { background: var(--bad); }

.set-owner-actions { display: flex; gap: 8px; margin: 4px 0 14px; }
/* Square icon-only button (e.g. the set settings gear). */
.icon-btn { padding: 0; width: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }

/* Remove-from-set control inside an owned set's word rows. */
.words-table-owned .c-open { width: 56px; white-space: nowrap; }
.row-remove {
  background: none; color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 6px; font-size: 13px; margin-left: 4px;
}
.row-remove:hover { border-color: var(--bad); color: var(--bad); }
.row-remove:disabled { opacity: 0.5; cursor: default; }

/* Emoji picker (create / settings). */
.emoji-field { margin-top: 10px; }
.emoji-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.emoji-input { width: 72px !important; text-align: center; font-size: 22px !important; }
.emoji-palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.emoji-pick {
  background: #f3f5f8; border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 8px; font-size: 18px; line-height: 1;
}
.emoji-pick:hover { border-color: var(--accent); }

.modal-card.wide { max-width: 560px; }

/* Add-words modal: tabs + result rows. */
.tabs { display: flex; gap: 6px; margin: 12px 0; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; color: var(--muted); border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 12px; font-size: 14px;
}
.tab-btn.selected { color: var(--accent); border-bottom-color: var(--accent); }

.aw-tab #aw-q { width: 100%; }
.aw-textarea { width: 100%; min-height: 120px; margin: 4px 0 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px; font-family: inherit; resize: vertical; }
.aw-col-wrap { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.aw-col-wrap select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.aw-header-opt { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.aw-results { margin-top: 12px; max-height: 46vh; overflow-y: auto; }
.aw-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 4px; border-bottom: 1px solid var(--border);
}
.aw-word { font-size: 15px; }
.aw-add {
  background: #eef1f6; color: var(--accent); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 10px; font-size: 15px; line-height: 1; flex: none;
}
.aw-add:hover { border-color: var(--accent); }
.aw-add.added { background: #e6f6ec; color: var(--ok); border-color: var(--ok); }
.aw-suggest {
  background: none; color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; font-size: 13px; flex: none;
}
.aw-suggest:hover { border-color: var(--accent); color: var(--accent); }
.aw-suggest.added { color: var(--ok); border-color: var(--ok); }
.aw-bucket { margin-top: 14px; }
.aw-bucket-head {
  font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em;
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.aw-bucket-head button { padding: 3px 10px; font-size: 13px; }

/* Quick-add-to-list button (mirrors the flag button, on the opposite corner) and its picker. */
.addlist-btn {
  position: absolute; top: 6px; left: 6px; z-index: 5;
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted);
  opacity: 0.7; transition: opacity 0.1s, background 0.1s, color 0.1s;
}
.addlist-btn svg { display: block; }
.addlist-btn:hover { opacity: 1; background: #eef1f6; color: var(--accent); }
.card-top .addlist-btn { position: relative; top: auto; left: auto; }

/* Hover hint above the button (Spotify-style). Edge-anchored so it never overflows the card. */
.addlist-btn::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px);
  background: #1f2733; color: #fff; font-size: 12px; line-height: 1.2; white-space: nowrap;
  padding: 6px 9px; border-radius: 6px; opacity: 0; pointer-events: none;
  transition: opacity 0.12s; z-index: 30;
}
.addlist-btn:hover::after { opacity: 1; }
#drill-add-list::after { left: 0; }
#card-add-list::after { right: 0; }

/* Row-level "save to a set": left of the word, reserved space so nothing shifts, shown on row hover. */
.row-addlist {
  background: none; border: none; padding: 0; margin-right: 6px; cursor: pointer;
  color: var(--muted); vertical-align: middle; line-height: 0;
  opacity: 0; transition: opacity 0.1s, color 0.1s;
}
.row-addlist svg { width: 16px; height: 16px; display: inline-block; vertical-align: middle; }
tr:hover .row-addlist { opacity: 0.65; }
tr:hover .row-addlist:hover { opacity: 1; color: var(--accent); }

.atl-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; max-height: 50vh; overflow-y: auto; }
.atl-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #f3f5f8; color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 15px; text-align: left;
}
.atl-item:hover { border-color: var(--accent); }
.atl-item.added { background: #e6f6ec; border-color: var(--ok); }
.atl-item.added .atl-state { color: var(--ok); }
.atl-item:disabled { cursor: default; }

/* Dev console (opened with Ctrl+` or #dev) */
.dev-section {
  margin-top: 12px; padding: 10px 12px;
  background: #f3f5f8; border: 1px solid var(--border); border-radius: 10px;
}
.dev-tag {
  display: inline-block; margin-bottom: 6px; padding: 1px 8px;
  background: #e2e6ec; color: var(--muted); border-radius: 6px;
  font-size: 12px; font-weight: 600;
}
.dev-kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 2px 0; }
.dev-kv > span:first-child { color: var(--muted); }
.dev-section .row { margin-top: 8px; }
