/* NeoCom — base styles: tokens, app shell and the shared components every view uses.
   Tuned for the Galaxy Z Fold: narrow cover screen + near-square inner screen (body.wide, >= 700px).
   View-specific styles live in tasks.css and views.css. */
:root {
  --bg: #0b0f14;
  --surface: #131a22;
  --surface-2: #19222c;
  --line: #243140;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #a78bfa;
  --accent-ink: #160a33;
  --warn: #fbbf24;
  --danger: #f87171;
  --good: #4ade80;
  --radius: 16px;
  --gutter: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --line: #d8dee5;
    --text: #0f1720; --muted: #5b6774; --accent: #6d28d9; --accent-ink: #ffffff;
    --warn: #b45309; --danger: #dc2626; --good: #15803d;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Samsung Sans", sans-serif;
  font-variant-numeric: tabular-nums;
  overflow: hidden; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; width: 100%; outline: none; min-width: 0;
}
textarea { resize: vertical; min-height: 44px; line-height: 1.4; display: block; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: .8; }
.muted { color: var(--muted); }
.neg { color: var(--danger); }
.pos { color: var(--good); }
.warn { color: var(--warn); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.ico { width: 22px; height: 22px; flex: none; display: block; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 28px; height: 28px; }
.ico.xl { width: 44px; height: 44px; }

/* ---------- shell ---------- */
#shell { height: 100dvh; display: flex; flex-direction: column; }
#topbar { flex: none; padding-top: var(--safe-t); }
.topbar-row { display: flex; align-items: center; gap: 10px; padding: 8px var(--gutter) 6px; }
.brand { font-weight: 700; letter-spacing: .2px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.offline { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); text-align: center; font-size: 12.5px; padding: 5px; }

/* #view and #detail are the scroll containers. Sticky offsets inside them are measured from the padding edge,
   so a sticky header in #view needs top: -4px, and a sticky footer in #detail bottom: calc(-20px - var(--safe-b)).
   tasks.css and views.css rely on these paddings; change them together. */
#panes { flex: 1; min-height: 0; display: flex; }
#view { flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px var(--gutter) 28px; }
#detail { display: none; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--gutter) calc(20px + var(--safe-b)); }

/* narrow: the open task covers the screen */
body:not(.wide).task-open #detail {
  display: block; position: fixed; inset: 0; z-index: 10; background: var(--bg);
  padding-top: var(--safe-t); animation: slide-in .18s cubic-bezier(.2,.8,.2,1);
}
/* wide: list on the left, the open task on the right */
body.wide #panes { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); width: 100%; max-width: 1280px; margin: 0 auto; }
body.wide #detail { display: block; border-left: 1px solid var(--line); }
body.anon #panes { display: flex; }
body.anon #detail { display: none; }

.detail-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 8px 0; background: var(--bg);
}
body.wide .detail-head [data-act="back"] { display: none; }
.detail-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); opacity: .7; }

/* tabs: bottom bar on narrow, in the top bar on wide */
#nav {
  flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
#nav:empty { display: none; }
#nav button { padding: 8px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; }
#nav button.on, .top-tabs button.on { color: var(--accent); }
.tab-ico { position: relative; display: grid; place-items: center; }
.tab-ico .badge { position: absolute; top: -5px; left: 13px; }
.top-tabs { flex: 1; display: flex; justify-content: center; gap: 4px; }
.top-tabs button { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 12px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.top-tabs button.on { background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; }
.top-tabs .ico { width: 19px; height: 19px; }
.top-tabs .tab-ico:has(.badge) { margin-right: 10px; }   /* keep the badge off the label */

/* ---------- shared components ---------- */
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line);
}
.icon-btn.plain { background: none; border-color: transparent; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; color: #0b0f14; font-size: 13px; flex: none; background: var(--muted); }
.avatar.sm { width: 20px; height: 20px; font-size: 10.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: 16px; }
.avatar-pair { display: inline-flex; flex: none; }
.avatar-pair .avatar + .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg); }
.avatar-btn { border-radius: 50%; display: grid; }
/* a new version was deployed and this page could not reload by itself (something was being typed) */
.update-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}

.primary {
  min-height: 50px; padding: 0 16px; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 16px; width: 100%;
}
.primary:disabled { opacity: .35; }
.secondary {
  min-height: 46px; padding: 0 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; width: 100%;
}
.danger-btn { min-height: 46px; padding: 0 14px; border-radius: 14px; width: 100%; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); font-weight: 600; }
.text-btn { color: var(--accent); font-weight: 600; font-size: 13.5px; padding: 6px 4px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; padding: 6px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.chip.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.chip .ico { width: 15px; height: 15px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 7px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line) inset; }
.badge {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

/* round tick box: tasks, sub-tasks, bought parts. Add .sq for a square one. */
.check {
  appearance: none; -webkit-appearance: none; width: 24px; height: 24px; margin: 0; flex: none; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--muted); display: inline-grid; place-items: center; background: none;
}
.check.sq { border-radius: 7px; }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after {
  content: ""; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}

.section-h { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 8px; }
.section-h h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.item:first-child { border-top: 0; }
.item .mid { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 12.5px; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
.field label, .field .label { font-size: 12.5px; color: var(--muted); }
.err { color: var(--danger); font-size: 13.5px; min-height: 18px; }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; overscroll-behavior: contain; background: var(--bg);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 8px var(--gutter) calc(18px + var(--safe-b)); animation: up .2s cubic-bezier(.2,.8,.2,1);
}
.sheet.full { height: 92dvh; display: flex; flex-direction: column; }
body.wide .sheet-backdrop { align-items: center; }
body.wide .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); max-height: 86dvh; }
body.wide .sheet.full { height: 86dvh; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; flex: none; }
.sheet h3 { margin: 2px 0 12px; font-size: 19px; }
.sticky-foot { position: sticky; bottom: calc(-18px - var(--safe-b)); background: var(--bg); padding: 10px 0 4px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); z-index: 30;
  background: var(--text); color: var(--bg); border-radius: 14px; padding: 11px 14px; font-weight: 600;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  /* centred with left: 50%, so without this its shrink-to-fit width is half the screen and it wraps early */
  width: max-content; max-width: calc(100% - 28px);
}
body.wide #toast { bottom: 24px; }
#toast[hidden] { display: none; }
#toast button { color: #6d28d9; font-weight: 800; }
@media (prefers-color-scheme: light) { #toast button { color: #c4b5fd; } }

/* ---------- login ---------- */
.login { max-width: 360px; width: 100%; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }

@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
