/* The timeline page: canvas, controls, popouts, the add/edit drawer, and Jog my memory.
   Loaded after app.css; everything is scoped under .tl-page. */

:root {
  --axis: #b8b6af;
  --grid: rgba(0, 0, 0, 0.045);
  --stem: #c2c0b9;

  /* Category palette slots (docs/schema.md: categories.color_slot). Same 8 hues as the mockups. */
  --slot-0: #8a8984;   /* uncategorized */
  --slot-1: #2a78d6;
  --slot-2: #eb6834;
  --slot-3: #1baf7a;
  --slot-4: #eda100;
  --slot-5: #e87ba4;
  --slot-6: #008300;
  --slot-7: #4a3aa7;
  --slot-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --axis: #5a5955;
    --grid: rgba(255, 255, 255, 0.05);
    --stem: #55544f;
    --slot-0: #8f8e86;
    --slot-1: #3987e5;
    --slot-2: #d95926;
    --slot-3: #199e70;
    --slot-4: #c98500;
    --slot-5: #d55181;
    --slot-6: #008300;
    --slot-7: #9085e9;
    --slot-8: #e66767;
  }
}

/* Swatches pick their color by class, never by inline style (the CSP forbids those). */
.slot-0 { --swatch: var(--slot-0); }
.slot-1 { --swatch: var(--slot-1); }
.slot-2 { --swatch: var(--slot-2); }
.slot-3 { --swatch: var(--slot-3); }
.slot-4 { --swatch: var(--slot-4); }
.slot-5 { --swatch: var(--slot-5); }
.slot-6 { --swatch: var(--slot-6); }
.slot-7 { --swatch: var(--slot-7); }
.slot-8 { --swatch: var(--slot-8); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--swatch); flex: none; }

.tl-page { position: fixed; inset: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.4; }

/* Top bar */
.tl-page .topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 10px 20px 8px; border-bottom: none;
}
.tl-page .title-block { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tl-page .title-block h1 { margin: 0; font-size: 17px; font-weight: 650; }
.tl-page .title-block .sub { margin: 0; font-size: 12px; color: var(--text-secondary); }
.tl-page .controls, .tl-page .who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-page .who { font-size: 13px; color: var(--text-secondary); }

.tl-page select, .tl-page button {
  font: inherit; font-size: 13px; color: var(--text-primary); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; cursor: pointer;
}
.tl-page button:hover, .tl-page select:hover { border-color: var(--axis); }
.tl-page button.primary { width: auto; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 5px 12px; }
.tl-page button.danger { color: var(--danger); border-color: transparent; background: transparent; }
.tl-page button.danger:hover { border-color: var(--danger); }
.tl-page button.icon { border: none; background: transparent; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--text-secondary); }
.tl-page .divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.tl-page .toggle { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-secondary); }

/* Legend (category filter) */
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 6px; }
.tl-page .legend button { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--chip); border-color: transparent; }
.legend button[aria-pressed="false"] { opacity: 0.45; }
.legend button[aria-pressed="false"] .sw { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-muted); }

/* Canvas */
#stage { position: relative; flex: 1; min-height: 320px; overflow: hidden; }
#tl { position: absolute; inset: 0; display: block; cursor: grab; touch-action: none; }
#tl.dragging { cursor: grabbing; }
.hint, .status { position: absolute; top: 8px; font-size: 12px; color: var(--text-muted); pointer-events: none; }
.hint { left: 20px; }
.status { right: 20px; }
@media (max-width: 900px) { .hint { display: none; } }   /* it would run into the status line */

/* Empty timeline */
.empty {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 40px)); text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 22px 24px;
}
.empty h2 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0 0 14px; color: var(--text-secondary); }
.empty .actions { display: flex; justify-content: center; gap: 8px; }

/* Popout */
.pop {
  position: absolute; z-index: 5; width: 300px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  pointer-events: none; font-size: 13px;
}
.pop.pinned { pointer-events: auto; }
.pop .kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.pop .kicker .sw { width: 8px; height: 8px; }
.pop .priv { margin-left: auto; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.pop h2 { margin: 4px 0 2px; font-size: 15px; font-weight: 650; }
.pop .when, .pop .where { color: var(--text-secondary); font-size: 12px; }
.pop p { margin: 8px 0 0; }
.pop .notes { color: var(--text-secondary); font-style: italic; }
.pop .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pop .chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--chip); }
.pop .chip.tag { color: var(--text-secondary); }
.pop .actions { display: flex; gap: 6px; margin-top: 10px; }
.tl-page .pop .actions button { font-size: 12px; padding: 3px 10px; }

/* Drawer (add/edit) */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 20;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow);
}
.drawer form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 18px 16px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 10px 18px 14px; }
.drawer-foot .buttons { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.err { color: var(--danger); font-size: 12px; }
.err:not(:empty) { margin-bottom: 8px; }

.drawer .field { display: block; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.drawer .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; padding: 0; }
.drawer .lbl i { color: var(--danger); font-style: normal; }
.drawer .lbl > span { display: inline; margin: 0; font-size: inherit; color: inherit; }   /* not app.css's block label text: keeps "When *" on one line */
.drawer .lbl small { font-weight: 400; color: var(--text-muted); }
.drawer .field > small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.drawer input:not([type]), .drawer textarea, .drawer select {
  width: 100%; font: inherit; font-size: 14px; color: var(--text-primary);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.drawer textarea { resize: vertical; }
.drawer input:focus, .drawer textarea:focus, .drawer select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.drawer input.bad { border-color: var(--danger); }
.drawer .quick { background: var(--chip); border-radius: 10px; padding: 10px 12px; }
.drawer .quick input { background: var(--panel); }
.drawer small.interp.ok { color: var(--ok); }
.drawer small.interp.no { color: var(--danger); }
.drawer .inline { display: flex; gap: 10px; align-items: center; }
.drawer .inline input:not([type="checkbox"]) { flex: 1; }
.drawer .check { display: flex; align-items: center; gap: 5px; font-size: 13px; white-space: nowrap; color: var(--text-secondary); }

/* Segmented controls and pickers: radio buttons styled as tabs and chips */
.seg { display: flex; gap: 4px; padding: 3px; background: var(--chip); border-radius: 10px; margin: 0 0 14px; }
.seg label { flex: 1; cursor: pointer; }
.seg input, .weights input, .cats input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.seg span { display: block; text-align: center; padding: 6px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.seg span small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }
.seg input:checked + span { background: var(--panel); color: var(--text-primary); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + span, .weights input:focus-visible + span, .cats input:focus-visible + span { outline: 2px solid var(--accent); }

.weights { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.weights label { cursor: pointer; }
.weights span {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px;
  height: 66px; padding: 6px 2px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 10.5px; text-align: center; color: var(--text-secondary); line-height: 1.15;
}
.weights .ball { border-radius: 50%; background: var(--text-muted); }
.weights .w1 { width: 8px; height: 8px; }
.weights .w2 { width: 12px; height: 12px; }
.weights .w3 { width: 17px; height: 17px; }
.weights .w4 { width: 23px; height: 23px; }
.weights .w5 { width: 30px; height: 30px; }
.weights input:checked + span { border-color: var(--accent); background: var(--chip); color: var(--text-primary); font-weight: 600; }
.weights input:checked + span .ball { background: var(--accent); }

.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats label { cursor: pointer; }
.cats span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--chip); font-size: 12.5px; border: 1px solid transparent; }
.cats input:checked + span { border-color: var(--text-primary); font-weight: 600; }

/* Chip inputs for people and tags */
.chipbox { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.drawer .chipbox input { flex: 1; width: auto; min-width: 120px; border: none; padding: 4px; background: transparent; }
.drawer .chipbox input:focus { outline: none; }
.chipbox:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-x { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; padding: 2px 2px 2px 9px; border-radius: 999px; background: var(--chip); }
.chip-x.new { box-shadow: inset 0 0 0 1.5px var(--slot-3); }
.tl-page .chip-x button { border: none; background: none; padding: 0 5px; font-size: 14px; line-height: 1; color: var(--text-muted); }

.prompt-banner { background: var(--chip); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 13px; }
.prompt-banner b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); margin-bottom: 2px; }
.prompt-banner .q2 { display: block; margin-top: 4px; font-weight: 600; }

/* Jog my memory card */
.prompt-card {
  position: absolute; top: 34px; left: 20px; z-index: 6; width: min(380px, calc(100% - 40px));
  padding: 10px 14px 14px; background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow);
}
.pc-head { display: flex; justify-content: space-between; align-items: center; }
.pc-head .kicker { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }
.pc-head .kicker span { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-muted); }
.pc-text { margin: 2px 0 4px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.pc-ctx { margin: 0 0 10px; font-size: 12px; color: var(--text-secondary); }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prompt-card textarea {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text-primary); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; resize: vertical;
}
.prompt-card textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pc-echo { margin: -2px 0 10px; padding: 6px 10px; border-radius: 6px; background: var(--chip); font-size: 12.5px; color: var(--text-secondary); font-style: italic; }
.pc-echo:empty { display: none; }

.toast {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 7;
  padding: 8px 14px; border-radius: 999px; background: var(--text-primary); color: var(--surface); font-size: 13px; box-shadow: var(--shadow);
}

/* Invite dialog (admins) */
.invite-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text-primary); box-shadow: var(--shadow); width: min(460px, calc(100vw - 32px)); }
.invite-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.invite-dialog .inner { padding: 18px 20px; }
.invite-dialog h2 { margin: 0 0 6px; font-size: 17px; }
.invite-dialog p { margin: 0 0 12px; color: var(--text-secondary); font-size: 13.5px; }
.invite-dialog .row { display: flex; gap: 8px; }
.invite-dialog input { flex: 1; }
.invite-dialog .invite-link input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.invite-dialog .close-row { display: flex; justify-content: flex-end; margin-top: 14px; }

/* Photos in the drawer: tiles you can drag to reorder, plus the "+" tile */
.photo-edit { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px; border-radius: 8px; }
.photo-edit.dropping { outline: 2px dashed var(--accent); outline-offset: 2px; }
.photo-edit .thumb { position: relative; width: 76px; height: 58px; border-radius: 6px; overflow: hidden; background: var(--chip); cursor: grab; }
.photo-edit .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.photo-edit .thumb.new { box-shadow: inset 0 0 0 2px var(--slot-3); }
.photo-edit .thumb.failed { box-shadow: inset 0 0 0 2px var(--danger); }
.photo-edit .thumb.failed img { opacity: 0.45; }
.tl-page .photo-edit .thumb button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: none; border-radius: 50%;
  font-size: 14px; line-height: 20px; background: rgba(0, 0, 0, 0.6); color: #fff;
}
.photo-edit .bar { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.35); display: none; }
.photo-edit .thumb.uploading .bar { display: block; }
.photo-edit .bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: #fff; transition: width 0.15s; }
.photo-add { display: grid; place-items: center; width: 76px; height: 58px; border-radius: 6px; border: 1px dashed var(--axis); font-size: 22px; color: var(--text-muted); cursor: pointer; }
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.drawer .photo-msg:not(:empty) { color: var(--danger); }

/* The popout's photo strip. Click a photo (when the popout is pinned) to see it big. */
.pop .photos { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.pop .photos img { height: 64px; width: auto; flex: none; border-radius: 6px; background: var(--chip); }
.pop.pinned .photos img { cursor: zoom-in; }

/* Full-size viewer */
.viewer {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: none;
  background: rgba(12, 12, 14, 0.94); color: #f4f4f2;
}
.viewer[open] { display: flex; align-items: center; justify-content: center; }
.viewer::backdrop { background: rgba(0, 0, 0, 0.5); }
.viewer img { max-width: calc(100vw - 140px); max-height: calc(100vh - 96px); width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.viewer button {
  position: absolute; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #fff;
  cursor: pointer; font: inherit; line-height: 1;
}
.viewer button:hover { background: rgba(255, 255, 255, 0.24); }
.viewer-close { top: 14px; right: 16px; width: 40px; height: 40px; font-size: 26px; }
.viewer-step { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 32px; }
.viewer-step.prev { left: 16px; }
.viewer-step.next { right: 16px; }
.viewer-step[hidden] { display: none; }
.viewer-caption { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; font-size: 14px; }
.viewer-caption .count { margin-left: 8px; color: rgba(255, 255, 255, 0.6); }

@media (max-width: 700px) {
  .viewer img { max-width: 100vw; max-height: calc(100vh - 120px); }
  .viewer-step { top: auto; bottom: 48px; transform: none; }
}
