/* ==========================================================================
   GYST styles
   Everything you might want to adjust — colors, spacing, fonts, rounding — is in the
   variables right below. The light set comes first; the dark set follows the device's dark mode.
   ========================================================================== */

:root {
  /* Fonts */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --text-size: 15px;
  --text-size-small: 13px;
  --title-size: 22px;

  /* Spacing (a 4px scale) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Sizes and rounding */
  --sidebar-width: 240px;
  --column-width: 280px;
  --details-width: 400px;
  --radius: 8px;
  --radius-small: 6px;

  /* Light colors */
  --bg: #ffffff;
  --bg-sidebar: #f6f6f4;
  --bg-column: #f3f3f1;
  --bg-card: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-selected: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-quiet: #6e6e73;
  --text-faint: #a1a1a6;
  --border: rgba(0, 0, 0, 0.09);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-raised: 0 8px 28px rgba(0, 0, 0, 0.16);
  --focus: #3478f6;
  --danger: #d1372e;
  --progress-track: rgba(0, 0, 0, 0.07);
  --progress-height: 3px;

  /* Badges (Carry over day counter) */
  --badge-text: #ffffff;
  --badge-warn: #e8830c;   /* soft orange: 1–2 days */
  --badge-alert: #e0352b;  /* red: 3 days or more */

  /* Area colors */
  --area-blue: #3478f6;
  --area-green: #34a853;
  --area-orange: #f08c00;
  --area-purple: #8e5bd8;
  --area-red: #e5484d;
  --area-teal: #12a594;
  --area-yellow: #d4a500;
  --area-gray: #8a8a8e;

  /* The current area's color (set per board) */
  --area: var(--text-faint);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-sidebar: #161618;
    --bg-column: #232325;
    --bg-card: #2c2c2e;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-selected: rgba(255, 255, 255, 0.1);
    --text: #f2f2f2;
    --text-quiet: #a1a1a6;
    --text-faint: #6e6e73;
    --border: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-raised: 0 8px 28px rgba(0, 0, 0, 0.5);
    --focus: #5e9bff;
    --danger: #ff6961;
    --progress-track: rgba(255, 255, 255, 0.1);
    --badge-warn: #d9800f;
    --badge-alert: #e5463c;

    --area-blue: #5e9bff;
    --area-green: #4cc06a;
    --area-orange: #ffa53d;
    --area-purple: #a97ff0;
    --area-red: #ff6b6f;
    --area-teal: #2ec4b0;
    --area-yellow: #e8bf2a;
    --area-gray: #98989d;
  }
}

/* ---------- Basics ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-size);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

.quiet { color: var(--text-quiet); }
.small { font-size: var(--text-size-small); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  height: 100dvh;
}

.main {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-card);
  font-size: var(--text-size-small);
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { background: var(--bg-hover); }
.button.small { padding: 2px var(--space-2); }
.button.danger { color: var(--danger); }

.icon-button {
  border: none;
  background: none;
  color: var(--text-quiet);
  border-radius: var(--radius-small);
  padding: 2px var(--space-2);
  line-height: 1.2;
}
.icon-button:hover { background: var(--bg-hover); color: var(--text); }

.quiet-until-hover { opacity: 0; }
*:hover > .quiet-until-hover,
.quiet-until-hover:focus-visible { opacity: 1; }

.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot, var(--area));
}
.dot.big { width: 14px; height: 14px; }

.count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: var(--text-size-small);
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-4) var(--space-3);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.quick-add { margin-bottom: var(--space-4); }

.quick-add-input,
.add-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-card);
}
.quick-add-input:focus,
.add-input:focus {
  outline: none;
  border-color: var(--focus);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 6px var(--space-2);
  border: none;
  border-radius: var(--radius-small);
  background: none;
  text-align: left;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.current { background: var(--bg-selected); font-weight: 500; }
.nav-item.add { color: var(--text-quiet); }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-heading {
  margin: var(--space-4) var(--space-2) var(--space-1);
  color: var(--text-faint);
  font-size: var(--text-size-small);
  font-weight: 500;
}

.nav-areas { display: flex; flex-direction: column; gap: 2px; }
.nav-add { padding: 2px 0; }
.nav-spacer { flex: 1; min-height: var(--space-5); }

/* ---------- View headers ---------- */

.view-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
}

.view-title {
  font-size: var(--title-size);
  font-weight: 600;
}

.board-view .view-header {
  border-top: 3px solid var(--area);
}

.intro { padding: 0 var(--space-5); margin: 0 0 var(--space-4); }

/* ---------- Editing in place ---------- */

.editable { cursor: text; border-radius: 4px; }
.editable:hover { background: var(--bg-hover); }
.editable.placeholder { color: var(--text-faint); }

.editable-input {
  border: 1px solid var(--focus);
  border-radius: 4px;
  background: var(--bg-card);
  padding: 0 var(--space-1);
  min-width: 0;
}
.editable-input.view-title { width: 20ch; }

/* ---------- Board ---------- */

.board-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.board-scroll {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
  overflow-x: auto;
  min-height: 0;
}

.board {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  max-height: 100%;
}

.column {
  flex: none;
  width: var(--column-width);
  max-height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  background: var(--bg-column);
  border-radius: var(--radius);
}

.column-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-2);
  cursor: grab;
}
.column-title { font-weight: 600; }

.add-list {
  flex: none;
  width: var(--column-width);
  padding: var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-quiet);
  text-align: left;
}
button.add-list:hover { background: var(--bg-hover); }
.add-list.open { border-style: solid; }

/* ---------- Cards ---------- */

.cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: var(--space-2);
  overflow-y: auto;
  padding: 2px;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  user-select: none;
}
.card:hover { box-shadow: var(--shadow-card), inset 0 0 0 1px var(--border); }
.card.selected { box-shadow: inset 0 0 0 2px var(--focus); }
.card.done .card-title { color: var(--text-faint); text-decoration: line-through; }

.card-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.card-hints {
  display: flex;
  gap: var(--space-2);
  color: var(--text-faint);
  font-size: var(--text-size-small);
}
.card-hints:empty { display: none; }

.check {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--area, var(--focus));
  cursor: pointer;
}

.add-button,
.fold {
  border: none;
  background: none;
  color: var(--text-quiet);
  text-align: left;
  padding: var(--space-2);
  border-radius: var(--radius-small);
}
.add-button:hover,
.fold:hover { background: var(--bg-hover); }

.add-form { padding: var(--space-1) 2px; }

.done-cards { padding-top: 0; }

/* ---------- Inbox and other single-column views ---------- */

.list-view {
  overflow-y: auto;
  flex: 1;
  padding-bottom: var(--space-6);
}

.single-column {
  max-width: 640px;
  padding: 0 var(--space-5);
  display: flex;
  flex-direction: column;
}

/* ---------- Details panel ---------- */

.details {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--details-width);
  max-width: 100%;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5) var(--space-5);
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  z-index: 10;
}

.details-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.where {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  color: var(--text-quiet);
  font-size: var(--text-size-small);
}

.details-title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.details-title .check { margin-top: 7px; }

.title-input,
.notes-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: none;
  resize: none;
  padding: var(--space-1) var(--space-2);
}
.title-input { font-size: 18px; font-weight: 600; }
.notes-input { min-height: 4.5em; color: var(--text); }
.title-input:hover,
.notes-input:hover { border-color: var(--border); }
.title-input:focus,
.notes-input:focus { outline: none; border-color: var(--focus); }

.subs h3 {
  font-size: var(--text-size-small);
  color: var(--text-quiet);
  font-weight: 500;
  margin-bottom: var(--space-2);
  white-space: pre;
}

.sub-list { display: flex; flex-direction: column; }

.sub {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  border-radius: var(--radius-small);
  background: var(--bg);
}
.sub .check { margin: 0; }
.sub-title { flex: 1; min-width: 0; padding: 2px var(--space-1); }
.sub.done .sub-title { color: var(--text-faint); text-decoration: line-through; }

.grip {
  color: var(--text-faint);
  cursor: grab;
  font-size: 12px;
  letter-spacing: -2px;
  padding: 0 2px;
}

.details-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-size-small);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ---------- Menus and the chooser ---------- */

.menu {
  position: fixed;
  z-index: 30;
  min-width: 180px;
  padding: var(--space-1);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
}

.menu-item {
  display: block;
  width: 100%;
  padding: 6px var(--space-3);
  border: none;
  background: none;
  text-align: left;
  border-radius: var(--radius-small);
}
.menu-item:hover,
.menu-item:focus-visible { background: var(--bg-hover); outline: none; }
.menu-item.danger { color: var(--danger); }

.menu-label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  color: var(--text-quiet);
  font-size: var(--text-size-small);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: var(--space-1) var(--space-3) var(--space-2);
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--dot);
  padding: 0;
}
.swatch.current { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--dot); }

.chooser {
  width: min(360px, calc(100vw - 32px));
  max-height: 80vh;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}
.chooser::backdrop { background: rgba(0, 0, 0, 0.25); }
.chooser h2 { font-size: 17px; margin-bottom: var(--space-3); }
.chooser .button { margin-top: var(--space-4); }

.chooser-area {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-1);
  font-weight: 600;
}

.chooser-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 6px var(--space-3);
  border: none;
  border-radius: var(--radius-small);
  background: none;
  text-align: left;
}
.chooser-option:hover { background: var(--bg-hover); }
.chooser-option.current { color: var(--text-faint); }
.chooser-option.current::after { content: " (here now)"; }
.chooser-empty { margin: 0; padding: 2px var(--space-3); color: var(--text-faint); font-size: var(--text-size-small); }

/* ---------- Recently deleted and Backup ---------- */

.deleted-list {
  max-width: 640px;
  padding: 0 var(--space-5);
}

.deleted-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.deleted-text { flex: 1; min-width: 0; }

.backup-section {
  max-width: 640px;
  padding: 0 var(--space-5) var(--space-5);
}
.backup-section h2 { font-size: 17px; }

.load-error { padding: var(--space-5); color: var(--danger); }

/* ---------- Today ---------- */

.star {
  flex: none;
  border: none;
  background: none;
  padding: 0 2px;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1.2;
}
.star:hover { color: var(--text-quiet); }
.star.on { color: var(--area, var(--focus)); opacity: 1; }

.quick-add { display: flex; gap: var(--space-1); align-items: center; }
.quick-add-input { flex: 1; min-width: 0; }
.quick-today {
  flex: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-card);
  color: var(--text-faint);
  padding: 6px var(--space-2);
}
.quick-today.on { color: var(--focus); border-color: var(--focus); }

.today-date { margin-top: 4px; }
.today-section { margin-bottom: var(--space-5); }
.today-heading {
  font-size: var(--text-size-small);
  font-weight: 600;
  color: var(--text-quiet);
  margin: 0 0 var(--space-2);
}
.today-section.carry .today-heading { color: var(--text); }

.today-row { align-items: flex-start; }
.today-text { flex: 1; min-width: 0; }
.today-parents { color: var(--text-quiet); }
.today-source { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.day-badge {
  flex: none;
  align-self: flex-start;
  margin-top: 1px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.day-badge.warn { background: var(--badge-warn); }
.day-badge.alert { background: var(--badge-alert); }

.details-top { flex-wrap: wrap; }
.today-button.on { color: var(--area, var(--focus)); }

.sheet-today {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--text-size-small);
  color: var(--text-quiet);
}

/* ---------- Settings ---------- */

.settings-section {
  max-width: 640px;
  padding: 0 var(--space-5);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.setting-name { font-weight: 500; }
.setting-row select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-card);
}

/* ---------- Sync ---------- */

.sync-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
  background: none;
  padding: 6px var(--space-2);
  font-size: var(--text-size-small);
  color: var(--text-quiet);
  text-align: left;
  border-radius: var(--radius-small);
}
button.sync-status:hover { background: var(--bg-hover); }
.sync-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.sync-status.ok .sync-dot { background: #34a853; }
.sync-status.busy .sync-dot { background: var(--focus); }
.sync-status.warn .sync-dot { background: var(--badge-warn); }
.sync-status.error .sync-dot { background: var(--badge-alert); }
.sync-status.error { color: var(--danger); }

.sync-section p { margin: var(--space-2) 0; }
.sync-form { display: flex; flex-direction: column; gap: var(--space-3); max-width: 420px; margin-top: var(--space-3); }
.sync-field { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-size-small); color: var(--text-quiet); }
.sync-field input, .device-name {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-card);
  color: var(--text);
  font-size: var(--text-size);
}
.sync-field input:focus, .device-name:focus { outline: none; border-color: var(--focus); }
.sync-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sync-check { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-size-small); }
.sync-warning {
  padding: var(--space-3);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--badge-warn) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--badge-warn) 40%, transparent);
}
.sync-error { color: var(--danger); }
.sync-save-help ol { margin: var(--space-1) 0 0; padding-left: 1.2em; }
.sync-choices { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.button.primary { background: var(--focus); border-color: var(--focus); color: #fff; }
.button.primary:hover { filter: brightness(1.08); background: var(--focus); }
.button:disabled { opacity: 0.5; cursor: default; }

.replaced-note {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--badge-warn) 14%, transparent);
}
.link-button { border: none; background: none; padding: 0; color: var(--focus); font: inherit; text-decoration: underline; }
.replaced-list h3 { margin: var(--space-4) 0 0; }
.replaced-table { width: 100%; border-collapse: collapse; margin: var(--space-3) 0; font-size: var(--text-size-small); }
.replaced-table th, .replaced-table td { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--border); vertical-align: top; }
.replaced-table tr.changed td { font-weight: 600; }
.replaced-dialog { width: min(520px, calc(100vw - 32px)); }

/* ---------- Update bar ---------- */

.update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--focus);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  font-size: var(--text-size-small);
  white-space: nowrap;
}
.update-reload {
  border: none;
  border-radius: var(--radius-small);
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
}
.update-reload:hover { background: rgba(255, 255, 255, 0.32); }

.settings-heading { font-size: 15px; margin: var(--space-5) 0 0; }

/* ---------- Logbook ---------- */

.log-button:disabled { color: var(--text-faint); cursor: default; background: none; }

.logbook {
  max-width: 640px;
  padding: 0 var(--space-5);
}

.log-day { margin-bottom: var(--space-5); }

.log-date {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-size);
  font-weight: 600;
}
.log-relative { color: var(--text); }
.log-relative + span { color: var(--text-quiet); font-weight: 400; }

.log-main {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}
.log-mark { color: var(--text-faint); width: 16px; text-align: center; }
.log-text { flex: 1; min-width: 0; }
.log-title { color: var(--text-quiet); }
.log-source { display: flex; align-items: center; gap: 6px; }

.log-steps {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding-left: var(--space-4);
  color: var(--text-faint);
  font-size: var(--text-size-small);
}
.log-step { display: inline-flex; gap: 6px; }

/* ---------- Short messages ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
  font-size: var(--text-size-small);
}
.toast-action {
  border: none;
  background: none;
  color: inherit;
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-small);
}
.toast-action:hover { background: rgba(127, 127, 127, 0.25); }

/* ---------- Progress bars ---------- */

.progress {
  height: var(--progress-height);
  border-radius: var(--progress-height);
  background: var(--progress-track);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--progress-height);
  background: var(--area);
  transition: width 0.3s ease;
}

/* On a card: along the bottom edge */
.card { position: relative; }
.card.has-progress { padding-bottom: calc(var(--space-2) + 5px); }
.card-progress {
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 6px;
}

/* Under a list's name */
.list-progress { margin: 0 var(--space-2) var(--space-2); }

/* Under the area name in the board header */
.view-header { flex-wrap: wrap; }
.header-progress {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.header-progress .progress { flex: 0 1 240px; }

/* Under an area in the sidebar */
.nav-item { flex-wrap: wrap; }
.nav-progress {
  flex-basis: 100%;
  height: 2px;
  margin: 2px 0 2px 18px;
}

/* In the details panel */
.details-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: calc(var(--space-2) * -1) 0 0 26px;
}
.details-progress .progress { flex: 1; }

/* ---------- Path back up (details of a sub-item) ---------- */

.path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: calc(var(--space-2) * -1);
  font-size: var(--text-size-small);
  color: var(--text-quiet);
}
.path-link {
  border: none;
  background: none;
  padding: 0 2px;
  border-radius: 4px;
  color: var(--text-quiet);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}
.path-link:hover { color: var(--text); background: var(--bg-hover); }
.path-sep { color: var(--text-faint); }
.path-current { color: var(--text-faint); }

.open-sub { font-size: 17px; padding: 0 var(--space-2); }

/* ---------- Dragging ---------- */

.is-dragging,
.is-dragging * { cursor: grabbing !important; user-select: none; }

.drag-placeholder { opacity: 0.35; }

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: var(--shadow-raised);
  transform-origin: top left;
  list-style: none;
}

/* ---------- Touch screens ---------- */

/* Controls that appear on hover with a mouse are always visible on touch screens. */
@media (hover: none) {
  .quiet-until-hover { opacity: 1; }
}

/* No grey flash on tap, and no iPhone "copy / look up" pop-up on long-press of draggable things. */
.card, .sub, .nav-item, .column-header, button {
  -webkit-tap-highlight-color: transparent;
}
.card, .sub, .nav-item, .column-header {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Phone-only parts are hidden on the Mac. */
.menu-toggle, .drawer-backdrop, .fab, .back-button { display: none; }

/* ---------- The add sheet (phone) ---------- */

.sheet-layer { position: fixed; inset: 0; z-index: 45; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.3); }
.sheet {
  position: absolute;
  top: calc(var(--space-4) + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 2 * var(--space-3)));
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-raised);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.sheet-head h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-input {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--focus);
  border-radius: var(--radius-small);
  background: var(--bg);
  font-size: 16px; /* 16px or more stops iPhone zooming in */
}
.sheet-input:focus { outline: none; }
.sheet-added { margin: var(--space-2) 0 0; min-height: 1.4em; }

/* The quick-add box on touch screens is a button that opens the add sheet. */
.quick-add-button { text-align: left; color: var(--text-faint); cursor: text; }

/* ---------- Mid-size screens (iPad portrait, small windows) ---------- */

@media (min-width: 701px) and (max-width: 1000px) {
  :root {
    --sidebar-width: 200px;
    --details-width: 360px;
  }
}

/* ---------- Phone layout ---------- */

@media (max-width: 700px) {
  :root {
    --column-width: calc(100vw - 48px);
    --text-size: 16px;
  }

  /* Text boxes at 16px or more stop iPhone zooming in when you tap them. */
  input, textarea { font-size: 16px; }

  .app { grid-template-columns: 1fr; }

  /* The sidebar becomes a menu that slides in from the left. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    width: min(85vw, 320px);
    padding-top: calc(var(--space-4) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-raised);
  }
  .drawer-open .sidebar { transform: none; }
  .drawer-open .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.3);
  }
  .sidebar .quick-add { display: none; } /* the round + button does this on the phone */
  .nav-item { padding: 10px var(--space-2); }

  .menu-toggle {
    display: block;
    border: none;
    background: none;
    font-size: 20px;
    padding: 0 var(--space-2) 0 0;
    color: var(--text);
  }

  .view-header {
    padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3);
    gap: var(--space-2);
  }
  .view-title { font-size: 20px; }

  /* Board: one list at a time; swipe sideways to the next. */
  .board-scroll {
    padding: 0 var(--space-4) var(--space-4);
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--space-4);
    gap: var(--space-2);
  }
  .is-dragging .board-scroll { scroll-snap-type: none; } /* lets dragging scroll smoothly */
  .board { gap: var(--space-2); }
  .column, .add-list { scroll-snap-align: start; }
  .column { max-height: calc(100dvh - 110px); }
  .card { padding: var(--space-3); }

  .single-column, .deleted-list, .backup-section, .logbook, .settings-section { padding-left: var(--space-4); padding-right: var(--space-4); }
  .intro { padding: 0 var(--space-4); }

  /* Item details fill the screen, with a Back button. */
  .details {
    width: 100%;
    left: 0;
    border-left: none;
    padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  }
  .back-button {
    display: block;
    border: none;
    background: none;
    color: var(--focus);
    padding: var(--space-1) var(--space-2) var(--space-1) 0;
    font-size: 16px;
  }
  .close-details { display: none; }
  .where { justify-content: center; }
  .sub { padding: 6px 0; }
  .open-sub { font-size: 22px; }
  .details-footer { flex-wrap: wrap; }

  /* The round + button for quick add. */
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: var(--space-5);
    bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
    z-index: 15;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--focus);
    color: #fff;
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
    box-shadow: var(--shadow-raised);
  }
  .has-details .fab, .drawer-open .fab { display: none; }

  /* Messages sit above the + button. */
  .toast {
    bottom: calc(96px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 32px);
  }

  /* Rows with buttons wrap instead of squeezing the text. */
  .deleted-row { flex-wrap: wrap; }
  .deleted-text { flex-basis: 100%; }
  .log-date { flex-wrap: wrap; }

  .menu { min-width: 200px; }
  .menu-item { padding: 10px var(--space-3); }
}
