/* DisplaySweet Agenda — all styles live here. Design tokens first (Kirby's spec, 19 Nov 2026). */
:root {
  --font-head: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* grays */
  --bg: #FFFFFF;
  --bg-soft: #F7F7F7;
  --bg-hover: #F2F2F2;
  --ink: #111111;        /* text */
  --ink-2: #666666;      /* secondary */
  --ink-3: #999999;      /* meta */
  --line: #E6E6E6;       /* hairlines */
  --line-strong: #D0D0D0;

  /* primary = solid #111; magenta only for small accents */
  --primary: #111111;
  --primary-ink: #FFFFFF;
  --accent: #FF2E8A;     /* active tab underline, focus ring, checked circle, quick-add + */
  --danger: #D1343B;
  --overdue: #D1343B;
  --focus: 0 0 0 2px #FFFFFF, 0 0 0 4px var(--accent);

  --radius: 12px;
  --radius-btn: 8px;
  --radius-sm: 6px;
  --gap: 12px;
  --pad: 16px;
  --tap: 44px;
  --maxw: 1180px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 40px rgba(0,0,0,.12);

  /* one fixed tag palette: pastel fill, dark same-hue text */
  --tag-grey-bg: #EDEDED;   --tag-grey-fg: #444444;
  --tag-red-bg: #FBE1E1;    --tag-red-fg: #8E2323;
  --tag-orange-bg: #FCE8D5; --tag-orange-fg: #8A4410;
  --tag-yellow-bg: #FAF0C8; --tag-yellow-fg: #6B5500;
  --tag-green-bg: #DDF1E2;  --tag-green-fg: #1F6B35;
  --tag-blue-bg: #DDE9FA;   --tag-blue-fg: #1F4E8C;
  --tag-purple-bg: #EAE1F7; --tag-purple-fg: #563A8A;
  --tag-pink-bg: #FADDEB;   --tag-pink-fg: #8C2459;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font-body); font-weight: 400; font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); text-transform: uppercase; margin: 0; color: var(--ink); }
h1 { font-size: 15px; font-weight: 600; letter-spacing: .04em; line-height: 20px; }
h2 { font-size: 12px; font-weight: 600; letter-spacing: .08em; }
h3 { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-btn);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-weight: 500; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.primary:hover { background: #2a2a2a; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: var(--tap); padding: 0 12px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: var(--tap); height: var(--tap); min-width: var(--tap); border: 0; background: transparent; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex: none; padding: 0;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- inputs ---------- */
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn); background: var(--bg); font-size: 16px; /* 16px stops iOS zoom */
}
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { outline: none; border-color: var(--ink); }
label.field { display: grid; gap: 6px; min-width: 0; }
label.field > span { font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-head); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: var(--gap); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 26px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; margin: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(16px); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-btn); padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; min-height: var(--tap); padding: 0 16px; border-radius: 6px; font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.pill { min-height: var(--tap); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 2px; padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left)); min-height: 56px; }
.topbar h1 { flex: 1; min-width: 0; padding: 0 6px; max-height: 40px; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; } /* 2 lines, then ellipsis */
.brand-home { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 10px; }
.brand-logo { display: block; width: auto; }
.brand-home .brand-logo { height: 20px; }
.topbar .spacer { flex: 1; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; flex: none;
}
main { max-width: var(--maxw); margin: 0 auto; padding: 12px max(var(--pad), env(safe-area-inset-right)) calc(48px + var(--safe-b)) max(var(--pad), env(safe-area-inset-left)); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0 14px; }
.banner { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 24px calc(24px + var(--safe-b)); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.login-card .brand-logo { height: 28px; margin-bottom: 6px; }
.login-card h1 { font-size: 18px; letter-spacing: .1em; }
.login-card .lede { color: var(--ink-2); margin: 0; }
.login-card .dev { border-top: 1px solid var(--line); padding-top: 18px; display: grid; gap: 12px; }
.tag-dev { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--tag-yellow-bg); color: var(--tag-yellow-fg); letter-spacing: .06em; text-transform: uppercase; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.error:empty { display: none; }

/* ---------- project list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; min-height: var(--tap); padding: 0 10px; font-family: var(--font-head); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li a { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 64px; }
.plist li a:hover { background: var(--bg-soft); }
.plist .pname { font-size: 16px; line-height: 22px; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.plist .pmeta { font-size: 12px; color: var(--ink-3); }
.badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; flex: none; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty p { margin: 0 0 12px; }

/* ---------- sections & tasks ---------- */
.section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; min-height: var(--tap); border-bottom: 1px solid var(--ink); margin: 0; padding: 0; }
.section-head .collapse-btn { margin-left: -12px; }
.section-head > .icon-btn:last-child { margin-right: -10px; }
.section-head .caret { display: inline-flex; transition: transform .15s; }
.section-head .caret svg { width: 18px; height: 18px; }
.section.collapsed .caret { transform: rotate(-90deg); }
.section-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: pointer; padding: 12px 0; }
.section-head .count { font-family: var(--font-body); font-size: 12px; color: var(--ink-3); padding: 0 4px; }
.section.collapsed .tasks, .section.collapsed .quick-add, .section.collapsed .thead { display: none; }
.section.drop-target .section-head { background: var(--bg-soft); }

.tasks { list-style: none; margin: 0; padding: 0; min-height: 4px; }
.task { position: relative; display: flex; align-items: flex-start; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 56px; background: var(--bg); }
.task:hover { background: var(--bg-soft); }
.task .title { font-size: 16px; line-height: 22px; color: var(--ink); overflow-wrap: anywhere; }
.task.done .title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.task.done .chips { opacity: .55; }
.task.drop-before { box-shadow: inset 0 2px 0 var(--ink); }
.task.dragging { opacity: .35; }
.drag-ghost { position: fixed; z-index: 70; pointer-events: none; background: var(--bg); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 15px; max-width: 80vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
body.is-dragging, body.is-dragging * { user-select: none; -webkit-user-select: none; cursor: grabbing !important; }

/* 44px hit area, 22px visual circle */
.check-hit { width: var(--tap); height: var(--tap); flex: none; display: inline-flex; align-items: center; justify-content: center; margin: -5px -6px -5px -12px; cursor: pointer; }
.check { appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); margin: 0; flex: none; cursor: pointer; position: relative; background: var(--bg); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ''; position: absolute; left: 6.5px; top: 2.5px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check:disabled { cursor: default; border-color: #CCCCCC; background: #F4F4F4; pointer-events: none; }
.check:disabled:checked { background: #CCCCCC; border-color: #CCCCCC; }
.check-hit:has(.check:disabled) { pointer-events: none; cursor: default; }
/* grip: full 44x44 hit area, never overlapping the complete circle. Phone: right end of the row. Desktop: left. */
.grip { width: var(--tap); height: var(--tap); flex: none; display: inline-flex; align-items: center; justify-content: center; color: #999999; touch-action: none; cursor: grab; border: 0; background: none; padding: 0; margin: -5px -10px -5px 0; order: 3; border-radius: var(--radius-sm); }
.grip:hover { background: var(--bg-hover); }
.grip svg { width: 16px; height: 16px; }
.task .body { flex: 1; min-width: 0; display: grid; gap: 4px; padding: 6px 0 4px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-family: var(--font-body); font-size: 12px; font-weight: 500; line-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--tag-grey-bg); color: var(--tag-grey-fg); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.initials { background: var(--ink); color: #fff; padding: 0 6px; min-width: 22px; text-align: center; font-weight: 600; }
.chip.due { background: transparent; color: var(--ink-2); padding: 0 2px; }
.chip.due.today, .due-text.today { color: var(--ink); font-weight: 700; }
.chip.due.overdue { color: var(--overdue); box-shadow: inset 0 0 0 1px var(--overdue); padding: 0 8px; }
.due-text.overdue { color: var(--overdue); box-shadow: inset 0 0 0 1px var(--overdue); padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 20px; display: inline-block; }
.chip.note { background: transparent; color: var(--ink-3); padding: 0; }
.t-grey   { background: var(--tag-grey-bg);   color: var(--tag-grey-fg); }
.t-red    { background: var(--tag-red-bg);    color: var(--tag-red-fg); }
.t-orange { background: var(--tag-orange-bg); color: var(--tag-orange-fg); }
.t-yellow { background: var(--tag-yellow-bg); color: var(--tag-yellow-fg); }
.t-green  { background: var(--tag-green-bg);  color: var(--tag-green-fg); }
.t-blue   { background: var(--tag-blue-bg);   color: var(--tag-blue-fg); }
.t-purple { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.t-pink   { background: var(--tag-pink-bg);   color: var(--tag-pink-fg); }

.quick-add { display: flex; gap: 0; align-items: center; min-height: var(--tap); }
.quick-add .plus { color: var(--accent); font-size: 18px; width: 32px; text-align: center; flex: none; font-weight: 500; }
.quick-add input { flex: 1; min-width: 0; border: 0; background: transparent; min-height: var(--tap); padding: 0 4px; font-size: 16px; color: var(--ink); }
.quick-add input::placeholder { color: var(--ink-3); font-size: 14px; }
.quick-add input:focus { outline: none; }
.add-section { display: flex; align-items: center; gap: 6px; border: 0; background: none; min-height: var(--tap); padding: 0; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.add-section .plus { color: var(--accent); font-size: 18px; }
.thead { display: none; }

/* ---------- desktop table (>= 900px) ---------- */
@media (min-width: 900px) {
  main { padding-left: 24px; padding-right: 24px; }
  /* the project view is its own scroller so wide tables scroll sideways and the header can stick */
  main.grid { max-width: none; height: calc(100vh - 57px - env(safe-area-inset-top)); height: calc(100dvh - 57px - env(safe-area-inset-top)); overflow: auto; overscroll-behavior: contain; }
  main.grid > * { max-width: calc(var(--maxw) - 48px); margin-left: auto; margin-right: auto; min-width: var(--minw); }
  .grid .thead, .grid .task { display: grid; grid-template-columns: var(--cols); align-items: center; gap: 0 12px; }
  .grid .thead { position: sticky; top: 0; z-index: 3; background: var(--bg); font-family: var(--font-head); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; color: var(--ink-2); padding: 8px 0; border-bottom: 1px solid var(--line); }
  .grid .thead > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid .thead > :first-child { padding-left: 88px; }
  .grid .task { min-height: 48px; padding: 2px 0; }
  .grid .task .chips { display: none; }
  .grid .task .body { padding: 0 0 0 4px; }
  .grid .task .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
  .grid .cell { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .grid .first { display: flex; align-items: center; gap: 0; min-width: 0; }
  .grid .grip { order: 0; margin: 0; }
  .grid .check-hit { margin: 0; }
  .grid .task:not(:has(.grip)) .first { padding-left: 44px; }
}
@media (max-width: 899px) { .grid .cell { display: none; } .grid .first { display: contents; } }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; box-shadow: var(--shadow); }
.sheet-head { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px max(6px, env(safe-area-inset-right)) 6px max(var(--pad), env(safe-area-inset-left)); border-bottom: 1px solid var(--line); flex: none; }
.head-title-wrap { flex: 1; min-width: 0; display: flex; }
.head-title-view { flex: 1; min-width: 0; min-height: var(--tap); text-align: left; font-size: 17px; line-height: 24px; font-weight: 500; border: 0; background: transparent; padding: 8px 4px; border-radius: var(--radius-sm); color: var(--ink);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
button.head-title-view { cursor: text; }
button.head-title-view:hover { background: var(--bg-soft); }
.sheet-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet-head .head-title { flex: 1; min-width: 0; font-size: 17px; line-height: 24px; font-weight: 500; border: 0; padding: 8px 4px; border-radius: var(--radius-sm); background: transparent; resize: none; overflow-y: auto; max-height: 96px; }
.sheet-head .head-title:hover { background: var(--bg-soft); }
.sheet-head .head-title:focus { outline: none; background: var(--bg-soft); }
.sheet-scroll { overflow: auto; overscroll-behavior: contain; padding: 14px max(var(--pad), env(safe-area-inset-right)) calc(24px + var(--safe-b)) max(var(--pad), env(safe-area-inset-left)); }
@media (min-width: 700px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 16px; max-height: 86vh; }
}
.actions { display: grid; gap: 8px; }
.actions .btn { justify-content: flex-start; }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
input[type=date].input { display: block; min-width: 0; max-width: 100%; width: 100%; -webkit-appearance: none; appearance: none; }
.fields .full { grid-column: 1 / -1; }
.notes-log { list-style: none; margin: 0; padding: 0; }
.notes-log li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-log .note-meta { color: var(--ink-3); font-size: 12px; margin-right: 2px; font-variant-numeric: tabular-nums; }
.notes-log .icon-btn { margin: -10px -10px -10px 0; color: var(--ink-3); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.member .em { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.tagcol { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid transparent; background-clip: content-box; padding: 6px; }
.opt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 4px; }
.opt { display: inline-flex; align-items: center; }
.opt .opt-remove { color: var(--ink-3); margin-left: -6px; }
.opt .opt-remove svg { width: 16px; height: 16px; }
.swatch[aria-pressed="true"] { border-color: var(--ink); }
.foot-note { font-size: 12px; color: var(--ink-3); margin: 0; }

#toast { pointer-events: none; position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-btn); font-size: 14px; z-index: 80; max-width: calc(100vw - 32px); }
