/* DayBoard — mobile-first design system for daily planning.
   Calm, focused, large touch targets, one-handed use.
   Shares its DNA with the SnapInspect / MailMate apps in this repo. */

:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --line: #e3e3ea;
  --line-strong: #c8c8d2;
  --ink: #191922;
  --ink-2: #52525e;
  --ink-3: #8a8a98;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #ffffff;
  --pri-high: #e11d48;
  --pri-normal: #6366f1;
  --pri-low: #94a3b8;
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 54px;
  --nav-h: 64px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05), 0 6px 16px rgba(0,0,0,0.05);
  --maxw: 560px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html[data-theme='dark'] {
  --bg: #0c0c11;
  --surface: #17171d;
  --surface-2: #1f1f27;
  --line: #2a2a33;
  --line-strong: #3a3a46;
  --ink: #f5f5f8;
  --ink-2: #b6b6c2;
  --ink-3: #7e7e8c;
  --accent-soft: #1d1d33;
  --accent-ink: #ffffff;
  --pri-high: #fb7185;
  --pri-normal: #818cf8;
  --pri-low: #64748b;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 6px 18px rgba(0,0,0,0.35);
}

/* ---- palettes (retint accent) ------------------------------------------- */
html[data-palette='indigo']    { --accent: #4f46e5; --accent-soft: #eef0ff; }
html[data-theme='dark'][data-palette='indigo']    { --accent: #818cf8; --accent-ink: #0b0b1a; --accent-soft: #1d1d33; }
html[data-palette='violet']    { --accent: #7c3aed; --accent-soft: #f3ecff; }
html[data-theme='dark'][data-palette='violet']    { --accent: #a78bfa; --accent-ink: #14071f; --accent-soft: #241433; }
html[data-palette='amber']     { --accent: #d97706; --accent-soft: #fff3df; }
html[data-theme='dark'][data-palette='amber']     { --accent: #fbbf24; --accent-ink: #1f1402; --accent-soft: #2a1f08; }
html[data-palette='teal']      { --accent: #0d9488; --accent-soft: #e2f6f3; }
html[data-theme='dark'][data-palette='teal']      { --accent: #2dd4bf; --accent-ink: #042420; --accent-soft: #082b27; }
html[data-palette='rose']      { --accent: #e11d48; --accent-soft: #ffe9ee; }
html[data-theme='dark'][data-palette='rose']      { --accent: #fb7185; --accent-ink: #2a060f; --accent-soft: #2e0c14; }
html[data-palette='contrast']  { --accent: #000000; --accent-soft: #f0f0f0; --line: #000; --line-strong: #000; --ink-2: #000; }
html[data-theme='dark'][data-palette='contrast'] { --accent: #fff; --accent-ink: #000; --accent-soft: #1a1a1a; --line: #fff; --line-strong: #fff; --ink-2: #fff; }

* { box-sizing: border-box; }

button, a, .btn, .chip, .iconbtn, input, select, textarea,
.tab, .check, .seg, .swatch, .color-dot, .menu-item, .toggle, .date-label {
  touch-action: manipulation;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
  line-height: 1.45;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

/* ---- app bar ------------------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar-title { flex: 1; text-align: center; min-width: 0; }
.appbar h1 { font-size: 1.2rem; margin: 0; letter-spacing: -0.01em; }
.bar-title .sub { font-size: 0.72rem; color: var(--ink-3); font-weight: 600; }
.brandmark {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; flex: none;
}
.iconbtn {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.15rem;
}
.iconbtn.sm { width: 38px; height: 38px; border-radius: 10px; font-size: 1rem; }
.iconbtn:active { transform: scale(0.95); }

/* ---- layout -------------------------------------------------------------- */
.screen {
  padding: 16px 14px calc(var(--nav-h) + var(--safe-b) + 24px);
  display: flex; flex-direction: column; gap: 14px;
  animation: rise 0.18s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section-label {
  font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 700; margin: 8px 2px -2px;
}
.muted { color: var(--ink-3); }
.sm { font-size: 0.8rem; }
.grow { flex: 1; min-width: 0; }
.desc { color: var(--ink-3); font-size: 0.82rem; }

/* ---- cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}

/* ---- buttons ------------------------------------------------------------- */
.btn {
  min-height: var(--tap);
  border-radius: 13px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--pri-high); border-color: var(--pri-high); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.sm { min-height: 44px; font-size: 0.88rem; padding: 0 12px; border-radius: 10px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ---- inputs -------------------------------------------------------------- */
input[type='text'], input[type='number'], input[type='date'], input[type='time'],
input[type='tel'], input[type='email'], input[type='search'], textarea, select {
  width: 100%; min-height: var(--tap);
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--surface); color: var(--ink);
  padding: 11px 13px; font-size: 1rem; font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; color: var(--ink-2); font-weight: 600; flex: 1; }
.field-row { display: flex; gap: 10px; }

/* ---- chips --------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chips { padding: 2px 0; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: 7px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pri-chip .pri-dot { width: 9px; height: 9px; }

/* ---- empty state --------------------------------------------------------- */
.empty { text-align: center; color: var(--ink-3); padding: 44px 16px; }
.empty .ico { font-size: 2.4rem; display: block; margin-bottom: 10px; opacity: 0.85; }
.empty .title { font-weight: 700; color: var(--ink-2); font-size: 1.05rem; }
.empty .sub { font-size: 0.85rem; margin-top: 4px; }

/* ---- date selector (Today) ---------------------------------------------- */
.date-bar { display: flex; align-items: center; gap: 10px; }
.date-label {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  border-radius: 13px; padding: 8px 12px; cursor: pointer; text-align: center;
  color: var(--ink); min-height: var(--tap);
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
}
.date-label:active { transform: scale(0.99); }
.dl-main { font-weight: 800; font-size: 1.02rem; }
.dl-sub { font-size: 0.74rem; color: var(--ink-3); font-weight: 600; }

/* ---- task list / rows ---------------------------------------------------- */
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; min-height: 52px;
}
.task-row:last-child { border-bottom: 0; }
.task-row .t-main { flex: 1; min-width: 0; }
.t-title { font-weight: 600; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; }
.t-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.t-due, .t-list { font-size: 0.72rem; color: var(--ink-3); font-weight: 600; }
.t-list { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.task-row.done .t-title { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }

.check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--surface);
  color: #fff; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; font-size: 0.85rem; font-weight: 800;
}
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check:active { transform: scale(0.9); }

.pri-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--pri-normal); display: inline-block; }
.pri-dot.pri-high { background: var(--pri-high); }
.pri-dot.pri-normal { background: var(--pri-normal); }
.pri-dot.pri-low { background: var(--pri-low); }

/* quick-add row */
.quick-row {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px;
}
.qa-plus { color: var(--accent); font-weight: 800; font-size: 1.3rem; width: 18px; text-align: center; flex: none; }
.quick-add { min-height: 44px; border: 1px dashed var(--line-strong); background: var(--surface-2); }

/* ---- schedule timeline --------------------------------------------------- */
.timeline { position: relative; margin-top: 4px; }
.tl-hour {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid var(--line); cursor: pointer;
}
.tl-hour:active { background: var(--surface-2); }
.tl-label {
  position: absolute; left: 0; top: -8px;
  font-size: 0.68rem; color: var(--ink-3); font-weight: 700;
  background: var(--surface); padding-right: 6px;
}
.tl-block {
  position: absolute; left: 52px; right: 4px;
  border-radius: 9px; padding: 4px 9px; overflow: hidden; cursor: pointer;
  color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  background: var(--c, #6366f1); border-left: 3px solid rgba(255,255,255,0.55);
}
.tl-block:active { transform: scale(0.99); }
.blk-title { font-size: 0.82rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-time { font-size: 0.66rem; opacity: 0.9; font-weight: 600; }
.tl-now {
  position: absolute; left: 46px; right: 0; height: 2px;
  background: var(--pri-high); z-index: 3;
}
.tl-now::before {
  content: ''; position: absolute; left: 0; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--pri-high);
}

/* block / list color tints (set --c for use in .tl-block + dots) */
.block-indigo { --c: #6366f1; }
.block-violet { --c: #8b5cf6; }
.block-sky    { --c: #0ea5e9; }
.block-teal   { --c: #14b8a6; }
.block-amber  { --c: #f59e0b; }
.block-rose   { --c: #f43f5e; }

/* color picker dots (modals) */
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: var(--c, #6366f1);
  box-shadow: inset 0 0 0 2px var(--surface);
}
.color-dot.on { border-color: var(--ink); }

/* ---- lists management (settings) ---------------------------------------- */
.list-rows { display: flex; flex-direction: column; gap: 2px; }
.list-row { display: flex; align-items: center; gap: 11px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* ---- segmented + swatches + toggle (settings) --------------------------- */
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg { flex: 1; min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.seg.on { background: var(--accent); color: var(--accent-ink); }
.swatch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; color: var(--ink-2); font-size: 0.72rem; font-weight: 600; }
.swatch .dot { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); }
.swatch.on { border-color: var(--accent); color: var(--ink); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; }
.set-row .label { font-weight: 600; }

.toggle {
  width: 50px; height: 30px; border-radius: 999px; border: 0; flex: none;
  background: var(--line-strong); cursor: pointer; position: relative;
  transition: background 0.18s ease;
}
.toggle.on { background: var(--accent); }
.toggle .knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.18s ease;
}
.toggle.on .knob { transform: translateX(20px); }

/* ---- bottom navigation --------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: var(--surface);
  border-top: 1px solid var(--line); z-index: 30;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; font-size: 0.66rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tab .ico { font-size: 1.3rem; line-height: 1; }
.tab.on { color: var(--accent); }
.tab.on .ico { transform: translateY(-1px); }

/* ---- toast --------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 80; max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- modal --------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); width: 100%; max-width: var(--maxw);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  box-shadow: var(--shadow); animation: rise 0.2s ease;
  max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { margin: 4px 0 6px; }
.modal .field { width: 100%; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal .modal-actions .btn { flex: 1; }

/* ---- footer -------------------------------------------------------------- */
.brand-foot { text-align: center; color: var(--ink-3); font-size: 0.72rem; padding: 12px 0 4px; }
