/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #efe9dd;
  --ink: #1f1a14;
  --ink-2: #5f574b;
  --ink-3: #9a9183;
  --hair: rgba(31, 26, 20, 0.09);
  --hair-2: rgba(31, 26, 20, 0.16);
  --accent: #b27b27;
  --accent-ink: #ffffff;
  --danger: #c23b33;
  --shadow: 0 1px 2px rgba(31, 26, 20, 0.05), 0 12px 32px -10px rgba(31, 26, 20, 0.18);
  --is-dark: 0;
  --panel-w: min(440px, 42vw);
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111318;
    --surface: #1a1d24;
    --surface-2: #242830;
    --ink: #ede7dd;
    --ink-2: #aca498;
    --ink-3: #6f6a62;
    --hair: rgba(237, 231, 221, 0.08);
    --hair-2: rgba(237, 231, 221, 0.15);
    --accent: #e2b264;
    --accent-ink: #1b1409;
    --danger: #ef6b61;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px -10px rgba(0, 0, 0, 0.6);
    --is-dark: 1;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #1a1d24;
  --surface-2: #242830;
  --ink: #ede7dd;
  --ink-2: #aca498;
  --ink-3: #6f6a62;
  --hair: rgba(237, 231, 221, 0.08);
  --hair-2: rgba(237, 231, 221, 0.15);
  --accent: #e2b264;
  --accent-ink: #1b1409;
  --danger: #ef6b61;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 36px -10px rgba(0, 0, 0, 0.6);
  --is-dark: 1;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

input:not([type="checkbox"]):not([type="range"]):not([type="color"]):not([type="file"]),
select, textarea {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--hair-2);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; field-sizing: content; min-height: 40px; line-height: 1.5; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--hair-2); border-radius: 10px;
  background: var(--surface);
  font-weight: 550; font-size: 13px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.ghost { cursor: default; opacity: 0.45; }
.icon-btn.ghost:hover { background: transparent; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-size: 12.5px; font-weight: 550;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--ink); }
.ghost-btn.danger:hover { color: var(--danger); }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 11px; background: var(--surface-2);
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 550; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--hair); }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--hair);
  background: var(--bg);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mark { width: 30px; height: 30px; flex: none; }
.brand-name { font: 600 19px/1 var(--serif); letter-spacing: -0.01em; white-space: nowrap; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; padding-left: 12px; border-left: 1px solid var(--hair-2); }
.crumb { border: 0; background: none; padding: 4px 6px; border-radius: 7px; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.crumb:last-child { color: var(--ink); }
.crumb:hover { background: var(--surface-2); }
.crumbs .sep { color: var(--ink-3); }
.zoom { display: flex; align-items: center; gap: 4px; }
.actions { display: flex; align-items: center; gap: 6px; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0px;
  min-height: 0;
  transition: grid-template-columns 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
}
body.panel-open .app { grid-template-columns: minmax(0, 1fr) var(--panel-w); }
.stage { position: relative; min-width: 0; overflow: hidden; }
#timeline { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }

.lane-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lane-label, .lane-add {
  position: absolute; left: 0; top: 0;
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px 0 8px;
  border: 1px solid var(--hair); border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  will-change: transform, opacity;
}
.lane-label { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.lane-label:hover { border-color: color-mix(in srgb, var(--c) 60%, transparent); }
.lane-label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.lane-label .ico { font-size: 12px; }
.lane-label .grip { width: 0; overflow: hidden; margin-right: -6px; color: var(--ink-3); font-size: 11px; transition: width 0.15s, margin 0.15s; }
.lane-label:hover .grip, .lane-label:focus-visible .grip, .lane-label.dragging .grip { width: 9px; margin-right: 0; }
.lane-label.dragging {
  cursor: grabbing; z-index: 2;
  border-color: color-mix(in srgb, var(--c) 70%, transparent);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.lane-add { color: var(--ink-3); border-style: dashed; font-weight: 550; }
.lane-add:hover { color: var(--ink); border-color: var(--hair-2); }

.bundle-caption {
  position: absolute; left: 0; top: 0;
  max-width: min(560px, calc(100% - 32px));
  font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
  pointer-events: none;
}
.bundle-caption strong { color: var(--ink); font-weight: 650; }
.bundle-caption .thread { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; white-space: nowrap; }
.bundle-caption .thread::before { content: ''; width: 10px; height: 3px; border-radius: 2px; background: var(--c); }
.bundle-caption .cap-hint { display: block; color: var(--ink-3); }

.tooltip {
  position: absolute; left: 0; top: 0; z-index: 3;
  display: grid; gap: 1px; max-width: 280px;
  padding: 7px 10px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font-size: 12.5px; pointer-events: none;
  box-shadow: var(--shadow);
}
.tooltip span { opacity: 0.7; font-size: 11.5px; }
.tooltip .tip-line { opacity: 0.9; font-size: 12px; }
.tooltip .tip-line.done { opacity: 0.55; text-decoration: line-through; }
.tooltip[hidden] { display: none; }

/* ---------- legend ---------- */
.legend {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  pointer-events: none;
}
.legend > * { pointer-events: auto; }
.sample-note {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 5px 5px 12px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 12.5px;
}
.sample-note button:not(.icon-btn) { border: 0; border-radius: 8px; padding: 4px 10px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 12px; }
.sample-note .icon-btn { color: inherit; opacity: 0.7; }
.sample-note .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: inherit; opacity: 1; }
.gesture-hint {
  display: flex; gap: 14px; margin: 0 0 0 auto; padding: 6px 4px;
  font-size: 11.5px; color: var(--ink-3); pointer-events: none; white-space: nowrap;
}
.gesture-hint b { color: var(--ink-2); font-weight: 600; }
@media (max-width: 1180px) { .gesture-hint { display: none; } }

/* ---------- panel ---------- */
.panel {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--hair);
}
.panel > * { width: var(--panel-w); }
.panel-head { padding: 12px 16px 10px; border-bottom: 1px solid var(--hair); }
.panel-row { display: flex; align-items: center; gap: 8px; }
.line-select { padding: 4px 8px !important; font-size: 13px; font-weight: 550; }
.panel-title-row { display: flex; align-items: center; gap: 4px; margin: 10px -6px 4px; }
.panel-title { flex: 1; min-width: 0; text-align: center; }
.panel-title h2 { margin: 0; font: 600 26px/1.15 var(--serif); letter-spacing: -0.015em; }
.panel-title p { margin: 3px 0 0; color: var(--ink-3); font-size: 13px; }
.panel-actions { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
/* The date at the top is a button: click it to change the date. */
.title-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 2px 10px; border: 0; border-radius: 10px; background: transparent; color: inherit;
}
.title-btn:hover { background: var(--surface-2); }
.title-btn h2 { min-width: 0; }
.edit-hint { color: var(--ink-3); font-size: 14px; opacity: 0; transition: opacity 0.15s; }
.title-btn:hover .edit-hint, .title-btn:focus-visible .edit-hint { opacity: 1; }
@media (hover: none) { .edit-hint { opacity: 1; } }
/* ▲ bigger period / ▼ smaller period */
.steps { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.step-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px 4px 6px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.step-btn:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.step-btn:disabled { opacity: 0.4; cursor: default; }
.date-editor { flex: 1; min-width: 0; display: grid; gap: 8px; padding: 2px 4px; }
.date-edit-row, .date-fields, .date-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.date-edit-row { justify-content: center; }
.date-editor select, .date-editor input { padding: 5px 8px; font-size: 14px; }
.date-editor input.year { width: 5.2em; }
.date-edit-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.date-edit-foot .btn { height: 30px; padding: 0 11px; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 40px; overscroll-behavior: contain; }

.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--c); }
.panel-head { box-shadow: inset 0 3px 0 var(--c, transparent); }

/* ---------- note space ---------- */
.note {
  margin-top: 14px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--c) 35%, var(--hair)); border-radius: 14px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.note:focus-within { border-color: color-mix(in srgb, var(--c) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent); }
.note-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px 0;
  font-size: 12.5px; font-weight: 650; color: color-mix(in srgb, var(--c) 55%, var(--ink));
}
/* The writing space: one editable box, a <div> per line. Parts of the text can
   be bigger or smaller (their significance); checklist items get a circle in
   their left margin (drawn here, so the caret never trips over it). */
.nb {
  position: relative; min-height: 96px; padding: 12px 14px 8px;
  outline: none; cursor: text; white-space: pre-wrap; overflow-wrap: anywhere;
  line-height: 1.45; color: var(--ink);
  transition: font-size 0.12s;
}
.nb.is-empty::before {
  content: attr(data-placeholder); position: absolute; top: 12px; left: 14px;
  color: var(--ink-3); pointer-events: none;
}
.nb-line { position: relative; min-height: 1.45em; }
.nb-line span { transition: font-size 0.12s; }
.nb-line.item { padding-left: 1.75em; }
.nb-line.item::before {
  content: ''; position: absolute; left: 0.05em; top: 0.19em;
  width: 1.05em; height: 1.05em; box-sizing: border-box;
  border: 1.5px solid color-mix(in srgb, var(--c) 55%, var(--ink-3)); border-radius: 50%;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.nb-line.item:hover::before { border-color: var(--c); }
.nb-line.item.done::before { background: var(--c); border-color: var(--c); }
.nb-line.item.done::after {
  /* the tick */
  content: ''; position: absolute; left: 0.43em; top: 0.39em;
  width: 0.26em; height: 0.48em; box-sizing: border-box;
  border: solid #fff; border-width: 0 0.12em 0.12em 0; transform: rotate(45deg);
  pointer-events: none;
}
.nb-line.item.done {
  color: var(--ink-3);
  text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink) 40%, transparent);
}
.nb.hide-done .nb-line.item.done:not(.stay) { display: none; }
.nb-line.leaving { opacity: 0; transition: opacity 0.3s; }
.note-tools { display: flex; align-items: center; gap: 4px; padding: 0 8px 2px; }
.note-tools .ghost-btn[aria-pressed] svg { opacity: 0.8; }
.note-foot { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 6px 6px 14px; }
.sig { display: flex; align-items: center; gap: 10px; padding: 2px 14px 4px; }
.sig-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.sig-bars {
  display: flex; align-items: flex-end; gap: 3px; height: 28px; padding: 2px;
  border-radius: 7px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
}
.sig-bars:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sig-bar { width: 10px; height: var(--h); border-radius: 2px; background: var(--hair-2); transition: background 0.1s; }
.sig-bar.on { background: var(--c); }
.sig-num { min-width: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--c) 60%, var(--ink)); }
.sig-hint { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.swatches { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw {
  position: relative; width: 18px; height: 18px; padding: 0; overflow: hidden;
  border: 0; border-radius: 50%; background: var(--s); box-shadow: 0 0 0 1px var(--hair-2); cursor: pointer;
}
.sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--s, var(--ink-2)); }
.sw.custom { background: conic-gradient(#ef4444, #eab308, #22c55e, #3b82f6, #8b5cf6, #ef4444); }
.sw.custom.on { --s: var(--c); }
.sw.custom input { position: absolute; inset: -6px; width: 30px; height: 30px; opacity: 0; cursor: pointer; }
.sw-sep { width: 1px; height: 14px; background: var(--hair-2); }

.write-on { display: grid; gap: 8px; margin-top: 16px; }
.line-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.line-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 9px; border: 1px solid color-mix(in srgb, var(--c) 40%, var(--hair-2)); border-radius: 999px;
  background: color-mix(in srgb, var(--c) 8%, var(--surface)); font-size: 13px; font-weight: 600;
}
.line-chip:hover { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.hint { margin-top: 16px; }

.mini-list { display: grid; gap: 2px; margin-top: 20px; }
.mini-list.part-of { margin-top: 12px; }
.mini-title { margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.mini-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-size: 13px;
}
.mini-row:hover { background: var(--surface-2); }
.mini-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-meta { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; }

.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-size: 11.5px; font-weight: 650; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }

/* ---------- dialogs ---------- */
dialog {
  padding: 0; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.4);
}
dialog::backdrop { background: rgba(20, 16, 10, 0.38); backdrop-filter: blur(3px); }
#customize { width: min(760px, calc(100vw - 24px)); height: min(780px, calc(100dvh - 40px)); }
#customize[open] { display: flex; }
.dlg { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.dlg-head { display: flex; align-items: center; gap: 16px; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--hair); flex-wrap: wrap; }
.dlg-head h2 { margin: 0; font: 600 22px var(--serif); }
.tabs { display: flex; gap: 2px; flex: 1; }
.tabs button { padding: 7px 12px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-weight: 600; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--ink); background: var(--surface-2); }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px 28px; }
.dlg-body h3 { margin: 26px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.lead { margin: 0 0 16px; color: var(--ink-2); max-width: 60ch; }

.rows { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--hair); border-radius: 12px; background: var(--bg); }
.row.is-hidden { opacity: 0.55; }
.row .grow { flex: 1; }
.grip-btn {
  flex: none; width: 22px; height: 30px; padding: 0; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3); font-size: 15px; line-height: 1;
  cursor: grab; touch-action: none;
}
.grip-btn:hover { background: var(--surface-2); color: var(--ink); }
.row.dragging { position: relative; z-index: 1; background: var(--surface); box-shadow: var(--shadow); border-color: var(--hair-2); }
.row.dragging, .row.dragging .grip-btn { cursor: grabbing; }
.row .name { min-width: 90px; }
input.emoji { width: 46px; text-align: center; padding: 6px 4px !important; }
.swatch {
  position: relative; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 0 1px var(--hair-2);
  cursor: pointer; overflow: hidden;
}
.swatch input { position: absolute; inset: -8px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }
.add-row { background: transparent; border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 9px; border: 1px solid var(--hair-2); border-radius: 999px; background: var(--surface);
  font-size: 13px; font-weight: 550;
}
.chip:hover { border-color: color-mix(in srgb, var(--c) 60%, transparent); background: color-mix(in srgb, var(--c) 9%, var(--surface)); }

.pref-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 22px; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.end { justify-content: flex-end; }

.confirm-dialog { width: min(440px, calc(100vw - 32px)); }
.confirm { padding: 22px; }
.confirm h2 { margin: 0 0 8px; font: 600 21px var(--serif); }
.confirm p { margin: 0 0 20px; color: var(--ink-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; z-index: 50; display: grid; gap: 8px; transform: translateX(-50%); }
.toast {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 10px 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 13.5px;
  animation: toast-in 0.25s ease;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.out { opacity: 0; transform: translateY(6px); }
.toast button { border: 0; border-radius: 8px; padding: 5px 11px; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 12.5px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .crumbs { display: none; }
  #zoom-in, #zoom-out { display: none; }
}

@media (max-width: 760px) {
  :root { --panel-w: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .brand-name { font-size: 17px; }
  .zoom { order: 5; width: 100%; }
  .zoom .seg { flex: 1; }
  .zoom .seg button { flex: 1; justify-content: center; padding: 6px 4px; }
  .actions { margin-left: auto; gap: 2px; }
  .actions .btn .label { display: none; }
  .actions .btn { width: 36px; padding: 0; justify-content: center; }
  .app, body.panel-open .app { grid-template-columns: minmax(0, 1fr); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: 62dvh; border: 0; border-radius: 20px 20px 0 0;
    box-shadow: 0 -20px 60px -10px rgba(0, 0, 0, 0.35);
    transform: translateY(105%); transition: transform 0.3s cubic-bezier(0.3, 0.7, 0.2, 1);
  }
  body.panel-open .panel { transform: none; }
  .panel-head { padding-top: 14px; }
  .dlg-body { padding: 14px 14px 24px; }
  .row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- years box ---------- */
.years-box {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid var(--hair-2); border-radius: 14px; background: var(--surface-2);
}
.years-box-text { flex: 1 1 auto; }
.years-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.years-field input.year { width: 92px; font-size: 15px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- icon picker ---------- */
input.emoji { cursor: pointer; }
.icon-picker {
  position: fixed; z-index: 60; width: 328px; max-height: 340px; overflow-y: auto;
  padding: 10px; border: 1px solid var(--hair-2); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow);
}
.ip-hint { margin: 0 2px 6px; font-size: 12px; color: var(--ink-3); }
.ip-group { margin: 8px 2px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.ip-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.ip-icon { height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 19px; }
.ip-icon:hover, .ip-icon:focus-visible { background: var(--surface-2); }

/* ---------- photos and videos in a note ---------- */
.note-media { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.note-media[hidden] { display: none; }
.nm-tile { position: relative; height: 84px; aspect-ratio: var(--ar, 1.33); border-radius: 9px; overflow: hidden; background: color-mix(in srgb, var(--c) 20%, var(--surface-2)); }
.nm-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.nm-open img { display: block; width: 100%; height: 100%; object-fit: cover; }
.nm-tile.video .nm-open::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; background: rgba(0, 0, 0, 0.5)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l9 5-9 5z' fill='white'/%3E%3C/svg%3E") center / 16px no-repeat;
  pointer-events: none;
}
.nm-remove {
  position: absolute; top: 4px; right: 4px; display: grid; place-items: center;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; opacity: 0; transition: opacity 0.15s;
}
.nm-tile:hover .nm-remove, .nm-remove:focus-visible { opacity: 1; }
@media (hover: none) { .nm-remove { opacity: 1; } }
.nm-adding { margin: 0 14px 6px; }
.nm-adding[hidden] { display: none; }
.note.dropping { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.note.dropping .nb { background: color-mix(in srgb, var(--c) 10%, transparent); }

/* the full-size viewer */
.media-dialog { width: min(1100px, calc(100vw - 24px)); height: min(820px, calc(100vh - 24px)); max-height: none; padding: 0; background: #111; color: #f4f1ea; }
.mv { display: flex; flex-direction: column; height: 100%; }
.mv-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; }
.mv-head .icon-btn { color: #f4f1ea; }
.mv-head .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.mv-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-body { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px 12px; }
.mv-body img, .mv-body video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.mv-nav { position: absolute; top: 50%; margin-top: -24px; width: 44px; height: 48px; color: #fff; background: rgba(0, 0, 0, 0.35); z-index: 1; }
.mv-nav:first-child { left: 12px; }
.mv-nav:last-child { right: 12px; }
.mv-nav:hover { background: rgba(0, 0, 0, 0.6) !important; }

/* ---------- print & export ---------- */
.print-dialog { width: calc(100vw - 24px); height: calc(100vh - 24px); max-width: 1500px; max-height: none; padding: 0; }
.print-dialog.busy .pr-stage, .print-dialog.busy .pr-side > :not(.pr-progress):not(.pr-actions) { pointer-events: none; opacity: 0.7; }
.print-dialog.busy .pr-actions { pointer-events: none; opacity: 0.5; }
.pr { display: flex; flex-direction: column; height: 100%; }
.pr-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--hair); }
.pr-head h2 { margin: 0; font: 600 21px var(--serif); }
.pr-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.pr-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 10px 14px 8px; background: var(--surface-2); }
.pr-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding-bottom: 8px; }
.pr-tools .btn { height: 32px; }
.pr-tools .btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.pr-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--hair-2); }
.pr-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pr-canvas { display: block; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 30px rgba(0, 0, 0, 0.12); cursor: grab; touch-action: none; }
.pr-canvas:active { cursor: grabbing; }
.pr-canvas.cropping { cursor: crosshair; }
.pr-hint { margin: 8px 0 0; text-align: center; }
.pr-side { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 18px; overflow-y: auto; border-left: 1px solid var(--hair); }
.pr-preview { display: grid; place-items: center; min-height: 196px; padding: 6px; border-radius: 12px; background: var(--surface-2); }
.pr-page { display: block; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.pr-info { margin: -6px 0 0; font-size: 12.5px; color: var(--ink-2); text-align: center; }
.pr-warn { color: var(--accent); }
.pr-field { display: grid; gap: 6px; }
.pr-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.pr-seg { display: flex; }
.pr-seg button { flex: 1; justify-content: center; padding: 6px 8px; }
.pr-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.pr-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pr-level {
  display: grid; gap: 1px; padding: 8px 10px; text-align: left;
  border: 1px solid var(--hair-2); border-radius: 10px; background: var(--surface);
}
.pr-level strong { font-size: 13px; }
.pr-level span { font-size: 11.5px; color: var(--ink-3); }
.pr-level[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pr-progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pr-progress[hidden] { display: none; }
.pr-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.pr-actions { display: flex; gap: 8px; margin-top: auto; }
.pr-actions .btn { flex: 1; justify-content: center; height: 40px; }
@media (max-width: 860px) {
  .pr-body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; overflow-y: auto; }
  .pr-side { border-left: 0; border-top: 1px solid var(--hair); overflow: visible; }
  .pr-sub { display: none; }
}

/* ---------- background menu (bright / dark / auto) ---------- */
.theme-pick { position: relative; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  display: grid; gap: 2px; min-width: 220px; padding: 6px;
  border: 1px solid var(--hair-2); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow);
}
.theme-menu[hidden] { display: none; }
.tm-title { margin: 4px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-3); }
.theme-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left;
  font-size: 13.5px; font-weight: 550;
}
.theme-menu button:hover, .theme-menu button:focus-visible { background: var(--surface-2); outline: none; }
.theme-menu button[aria-checked="true"] { color: var(--ink); }
.tm-name { flex: 1; display: grid; }
.tm-name small { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }

/* ---------- undo / redo ---------- */
.history { display: inline-flex; gap: 2px; margin-right: 2px; }
.icon-btn:disabled { opacity: 0.32; cursor: default; }
