:root {
    color-scheme: light;
    --bg: #f4f4f2;
    --surface: #fcfcfb;
    --surface-2: #ecebe7;
    --line: #dddcd6;
    --text: #1a1a19;
    --text-2: #52514e;
    --muted: #7a7973;
    --accent: #2a78d6;
    --accent-ink: #ffffff;
    --danger: #c0392b;
    --ok: #0a7d0a;
    --a-3: #b8302f; --a-2: #e34948; --a-1: #f0a3a2; --a0: #c9c8c3; --a1: #86b6ef; --a2: #3987e5; --a3: #1c5cab;
    --ink-3: #fff; --ink-2: #fff; --ink-1: #1a1a19; --ink0: #1a1a19; --ink1: #1a1a19; --ink2: #fff; --ink3: #fff;
    --radius: 12px;
    --nav-h: 60px;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #121211;
        --surface: #1a1a19;
        --surface-2: #262624;
        --line: #33332f;
        --text: #f2f2ef;
        --text-2: #c3c2b7;
        --muted: #8f8e86;
        --accent: #3987e5;
        --danger: #e66767;
        --ok: #3fbf3f;
        --a-3: #f08a8a; --a-2: #e66767; --a-1: #8c4241; --a0: #55544f; --a1: #2c5a92; --a2: #3987e5; --a3: #86b6ef;
        --ink-3: #1a1a19; --ink-2: #1a1a19; --ink-1: #fff; --ink0: #fff; --ink1: #fff; --ink2: #fff; --ink3: #1a1a19;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #262624; --line: #33332f;
    --text: #f2f2ef; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5; --danger: #e66767; --ok: #3fbf3f;
    --a-3: #f08a8a; --a-2: #e66767; --a-1: #8c4241; --a0: #55544f; --a1: #2c5a92; --a2: #3987e5; --a3: #86b6ef;
    --ink-3: #1a1a19; --ink-2: #1a1a19; --ink-1: #fff; --ink0: #fff; --ink1: #fff; --ink2: #fff; --ink3: #1a1a19;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; color: var(--text-2); font-weight: 600; }
.splash { display: grid; place-items: center; min-height: 100vh; font-size: 3rem; color: var(--muted); }

/* Ecranul se acopera cand aplicatia iese din vedere (ca miniatura din lista de aplicatii sa nu arate nimic). */
body.veil #app > * { visibility: hidden; }
body.veil #app::after { content: ""; position: fixed; inset: 0; background: #fff; z-index: 50; }
body.veil nav.tabs { visibility: hidden; }

/* ---------- blocare ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate form { width: min(320px, 100%); display: grid; gap: 14px; text-align: center; }
.gate .mark { font-size: 2.6rem; color: var(--muted); }
.gate input { text-align: center; letter-spacing: .1em; }
.err { color: var(--danger); min-height: 1.4em; font-size: .9rem; }

/* ---------- cadru ---------- */
.shell { padding: 12px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(4px + env(safe-area-inset-top)) 0 10px; }
header.top h1 { font-size: 1.15rem; }
.pending { font-size: .8rem; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
nav.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
    height: var(--nav-h); border: 0; background: none; color: var(--muted);
    display: grid; place-content: center; gap: 2px; font-size: .72rem;
}
nav.tabs button b { font-size: 1.25rem; font-weight: 500; line-height: 1; }
nav.tabs button[aria-current="page"] { color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack { display: grid; gap: 10px; }

label.f { display: grid; gap: 4px; font-size: .85rem; color: var(--text-2); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn { min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn.link { background: none; border: 0; color: var(--accent); padding: 6px 4px; min-height: 0; }
.btn:disabled { opacity: .5; }

/* ---------- formularul de replica ---------- */
.scale { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.scale button {
    border: 2px solid transparent; border-radius: 10px; min-height: 58px; padding: 4px 0;
    display: grid; place-content: center; gap: 1px; font-weight: 700; font-size: 1.05rem;
}
.scale button small { font-weight: 500; font-size: .62rem; line-height: 1.1; }
.scale button[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
.scale button:not([aria-pressed="true"]) { opacity: .75; }
.scale.chosen button:not([aria-pressed="true"]) { opacity: .35; }
.a-3 { background: var(--a-3); color: var(--ink-3); } .a-2 { background: var(--a-2); color: var(--ink-2); }
.a-1 { background: var(--a-1); color: var(--ink-1); } .a0 { background: var(--a0); color: var(--ink0); }
.a1 { background: var(--a1); color: var(--ink1); } .a2 { background: var(--a2); color: var(--ink2); }
.a3 { background: var(--a3); color: var(--ink3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
    padding: 7px 12px; min-height: 36px; font-size: .9rem;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.add { border-style: dashed; color: var(--muted); }
.group { display: grid; gap: 8px; }
.group > h3 { display: flex; justify-content: space-between; align-items: baseline; }
.conv { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.savebar { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 4px; }
.savebar .btn.primary { min-height: 52px; font-size: 1.05rem; }
details > summary { cursor: pointer; color: var(--text-2); padding: 6px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

/* ---------- jurnal ---------- */
.day { margin-bottom: 18px; }
.day > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.dot { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 8px; font-weight: 700; font-size: .85rem; }
.entry { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.entry:first-of-type { border-top: 0; }
.entry .meta { font-size: .9rem; }
.entry .meta .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.entry .words { font-size: .88rem; color: var(--text-2); margin-top: 2px; }
.convhead { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.daynote { font-size: .88rem; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }

/* ---------- tipare ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .78rem; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--text-2); stroke-width: 1; }
.chart .hit { fill: transparent; }
.bars { display: grid; gap: 2px; }
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 64px; align-items: center; gap: 8px; font-size: .86rem; min-height: 30px; }
.bar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bar .val small { color: var(--muted); }
.bar svg { width: 100%; height: 18px; display: block; }
.insight { font-size: .92rem; padding-left: 18px; margin: 6px 0 0; }
.insight li { margin-bottom: 4px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--text-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

#tip {
    position: fixed; z-index: 30; pointer-events: none; display: none;
    background: var(--text); color: var(--bg); font-size: .8rem; padding: 6px 9px; border-radius: 8px; max-width: 240px;
}
#toast {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom));
    background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .92rem;
    opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 40; max-width: calc(100% - 32px);
}
#toast.on { opacity: 1; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: 90vh; background: var(--bg); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .inner { padding: 16px; display: grid; gap: 12px; }
pre.preview { white-space: pre-wrap; font-size: .78rem; max-height: 50vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0; }
.taglist { display: grid; gap: 4px; }
.tagrow { display: grid; grid-template-columns: 1fr auto auto auto; gap: 4px; align-items: center; font-size: .9rem; }
.tagrow.off span { color: var(--muted); text-decoration: line-through; }
.chart .pos, .bar .pos { fill: var(--a2); }
.chart .neg, .bar .neg { fill: var(--a-2); }
.chart .neu { fill: var(--a0); }
.bar .cnt { fill: var(--text-2); }
.bar .zero { stroke: var(--line); stroke-width: 2; }
.legend .lg-pos { background: var(--a2); }
.legend .lg-neg { background: var(--a-2); }
[hidden] { display: none !important; }
@media (min-width: 760px) { nav.tabs { left: 50%; right: auto; width: 720px; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; } }
a.btn { text-decoration: none; display: inline-flex; align-items: center; color: var(--text); }
.entry { grid-template-columns: auto 1fr auto; }
.entry .del { align-self: start; border: 1px solid transparent; background: none; border-radius: 8px; min-width: 40px; min-height: 36px; padding: 4px 8px; font-size: .95rem; color: var(--muted); }
.entry .del.armed { border-color: var(--danger); color: var(--danger); font-size: .82rem; font-weight: 600; }
#toast.act { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
#toast button { border: 0; background: none; color: var(--bg); font-weight: 700; text-decoration: underline; padding: 4px 2px; }
.conv { margin-bottom: 4px; }
.savebar + .row { margin-top: 18px; margin-bottom: 6px; }
.entry .del { color: var(--text-2); font-size: 1.05rem; }
.day > header .del { border: 1px solid transparent; background: none; border-radius: 8px; min-width: 40px; min-height: 36px; padding: 4px 8px; font-size: 1.05rem; color: var(--text-2); }
.day > header .del.armed { border-color: var(--danger); color: var(--danger); font-size: .82rem; font-weight: 600; }
.gate .install { margin-top: 18px; }
/* Ecranul alb: alb in orice tema, fara nimic de vazut sau de selectat. */
html:has(body.blank), body.blank { background: #fff !important; }
body.blank #toast, body.blank #tip { display: none !important; }
.blank-pad { position: fixed; inset: 0; z-index: 60; background: #fff; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.keypad-demo { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.keypad-demo span { display: grid; place-items: center; height: 30px; border: 1px dashed var(--line); border-radius: 6px; font-size: .85rem; color: var(--text-2); }
html.blank, html.blank body { overscroll-behavior: none; background: #fff !important; }
.blank-pad { touch-action: none; }
.practice-digit { position: fixed; transform: translate(-50%, -50%); font-size: 2.4rem; font-weight: 700; color: #2a78d6; pointer-events: none; }
.practice-zone { position: fixed; transform: translate(-50%, -50%); font-size: 1.4rem; color: #d6d5cf; pointer-events: none; }
.practice-zone.r0 { top: 12.5%; } .practice-zone.r1 { top: 37.5%; } .practice-zone.r2 { top: 62.5%; } .practice-zone.r3 { top: 87.5%; }
.practice-zone.c0 { left: 16.67%; } .practice-zone.c1 { left: 50%; } .practice-zone.c2 { left: 83.33%; }
.practice-bar { position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; gap: 10px; align-items: center; font-size: .8rem; color: #52514e; background: #f4f4f2; border-radius: 12px; padding: 6px 8px 6px 12px; width: max-content; max-width: calc(100% - 24px); }
.practice-bar .btn { color: #1a1a19; background: #ecebe7; }
/* Campul invizibil care aduce tastatura numerica; 16px ca iOS sa nu faca zoom. */
.blank-kb { -webkit-user-select: text; user-select: text; touch-action: auto; position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; margin: 0; font-size: 16px; color: transparent; caret-color: transparent; background: transparent; outline: none; }
