/* Family Kanban Board.
   Dark is default (evening kitchen phone). Light is data-theme="light" on <html>.
   Phone breakpoint 900px: columns become swipe pages; .topbar shrinks; More is a sheet.
   Do not add a CSS framework — tokens here are the design system.
*/
:root {
  --bg: #1a1d23;
  --surface: #21252b;
  --card: #282c34;
  --border: #2d3139;
  --text: #e1e4e8;
  --text-dim: #8b949e;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --priority-high: #ef4444;
  --priority-med: #f59e0b;
  --priority-low: #10b981;
  --danger: #ef4444;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 20px rgba(0, 0, 0, 0.22);
  --radius: 10px;
  --radius-card: 14px;
  --ease-snap: 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-dim: #6b7280;
  --text-muted: #9ca3af;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 18px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.board-switch-wrap select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.85rem;
  max-width: 180px;
}
.auth-error { color: var(--danger); }
.auth-tabs { margin: 12px 0; }
.google-btn { width: 100%; margin-top: 8px; }
.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
}
.skip-link:focus {
  left: 8px;
}
.muted { color: var(--text-dim); font-size: 0.85rem; }

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  transition: background var(--ease-snap), border-color var(--ease-snap), transform var(--ease-snap);
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; padding: 4px 8px; }
.btn.danger { background: #7f1d1d; border-color: #991b1b; color: #fff; }
.btn.small { font-size: 0.75rem; padding: 2px 6px; }

.server-banner, .alert-banner {
  padding: 8px 16px;
  font-size: 0.9rem;
}
.server-banner { background: #7f1d1d; color: #fff; }
.alert-banner { background: #422006; color: #fde68a; position: sticky; top: 0; z-index: 40; }
.alert-banner a { color: #fde68a; cursor: pointer; text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}
.topbar h1 { margin: 0; font-size: 1.25rem; min-width: 0; }
.topbar-left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  align-items: start;
  min-height: calc(100vh - 180px);
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 1400px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .board { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .board { grid-template-columns: 1fr; }
}

.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.column-blocked { overflow-y: auto; max-height: calc(100vh - 160px); }
.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.column-header h2 { margin: 0; font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.header-btns { display: flex; gap: 4px; }
.count-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.quick-add {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 48px;
  min-width: 0;
  flex: 1;
}
.task-list.section-auto { flex: 0 0 auto; min-height: 24px; }
.task-list.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }

.blocked-stack { display: flex; flex-direction: column; gap: 8px; }
.blocked-section.holding, .blocked-section.planning {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.section-label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--radius-card);
  padding: 12px 12px 10px;
  cursor: grab;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: transform var(--ease-snap), box-shadow var(--ease-snap), border-color var(--ease-snap);
  min-width: 0;
  max-width: 100%;
}
.card.priority-high { border-left-color: var(--priority-high); }
.card.priority-medium { border-left-color: var(--priority-med); }
.card.priority-low { border-left-color: var(--priority-low); }
.card.focused { outline: 2px solid var(--accent); outline-offset: 1px; }
.card.selected { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-card); }
.card.has-select { padding-left: 30px; }
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 40px 6px 0;
  min-width: 0;
  max-width: 100%;
}
.card-title {
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.3;
  margin: 0;
  flex: 1;
  min-width: 0;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.card-id {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.72rem;
  margin: 2px 0 0;
  flex: 0 0 auto;
  opacity: 0.7;
}
.card-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 80%, var(--surface));
  border: 1px solid var(--border);
  color: var(--text-dim);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-chip.due { color: var(--text); }
.meta-chip.overdue, .card-meta .overdue {
  color: #fecaca;
  border-color: color-mix(in srgb, var(--priority-high) 45%, var(--border));
  background: color-mix(in srgb, var(--priority-high) 18%, var(--card));
}
.meta-chip.due-soon, .card-meta .due-soon {
  color: #fde68a;
  border-color: color-mix(in srgb, var(--priority-med) 40%, var(--border));
}
.meta-chip.stale { color: var(--priority-high); }
.who-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  padding: 1px 8px 1px 2px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
}
.who-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-chip.compact { padding: 0; border: 0; background: transparent; }
.who-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.card-progress {
  height: 3px;
  border-radius: 999px;
  background: var(--bg);
  margin-top: 8px;
  overflow: hidden;
}
.card-progress > div {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; min-width: 0; max-width: 100%; }
.card-desc {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text-dim);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.composer-desc {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag-pill {
  border: none;
  color: #fff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-actions {
  position: absolute;
  top: 8px;
  right: 6px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2px;
  z-index: 2;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--ease-snap), transform var(--ease-snap);
}
.card:hover .card-actions,
.card:focus-within .card-actions,
.card.menu-open .card-actions { opacity: 1; transform: none; }
.card-actions button { padding: 0 4px; line-height: 1.2; border-radius: 8px; }
.card-menu {
  position: absolute;
  top: 30px;
  right: 0;
  min-width: 108px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 9;
  box-shadow: var(--shadow);
}
.card-menu.hidden { display: none; }
.card-menu button { width: 100%; text-align: left; padding: 7px 10px; }
.card.menu-open { z-index: 8; }
.sparkline { display: block; margin-top: 6px; }
.select-check {
  position: absolute;
  left: 8px;
  top: 10px;
  width: 16px;
  height: 16px;
}

.below-board { padding: 0 16px 80px; }
.below-board details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.stack-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.stack-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.stack-row > * { min-width: 0; overflow-wrap: anywhere; }

.batch-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  z-index: 50;
}
.batch-bar input, .batch-bar select, .modal input, .modal select, .modal textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}

.notices-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 280px;
  min-width: 220px;
  min-height: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 45;
  resize: both;
  overflow: auto;
}
.notices-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  cursor: move;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.notice-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
.notice-item {
  margin: 8px;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: flex-start;
}
.notice-item.blue { background: #1e3a5f; }
.notice-item.orange { background: #7c4a03; }
.notice-item.red { background: #7f1d1d; }
.notice-item.green { background: #14532d; }
.notice-item.purple { background: #4c1d95; }
[data-theme="light"] .notice-item.blue { background: #dbeafe; color: #1e3a8a; }
[data-theme="light"] .notice-item.orange { background: #ffedd5; color: #9a3412; }
[data-theme="light"] .notice-item.red { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .notice-item.green { background: #dcfce7; color: #166534; }
[data-theme="light"] .notice-item.purple { background: #ede9fe; color: #5b21b6; }
.notice-item input { flex: 1; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 80;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 12px;
  overflow: auto;
}
.overlay.active { display: flex; padding-bottom: var(--kb, 0px); }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  width: min(640px, 100%);
  box-shadow: var(--shadow);
}
.modal-wide { width: min(860px, 100%); }
.modal {
  max-height: calc(100vh - 48px);
  overflow: auto;
}
.modal h2 { margin-top: 0; }
#edit-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 6px;
  font-weight: 700;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
#edit-form label, .modal label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; margin-bottom: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.checks label { flex-direction: row; align-items: center; gap: 6px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 10px;
}
.detail-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 0.9rem; }
.notes-md { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.notes-md a { color: var(--accent); }
.dropzone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  margin-top: 8px;
}
.att-row, .link-row, .ref-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  min-width: 0;
  max-width: 100%;
}
.att-row span, .link-row a, .ref-row input {
  min-width: 0;
  max-width: 100%;
}
.ref-block { margin: 10px 0; }
.help-list { line-height: 1.5; padding-left: 18px; }
.help-table { width: 100%; border-collapse: collapse; }
.help-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.help-table td:first-child, .help-table td:nth-child(2) { font-family: ui-monospace, Consolas, monospace; width: 70px; }

.spotlight { align-items: flex-start; padding-top: 12vh; }
.spotlight-box { width: min(720px, 100%); }
#spotlight-input {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
#spotlight-results { margin-top: 8px; background: var(--surface); border-radius: 10px; overflow: hidden; }
.spot-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.spot-item span { min-width: 0; overflow-wrap: anywhere; }
.spot-item.active, .spot-item:hover { background: var(--card); }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 700px) { .metric-grid { grid-template-columns: 1fr 1fr; } }
.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.metric-card .num { font-size: 1.6rem; font-weight: 700; }
.chart { margin: 16px 0; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.85rem; }
.bar-label { width: 110px; color: var(--text-dim); }
.bar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }
.trend { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.trend-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.trend-bar { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 4px; }
.trend-label { font-size: 0.7rem; color: var(--text-muted); }

code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.identity {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.identity-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 32px;
  line-height: 1;
  max-width: 100%;
  min-width: 0;
}
.identity-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-chip:hover { color: var(--text); }
.identity-chip.active {
  background: var(--person, var(--accent));
  color: #fff;
}
.identity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.identity-chip.active .identity-dot {
  background: #fff;
}
.view-filter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.view-chip {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 32px;
}
.view-chip.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 12px 0;
}
.week-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 7px;
  min-height: 64px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
}
.week-day.today { outline: 2px solid var(--accent); }
.week-day-label { font-size: 0.68rem; color: var(--text-muted); }
.week-day-num { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.week-chip {
  display: block;
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.week-chip.event { color: #93c5fd; }
.week-chip.more { color: var(--text-dim); font-weight: 600; }
.today-home { display: none; }
body.needs-identity #board,
body.needs-identity #week-strip,
body.needs-identity #today-home,
body.needs-identity .below-board,
body.needs-identity .notices-panel,
body.needs-identity #column-tabs,
body.needs-identity .ios-hint,
body.needs-identity #alert-banner {
  display: none !important;
}
[data-theme="light"] .week-chip.event { color: #1d4ed8; }
[data-theme="light"] .meta-chip.overdue,
[data-theme="light"] .card-meta .overdue {
  color: #991b1b;
  background: #fee2e2;
}
[data-theme="light"] .meta-chip.due-soon,
[data-theme="light"] .card-meta .due-soon {
  color: #92400e;
  background: #fef3c7;
}
.btn:focus-visible,
.identity-chip:focus-visible,
.week-day:focus-visible,
.view-chip:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.toast-host {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 240;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  pointer-events: auto;
}
.toast.error { border-color: var(--danger); }
.toast .btn { margin-left: auto; }
.topbar-actions { position: relative; }
.more-actions {
  display: none;
  position: fixed;
  z-index: 120;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.more-actions.open { display: flex; }
.more-actions .btn { justify-content: flex-start; width: 100%; }
body.is-loading .board,
body.is-loading .week-strip { opacity: 0.4; pointer-events: none; }
.empty-hint {
  margin: 8px 4px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.who-field { margin: 10px 0; }
.who-field > span { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 6px; }
.who-field .identity,
.welcome-people {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  border-radius: 16px;
}
#edit-more { margin: 14px 0 0; }
#edit-more summary {
  cursor: pointer;
  color: var(--text-dim);
  font-weight: 600;
  list-style: none;
}
#edit-more summary::-webkit-details-marker { display: none; }
#edit-more summary::after {
  content: "▸";
  display: inline-block;
  margin-left: 8px;
  transition: transform var(--ease-snap);
}
#edit-more[open] summary::after { transform: rotate(90deg); }
.composer-title-wrap { margin: 0 0 14px; }
.composer-title {
  width: 100%;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  border: 0 !important;
  background: transparent !important;
  padding: 4px 0 10px !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
}
.composer-title:focus {
  outline: none;
  border-bottom-color: var(--accent) !important;
}
.composer-block { margin: 0 0 14px; }
.composer-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.seg, .due-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}
.seg.wrap { width: auto; max-width: 100%; }
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 9px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
  transition: background var(--ease-snap), color var(--ease-snap);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.seg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.seg-row > span {
  min-width: 64px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.due-fields { margin-top: 8px; }
.prop-toggles { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chip-toggle {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
}
.chip-toggle:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg));
}
.composer-section {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.composer-section h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-chip {
  border: 0;
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.chip-input {
  width: 100%;
}
.stack-editor { display: flex; flex-direction: column; gap: 6px; }
.checklist-row { align-items: center; }
.check-line {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  flex: 1;
}
.check-line .sub-text { flex: 1; }
.who-field #f-owner-extra { width: 100%; margin-top: 8px; }
.detail-head h2 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.detail-head .card-id { margin: 0 0 4px; display: block; }
.modal.modal-wide { width: min(720px, 100%); }

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  }
}

@media (prefers-reduced-motion: reduce) {
  .card, .btn, .seg-btn, .card-actions { transition: none; }
}
.welcome-people { margin-top: 12px; }
#day-body h3 {
  font-size: 0.85rem;
  margin: 12px 0 6px;
  color: var(--text-dim);
}
.week-day { position: relative; }
.week-add {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.day-item {
  display: block;
  width: 100%;
  max-width: 100%;
  text-align: left;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.sparkline { display: none; }
.person-dot {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.people-add, .person-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.person-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.person-key-wrap {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
input.person-key {
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 0.85rem;
  width: 100%;
  min-height: 44px;
  word-break: break-all;
}
@media (max-width: 900px) {
  .identity { flex: 0 0 auto; }
}
.column-tabs, .ios-hint { display: none; }
.sheet-choices { display: flex; flex-direction: column; gap: 8px; }
.sheet-choice {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: calc(10px + env(safe-area-inset-top));
}
input, select, textarea { font-size: 16px; }
.quick-add { font-size: 16px; min-height: 44px; }
.btn { min-height: 36px; }
.select-check { width: 22px; height: 22px; }

body.more-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 110;
}
body.dragging {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.drag-ghost {
  position: fixed;
  z-index: 220;
  pointer-events: none;
  width: min(280px, 72vw);
  opacity: 0.95;
  transform: rotate(2deg) scale(1.03);
  box-shadow: var(--shadow);
}
.card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
.card.lifted { opacity: 0.35; }

.move-dock {
  display: none;
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 210;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  box-shadow: var(--shadow);
  flex-direction: column;
  gap: 8px;
}
.move-dock p { margin: 0 0 4px; font-size: 0.8rem; color: var(--text-dim); text-align: center; }
.dock-row { display: flex; gap: 6px; }
.dock-row button {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}
.dock-row button.hot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.move-dock:not(.hidden) { display: flex; }
.mobile-only { display: none; }
.desktop-only { display: inline-flex; align-items: center; }
.project-kids { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: 0; }
.project-kids a { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .mobile-only { display: inline-flex; align-items: center; }
  .desktop-only { display: none !important; }
  .card-actions { opacity: 1; transform: none; }
  .card-head { margin-right: 0; }
  .week-strip { min-width: 0; max-width: 100%; }
  .week-day { min-height: 56px; padding: 4px; min-width: 0; overflow: hidden; }
  .week-chip { font-size: 0.58rem; }
  .more-actions {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    top: auto;
    z-index: 120;
    max-width: none;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    box-shadow: var(--shadow);
    flex-direction: column;
  }
  .more-actions.open {
    display: flex;
    max-height: min(60vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .more-actions .btn { min-height: 44px; width: 100%; justify-content: center; }
  .column-tabs {
    display: flex;
    position: sticky;
    top: calc(52px + env(safe-area-inset-top));
    z-index: 25;
    background: var(--bg);
    padding: 8px 8px 0;
    gap: 4px;
    overflow-x: auto;
  }
  .tab-btn {
    flex: 1 0 auto;
    min-width: 0;
    min-height: 40px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    border-radius: 999px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
  }
  .tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .tab-btn span {
    display: inline-block;
    min-width: 1.2em;
    margin-left: 2px;
    opacity: 0.9;
  }
  .ios-hint {
    display: block;
    margin: 6px 12px 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
  }
  .today-home {
    display: none;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    flex: 1;
  }
  .today-home h2 { margin: 0 0 8px; font-size: 1.1rem; }
  .today-home h3 { margin: 16px 0 8px; font-size: 0.85rem; color: var(--text-muted); }
  body.phone-today .today-home { display: block; }
  body.phone-today .board { display: none; }
  body.phone-today .ios-hint { display: none; }
  .board {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    padding: 8px 0 24px;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100dvh - 150px);
    height: calc(100svh - 150px);
  }
  .column {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    min-height: 0;
    max-height: none;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .column-blocked { max-height: none; overflow-x: hidden; overflow-y: auto; }
  .task-list, .blocked-stack { min-width: 0; max-width: 100%; }
  .task-list { min-height: 80px; }
  .card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    padding: 12px;
    border-radius: 12px;
  }
  .card-head, .card-meta, .card-progress, .card-tags, .card-desc {
    grid-column: 1;
    min-width: 0;
    max-width: 100%;
  }
  .card-title { margin-right: 0; font-size: 1.02rem; }
  .card-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    position: static;
    top: auto;
    right: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .card-menu {
    right: 8px;
    top: auto;
  }
  .card-actions button {
    min-width: 44px;
    min-height: 44px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
  }
  .sparkline { display: none; }
  .overlay {
    padding: 0;
    align-items: flex-end;
    -webkit-overflow-scrolling: touch;
  }
  .overlay.active {
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: var(--kb, 0px);
    overflow: hidden;
  }
  .spotlight { align-items: flex-start; padding-top: calc(12px + env(safe-area-inset-top)); overflow: auto; }
  .modal, .modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Leave a dim strip above the sheet so a tap outside still closes it. */
  .overlay[data-dismiss="backdrop"] > .modal {
    max-height: calc(100% - 48px);
  }
  #edit-modal, #detail-modal {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #edit-form.composer, #detail-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #edit-modal .modal-actions,
  #detail-modal .detail-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex-shrink: 0;
    margin-top: 8px;
    padding-bottom: 4px;
    background: var(--surface);
  }
  .form-grid { grid-template-columns: 1fr; }
  .seg, .due-presets { width: 100%; }
  .seg-btn, .chip-toggle, .identity-chip, .view-chip {
    min-height: 44px;
  }
  #edit-more summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .modal input, .modal select, .modal textarea,
  .composer-title, .chip-input, #f-owner-extra, .composer-desc {
    min-height: 44px;
    max-width: 100%;
  }
  .composer-title { font-size: 1.2rem; }
  .modal::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    background: var(--border);
    border-radius: 99px;
    margin: 4px auto 12px;
  }
  .detail-actions {
    flex-direction: column;
  }
  .detail-actions > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .detail-actions .btn, .modal-actions .btn, #d-add-child {
    min-height: 44px;
    flex: 1 1 calc(50% - 8px);
  }
  .detail-grid { grid-template-columns: 1fr; }
  .notices-panel {
    left: 10px;
    right: 10px;
    width: auto;
    min-width: 0;
    min-height: 0;
    bottom: calc(10px + env(safe-area-inset-bottom));
    resize: none;
    max-height: 36vh;
  }
  .notices-titlebar { cursor: default; min-height: 44px; }
  .below-board { padding: 0 12px calc(96px + env(safe-area-inset-bottom)); }
  .batch-bar {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .batch-bar input, .batch-bar select { min-height: 44px; font-size: 16px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .help-table { font-size: 0.85rem; table-layout: fixed; width: 100%; }
  .help-table td { word-break: break-word; }
  .bar-label { width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .person-row, .people-add { max-width: 100%; }
  .person-name, .people-add input { min-width: 0; max-width: 100%; min-height: 44px; }
  .person-row .btn, .people-add .btn { min-height: 44px; }
  .cal-header h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .cal-day { min-width: 0; overflow: hidden; }
  .cal-toolbar .btn { min-height: 44px; }
}

@media (max-width: 900px) {
  html, body { overflow: hidden; height: 100%; height: 100dvh; max-width: 100%; }
  body {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .topbar h1 {
    font-size: 0.95rem;
    line-height: 1.25;
    max-width: min(100%, 11rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-left .muted { display: none; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .board-switch-wrap select { max-width: min(140px, 42vw); }
  .week-strip { gap: 4px; padding: 6px 8px 0; min-width: 0; }
  .week-chip { font-size: 0.62rem; color: var(--text); }
  .board {
    flex: 1;
    min-height: 0;
    height: auto;
  }
  .below-board {
    flex: 0 0 auto;
    max-height: 20vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  }
  .notices-panel {
    max-height: 28vh;
  }
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cal-header h2 { margin: 0; flex: 1; text-align: center; }
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-dow {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}
.cal-day {
  min-height: 88px;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
}
.cal-day.dim { opacity: 0.45; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day-num { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; }
.cal-chip {
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 0.68rem;
  text-align: left;
  padding: 2px 5px;
  cursor: pointer;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-chip.event { background: #2563eb; }
.cal-chip.task { background: #d97706; }
.cal-legend { margin-top: 8px; }
@media (max-width: 900px) {
  .cal-day { min-height: 64px; }
  .cal-chip { font-size: 0.62rem; }
}

