:root {
  --bg: #F5F1EA;
  --surface: #FFFFFF;
  --surface-2: #EFEAE1;
  --ink: #1E1D1B;
  --ink-2: #6B665E;
  --ink-3: #A39D93;
  --line: #E4DED3;
  --accent: #17B3B0;          /* turcoaz Wonderland */
  --accent-strong: #0C8C89;   /* turcoaz mai închis: text și butoane cu text alb (contrast) */
  --accent-ink: #FFFFFF;
  --accent-soft: #D5F3F2;
  --p1: #0C8C89;          /* primul membru */
  --p2: #E0612F;          /* al doilea membru */
  --p3: #7A5AC8;
  --ok: #2E9A5B;
  --ok-soft: #DDF1E4;
  --later: #3A6FD8;
  --later-soft: #DFE8FB;
  --danger: #C8402E;
  --warn: #B9541F;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .06);
  --radius: 16px;
  --tabs-h: 60px;
  --quick-h: 64px;
  /* Edge-to-edge (viewport-fit=cover, Chrome 135+): pagina ajunge sub bara de gesturi Android.
     --safe-b = zona de gesturi acum; --safe-max-b = cea mai mare valoare posibilă (fixă, fără salturi). */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-max-b: env(safe-area-max-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171A;
    --surface: #1F2024;
    --surface-2: #2A2B30;
    --ink: #F1EEE8;
    --ink-2: #A9A59D;
    --ink-3: #6E6A64;
    --line: #2E2F34;
    --accent: #3CD0CC;
    --accent-strong: #3CD0CC;
    --accent-ink: #0B2B2A;
    --accent-soft: #123D3C;
    --p1: #1E9E9B;
    --p2: #F07443;
    --ok: #46B874;
    --ok-soft: #173525;
    --later: #6B95F0;
    --later-soft: #1A2742;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ───────────── structură ───────────── */

#main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(var(--tabs-h) + var(--quick-h) + var(--safe-max-b) + 24px);
}
body.typing #main { padding-bottom: calc(var(--quick-h) + 80px); }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 4px 16px; }
.head h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.02em; margin: 0; font-weight: 750; }
.head .sub { color: var(--ink-2); font-size: 15px; margin-top: 4px; }
.head .back { display: inline-flex; align-items: center; gap: 2px; color: var(--ink-2); text-decoration: none; font-size: 15px; margin-bottom: 6px; }

.ring { --p: 0; width: 46px; height: 46px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; }
.ring span { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--ink-2); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px;
  font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.section { margin-top: 22px; }
.section > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 6px 8px;
  display: flex; justify-content: space-between; align-items: center; font-weight: 650; }
.section > h2 .count { font-weight: 500; letter-spacing: 0; text-transform: none; }
.section.overdue > h2 { color: var(--warn); }
.section > h2 button { background: none; border: 0; color: var(--ink-2); font-size: 13px; text-transform: none; letter-spacing: 0; padding: 4px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

/* ───────────── task ───────────── */

.task { position: relative; touch-action: pan-y; user-select: none; }
.task + .task .task-body { border-top: 1px solid var(--line); }
.task-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  font-weight: 650; font-size: 14px; opacity: 0; }
.task-bg .l { color: var(--ok); } .task-bg .r { color: var(--later); }
.task.swiping .task-bg { opacity: 1; }
.task.swipe-right .task-bg { background: var(--ok-soft); }
.task.swipe-left .task-bg { background: var(--later-soft); }
.task.swipe-right .task-bg .r, .task.swipe-left .task-bg .l { visibility: hidden; }
.task-body { position: relative; background: var(--surface); display: flex; align-items: center; gap: 12px;
  padding: 13px 14px 13px 12px; min-height: 56px; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.task.dragging .task-body { transition: none; }

.check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink-3); background: none;
  display: grid; place-items: center; padding: 0; position: relative; }
.check::after { content: ""; position: absolute; inset: -10px; }
.check svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.done .check svg { opacity: 1; }
.task.done .title { color: var(--ink-3); text-decoration: line-through; }
.task.pop .check { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }

.task-main { flex: 1; min-width: 0; }
.title { font-size: 16px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 13px; color: var(--ink-2); }
.meta:empty { display: none; }
.meta .late { color: var(--warn); font-weight: 600; }
.meta .time { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meta .note-dot::before { content: "✎ "; }

.av { flex: none; width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center; }
.av.sm { width: 20px; height: 20px; font-size: 10px; }
.av.both { background: var(--surface-2); color: var(--ink-2); }

.timed .title { font-weight: 550; }

/* zile următoare */
.day-head { font-size: 14px; font-weight: 650; color: var(--ink); padding: 12px 14px 4px; }
.day-head small { color: var(--ink-3); font-weight: 500; margin-left: 6px; }

.empty { text-align: center; color: var(--ink-2); padding: 38px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty b { color: var(--ink); display: block; font-size: 17px; margin-bottom: 4px; }

.more { width: 100%; background: none; border: 0; padding: 14px; color: var(--ink-2); font-size: 14px; text-align: left; }

/* ───────────── liste ───────────── */

.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.list-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-decoration: none;
  color: inherit; display: flex; flex-direction: column; gap: 14px; min-height: 118px; }
.list-card .emoji { font-size: 28px; line-height: 1; }
.list-card .name { font-weight: 650; font-size: 16px; }
.list-card .n { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.list-card.add { border: 2px dashed var(--line); background: none; box-shadow: none; align-items: center; justify-content: center;
  color: var(--ink-2); font-weight: 600; gap: 6px; }

.icon-btn { background: var(--surface); border: 0; width: 40px; height: 40px; border-radius: 50%; box-shadow: var(--shadow);
  display: grid; place-items: center; color: var(--ink-2); }

/* ───────────── adăugare rapidă ───────────── */

#quick { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 20;
  padding: 8px 12px 10px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
body.typing #quick { bottom: 0; padding-bottom: calc(10px + var(--safe-b)); }
.quick-row { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: center;
  background: var(--surface); border-radius: 999px; box-shadow: 0 2px 14px rgba(40,30,10,.12); padding: 5px 5px 5px 18px;
  border: 1px solid var(--line); }
#quick-input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; padding: 9px 0; }
#quick-input::placeholder { color: var(--ink-3); }
#quick-send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; transition: transform .15s; }
#quick-send:active { transform: scale(.92); }
#quick-preview { max-width: 640px; margin: 0 auto 8px; display: flex; gap: 6px; flex-wrap: wrap; padding: 0 6px; }
#quick-preview:empty { display: none; }
.pchip { border: 0; border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-strong); display: inline-flex; align-items: center; gap: 5px; }
.pchip.list { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); }
.pchip.sugg { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.pchip.off { opacity: .45; text-decoration: line-through; }

/* ───────────── bara de jos ───────────── */

/* Rețeta Chrome pentru edge-to-edge: bara are mereu înălțimea maximă (fundalul ei ajunge până la marginea
   fizică a ecranului, sub bara de gesturi), iar `bottom` o coboară cu diferența, fără relayout. */
#tabs { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) - var(--safe-max-b));
  z-index: 21; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-max-b); height: calc(var(--tabs-h) + var(--safe-max-b)); }
body.typing #tabs { display: none; }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); text-decoration: none; font-size: 11.5px; font-weight: 600; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#tabs a.on { color: var(--ink); }
#tabs a.on svg { stroke-width: 2.3; }

/* ───────────── toast ───────────── */

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--quick-h) + var(--safe-b) + 12px); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 10px 10px 16px; font-size: 14px;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--accent-strong); font-weight: 700; padding: 4px 8px; }

/* ───────────── foaie (bottom sheet) ───────────── */

dialog#sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh;
  background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,.2); }
@media (min-width: 700px) { dialog#sheet { margin: auto; max-width: 520px; border-radius: 22px; } }
dialog#sheet[open] { animation: up .24s cubic-bezier(.2,.8,.2,1); }
dialog#sheet::backdrop { background: rgba(10, 8, 5, .38); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-in { padding: 10px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 2px; }
.sheet-in h3 { margin: 0; font-size: 19px; }
.sheet-title { width: 100%; border: 0; outline: 0; background: none; font-size: 20px; font-weight: 600; resize: none; padding: 4px 0; }
.field-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-weight: 650; margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 9px 13px; font-size: 14.5px;
  display: inline-flex; align-items: center; gap: 7px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input[type="date"], .seg input[type="time"] { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 10px; font-size: 14.5px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: 0; }
.input:focus { border-color: var(--ink-2); }
textarea.input { min-height: 74px; resize: vertical; }
.row-actions { display: flex; gap: 10px; }
.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 650; font-size: 16px; background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--accent-strong); color: var(--accent-ink); flex: 1; }
.btn.danger { background: none; color: var(--danger); }
.btn.block { width: 100%; }

/* ───────────── setări ───────────── */

.settings .card { padding: 4px 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row .lbl { font-weight: 550; }
.set-row .hint { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.set-row input[type="time"] { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px 9px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--surface-2); border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.code { font: 700 22px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; }
.link-btn { background: none; border: 0; color: var(--accent-strong); font-weight: 650; padding: 6px 0; }

.banner { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.banner p { margin: 0; flex: 1; font-size: 14.5px; }
.banner .btn { padding: 9px 14px; font-size: 14px; background: var(--accent-strong); color: var(--accent-ink); }
.banner .x { background: none; border: 0; color: var(--ink-2); font-size: 20px; padding: 0 4px; }

.offline { text-align: center; font-size: 13px; color: var(--ink-2); padding: 6px; margin: -10px 0 10px; }

/* ───────────── autentificare ───────────── */

#auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.auth-box h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
.auth-box p.lead { color: var(--ink-2); margin: 0 0 24px; }
.auth-box form { display: flex; flex-direction: column; gap: 10px; }
.auth-box .btn { margin-top: 6px; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--ink-2); font-size: 15px; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; }
.grab:focus { outline: none; }

