:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --accent-text: #fff; --danger: #c62828; --ok-bg: #e7f6ec; --ok: #1b6e35;
  --err-bg: #fdecec; --err: #9b1c1c; --tag: #eef1f5; --warn-bg: #fff6d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --line: #2c323d;
    --accent: #4b8df8; --danger: #ef5350; --ok-bg: #173323; --ok: #8fe0a8; --err-bg: #3a1a1a;
    --err: #ffb4b4; --tag: #262c36; --warn-bg: #3a3215;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .brand { font-weight: 600; }
.top nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.top nav a { color: var(--accent); text-decoration: none; }
.banner { background: var(--warn-bg); padding: 6px 16px; font-size: 13px; text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
h1, h2, h3 { margin: 0 0 10px; } h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 16px; margin-top: 16px; }
h4 { margin: 10px 0 4px; font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; } .pre { white-space: pre-wrap; }
.count { font-size: 13px; background: var(--tag); border-radius: 10px; padding: 1px 8px; vertical-align: middle; }
.tag { display: inline-block; background: var(--tag); border-radius: 6px; padding: 0 6px; font-size: 12px; }
.tag.live, .st-applied { background: var(--ok-bg); color: var(--ok); }
.tag.dry { background: var(--warn-bg); }
.st-rejected { background: var(--err-bg); color: var(--err); }
.st-approved { background: #dbe8ff; color: #123d82; }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
#toast { position: fixed; right: 16px; bottom: 16px; max-width: min(480px, calc(100vw - 32px)); z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
tr.inactive td { opacity: .55; }
td.name { font-weight: 600; }
input, select, button { font: inherit; color: inherit; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
input.spelling { width: 13em; } input.note { width: 11em; }
button { background: var(--tag); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { filter: brightness(0.96); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.small { padding: 3px 8px; font-size: 13px; }
button.busy { opacity: .6; cursor: progress; }
button:disabled { cursor: not-allowed; }
button:disabled:not(.busy) { opacity: .45; filter: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0; }
form.row, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
form.review { display: flex; flex-wrap: wrap; gap: 4px; }
div.propose { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 22em; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--err); }
.login { max-width: 360px; margin: 48px auto; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; }
details.apply { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
details summary { cursor: pointer; }
ul.cols { columns: 3 18em; font-size: 13px; }
.usage { margin: 6px 0 0; }
/* new-spelling cell: [input|▶] [Исправить/Отправить] message */
.newspell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.spell-group { display: inline-flex; align-items: stretch; }
.spell-group input.spelling { border-radius: 6px 0 0 6px; border-right: 0; }
.spell-group button.listen { border-radius: 0 6px 6px 0; }
.newspell .msg:empty { display: none; }
.spelled { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
table tr.is-playing td { background: rgba(31, 111, 235, .10); }
tr.is-playing td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 700px) {
  input.spelling, input.note { width: 100%; }
  div.propose { min-width: 16em; }
  .spell-group { flex: 1 1 12em; }
  .spell-group input.spelling { width: auto; flex: 1; min-width: 0; }
  button.play, button.listen { min-width: 2.6em; min-height: 2.2em; }
}

/* admin dictionary: rows marked OK */
tr.ok td { background: rgba(52, 168, 83, .10); }
input.okbox { width: 18px; height: 18px; cursor: pointer; }

/* ---- icons (SVG sprite in base.html) ---- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 14px; height: 14px; fill: currentColor; display: block; }
.ic-stop { display: none; }
.playing .ic-play { display: none; }
.playing .ic-stop { display: block; }

/* play buttons: calm round outline, filled only while playing */
button.play, button.listen {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 30px; height: 30px; min-width: 30px; padding: 0; border-radius: 50%;
  background: var(--card); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
button.play:hover:not(:disabled), button.listen:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, var(--card)); filter: none;
}
button.play.playing, button.listen.playing { background: var(--accent); color: #fff; border-color: var(--accent); }
.spell-group button.listen { width: 34px; height: auto; min-height: 30px; border-radius: 0 6px 6px 0; }

/* Исправить / Отправить: square icon buttons, green when ready */
button.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 30px; padding: 0; border-radius: 6px;
  background: var(--ok-bg); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
}
button.icon-btn:hover:not(:disabled) { background: var(--ok); color: #fff; filter: none; }
button.icon-btn:disabled { background: var(--tag); color: var(--muted); border-color: var(--line); }
button.icon-btn .ic { width: 16px; height: 16px; }
@media (max-width: 700px) {
  button.play, button.listen { width: 36px; height: 36px; min-width: 36px; }
  button.icon-btn { width: 38px; height: 36px; }
}

/* ---- visibility fixes (dark mode, disabled states, one line) ---- */
.newspell { flex-wrap: nowrap; }
.newspell .msg { white-space: normal; }
input.spelling { width: 11.5em; }

/* play buttons: strong outline in both themes */
button.play, button.listen {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
}
.spell-group button.listen {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
button.play:hover:not(:disabled), button.listen:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}
button.play.playing, button.listen.playing { background: var(--accent); color: #fff; }

/* disabled = visible but quiet (no double fading) */
button.play:disabled, button.listen:disabled, button.icon-btn:disabled { opacity: 1; filter: none; }
button.listen:disabled {
  border-color: var(--muted); color: var(--muted); background: transparent;
}

/* Исправить / Отправить */
button.icon-btn {
  border: 1.5px solid var(--ok); color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}
button.icon-btn:hover:not(:disabled) { background: var(--ok); color: var(--card); }
button.icon-btn:disabled {
  border-color: var(--muted); color: var(--muted); background: transparent;
}
@media (prefers-color-scheme: dark) {
  :root { --muted: #a7b0bf; }
}

/* ---- one field button: step 1 play, step 2 save (green check / send) ---- */
.newspell > .fix { display: none; }
.ic-save { display: none; }
.spell-group button.listen.ready {
  border-color: var(--ok); color: var(--ok);
  background: color-mix(in srgb, var(--ok) 18%, transparent);
}
.spell-group button.listen.ready:hover:not(:disabled) { background: var(--ok); color: var(--card); }
.listen.ready .ic-play, .listen.ready .ic-stop { display: none; }
.listen.ready .ic-save { display: block; }
/* heard = check icon at once, even while still playing (row highlight shows playback) */
.listen.ready.playing { background: var(--ok); color: var(--card); border-color: var(--ok); }

/* ---- «Примечание»: small and compact ---- */
td.note-cell { font-size: 11.5px; color: var(--muted); max-width: 12em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.note-col input.note { width: 9em; font-size: 12px; padding: 3px 6px; }
/* notes: show the full text, wrapped in a narrow column (no "…") */
td.note-cell { white-space: normal; overflow: visible; text-overflow: clip;
  max-width: 14em; min-width: 9em; line-height: 1.3; word-break: break-word; }

/* ---- admin: tester suggestions in the dictionary ---- */
tr.has-sugg td { background: color-mix(in srgb, #f5a623 12%, transparent); }
td.sugg-cell { min-width: 15em; }
.sugg { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; padding: 2px 0; }
.sugg + .sugg { border-top: 1px dashed var(--line); }
button.icon-btn.reject { border-color: var(--danger); color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent); }
button.icon-btn.reject:hover:not(:disabled) { background: var(--danger); color: var(--card); }
.top nav .count { margin-left: 2px; background: #f5a623; color: #1d2330; }

.send-all-bar { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }

/* ---- public page ---- */
.top .brand a.home { color: inherit; text-decoration: none; }
.noaudio { display: inline-flex; width: 30px; justify-content: center; color: var(--muted); }

/* ---- names page ---- */
.names { columns: 3 18em; column-gap: 24px; }
.brand-group { break-inside: avoid; margin-bottom: 14px; }
.brand-group h2 { font-size: 16px; margin: 0 0 4px; }
.brand-group ul { margin: 0; padding-left: 18px; }
.brand-group li { line-height: 1.5; }

.brand-group ul { list-style: none; padding-left: 0; }
.brand-group li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.brand-group h2 { display: flex; align-items: center; gap: 8px; }
button.play.small-play { width: 26px; height: 26px; min-width: 26px; }
button.play.small-play .ic { width: 12px; height: 12px; }
