/* The Definitions tool: a registry's look — cool grey paper, slate text, a green accent for what is current and
   sound. Compact tables, monospace for paths and keys. No inline styles: the CSP allows none. */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --border: #dfe3e8;
  --border-strong: #c3cad3;
  --text: #1b2430;
  --text-2: #44505e;
  --muted: #6f7b89;
  --accent: #1f7a5c;
  --accent-hover: #17654b;
  --accent-soft: #dff1e9;
  --on-accent: #ffffff;
  --ok: #1f7a5c;
  --ok-soft: #dff1e9;
  --warn: #9a6700;
  --warn-soft: #fff1cc;
  --err: #b3261e;
  --err-soft: #fbe2e0;
  --shadow-lg: 0 12px 40px rgba(20, 30, 45, .18);
  color-scheme: light;
}

:root[data-theme="dark"], :root:not([data-theme="light"]):is(.dark) { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d;
    --surface: #1b2027;
    --surface-2: #20262e;
    --surface-3: #2a313a;
    --border: #2f3842;
    --border-strong: #46515d;
    --text: #e6eaef;
    --text-2: #b9c2cc;
    --muted: #8793a0;
    --accent: #4cc39a;
    --accent-hover: #6ad1ad;
    --accent-soft: #163428;
    --on-accent: #06211a;
    --ok: #4cc39a;
    --ok-soft: #163428;
    --warn: #e8b24a;
    --warn-soft: #3a2d10;
    --err: #f27a72;
    --err-soft: #3b1a18;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
code { font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; color: var(--text);
  font-weight: 600; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 15px; }
.btn:disabled, .btn:disabled:hover { opacity: .45; cursor: default; border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.btn.primary:disabled { background: var(--accent); color: var(--on-accent); }

.input, .select, textarea.input {
  height: 34px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; min-width: 0; width: 100%;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; text-transform: uppercase;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.current { background: var(--accent); color: var(--on-accent); }

.note { padding: 10px 12px; border-radius: 7px; font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.err { background: var(--err-soft); color: var(--err); }
.sub { color: var(--muted); font-size: 13px; }
.lead { color: var(--text-2); font-size: 15px; margin-bottom: 8px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- top bar */
.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; height: 54px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.logo { width: 28px; height: 28px; }
.logo rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.logo path { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.ver { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 4px; }
.tabs { display: flex; gap: 4px; }
.tabs button { height: 54px; padding: 0 12px; background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 700; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
body.signed-out .tabs { display: none; }

main { padding: 22px 20px 48px; }
.view { max-width: 1240px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 16px; min-width: 0; margin-bottom: 14px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h h2 { font-size: 12.5px; font-weight: 800; color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; }
.card-h .key { color: var(--muted); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.side { position: sticky; top: 68px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- sign in */
.login { display: grid; place-items: start center; padding-top: 8vh; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 12px; padding: 30px 32px; }
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-card .lead { margin-bottom: 18px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-card .note { margin-top: 12px; }

/* ---------------------------------------------------------------- tables */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; height: 100%; }
.table-card { border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 60vh; }
table.vt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.vt th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; white-space: nowrap; padding: 8px 10px; color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.vt td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.vt tbody tr:last-child td { border-bottom: 0; }
.vt tbody tr.link { cursor: pointer; }
.vt tbody tr.link:hover td { background: var(--surface-2); }
.vt tbody tr.selected td { background: var(--accent-soft); }
.vt td.note { color: var(--text-2); max-width: 320px; overflow-wrap: anywhere; }
.vt .c-actions { white-space: nowrap; text-align: right; }
.vt .c-actions .btn { margin-left: 4px; }

/* ---------------------------------------------------------------- problems and diff */
.problems { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; max-height: 50vh; overflow: auto; }
.problems li { display: flex; gap: 8px; align-items: flex-start; }
.problems li.ok { color: var(--ok); }
.problems .tag { flex: none; margin-top: 1px; }
#defDiff h3 { font-size: 13px; font-weight: 800; color: var(--text-2); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.change { display: grid; grid-template-columns: max-content max-content 1fr; gap: 6px 10px; align-items: start; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.change code { grid-column: 3; overflow-wrap: anywhere; white-space: pre-wrap; display: block; padding: 4px 6px; border-radius: 4px; }
.change code.before { background: var(--err-soft); text-decoration: line-through; text-decoration-color: var(--err); }
.change code.after { background: var(--ok-soft); }
.change.mono { display: block; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; box-shadow: var(--shadow-lg); }
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast-x { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }

/* ---------------------------------------------------------------- the editor */
.subtabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.subtabs button { height: 38px; padding: 0 14px; background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 700; }
.subtabs button:hover { color: var(--text); }
.subtabs button[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.editor-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 14px; align-items: start; }
.editor-grid .card { margin-bottom: 0; }
.table-card.tall { max-height: 72vh; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); }
.field .hint { font-weight: 400; }
.about { margin: -4px 0 10px; }
.btn.danger { border-color: var(--err); color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.form-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.vt tbody tr.removed td { color: var(--muted); }
.vt tbody tr.removed td.mono, .vt tbody tr.removed td:nth-child(3) { text-decoration: line-through; }
.vt td .tag { margin-left: 6px; }

/* the texts of an entry: key, English, Czech */
.words { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr) minmax(0, 2fr); gap: 6px 10px; align-items: center; margin-bottom: 12px; }
.words-key { overflow-wrap: anywhere; }
.words-key .tag { margin-left: 6px; }
#efWords details { margin-bottom: 12px; }
#efWords summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
#efWords .words .input, .words-table .input, .rule-table .input { height: 30px; }

/* a rule's table */
.rule-wrap { max-height: 50vh; }
.rule-table td { padding: 3px 4px; }
.rule-table td.cell-num { width: 96px; }
.rule-table .c-actions .btn { padding: 0 8px; }
.expr .input { flex: 1; min-width: 180px; }
.expr-result { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 700; white-space: nowrap; }
#efProblems .problems { margin: 8px 0; max-height: none; }

/* the live preview */
#edPreview { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
#edPreview .raw { max-width: 220px; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.lang-h { font-size: 11.5px; font-weight: 800; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.preview-grid .kv { margin: 6px 0 10px; }
.err-text { color: var(--err); }

/* the translations */
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .narrow { width: auto; min-width: 200px; flex: 0 1 auto; }
.words-table td:first-child { max-width: 260px; }
.words-table .num { white-space: nowrap; }

/* the file's properties */
.file-props { max-width: 640px; }
.file-props code { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- dialogs */
.dlg { border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 12px; padding: 22px 24px 20px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dlg.wide { width: min(720px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(20, 30, 45, .45); }
.dlg h2 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.dlg-text { color: var(--text-2); margin-bottom: 14px; }
.dlg .check { margin: 4px 0 10px; }
.dlg-result { max-height: 40vh; overflow: auto; margin-top: 10px; }
.dlg-result:empty { display: none; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .two, .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  main { padding: 16px 12px 40px; }
  .vt .c-actions { white-space: normal; }
  .table-card.tall { max-height: 50vh; }
  .words { grid-template-columns: 1fr; gap: 4px; margin-bottom: 14px; }
  .words .words-key { margin-top: 6px; }
  .preview-grid { grid-template-columns: 1fr; }
  .toolbar .narrow { min-width: 0; flex: 1 1 100%; }
  .dlg { padding: 18px 16px 16px; }
}

/* a phone: the brand and the sign-out on the first line of the top bar, the view tabs on a second */
@media (max-width: 600px) {
  .top { flex-wrap: wrap; height: auto; min-height: 54px; padding: 0 12px; gap: 0 10px; }
  .brand { height: 54px; }
  .tabs { order: 10; flex-basis: 100%; margin-top: -8px; }
  .tabs button { height: 40px; padding: 0 10px; }
  body.signed-out .top { min-height: 54px; }
}
