/* Mystery Tracker — "Case File" look.
   Layout idea: a calm, flat canvas with a dot grid. All surfaces are neutral.
   The one strong color is the red string and its pin. Light and dark follow the device. */
:root {
  color-scheme: light dark;
  /* color */
  --canvas: #F4F2EE; --dot: #CFCAC0; --surface: #FFFFFF; --surface-2: #FAF9F6; --sunken: #ECEAE5;
  --ink: #1B1A17; --ink-2: #55514A; --ink-3: #6B665D;
  --line: #D9D5CC; --line-strong: #8F8A7F;
  --string: #C8321F; --on-string: #FFFFFF; --focus: #2459D6;
  --btn: #1B1A17; --on-btn: #FFFFFF;
  --danger: #B3261E; --warn-bg: #FFF1C7; --warn-fg: #7A4E00;
  --ev-fg: #55514A; --ev-bg: #ECEAE5;
  --clue-fg: #7A4E00; --clue-bg: #FFF1C7;
  --q-fg: #1F4FA3; --q-bg: #E3ECFB;
  --actor-mix: 100%;
  --scrim: rgb(27 26 23 / .45);
  /* type */
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
  --fs-1: 12px; --fs-2: 13px; --fs-3: 14px; --fs-4: 16px; --fs-5: 18px; --fs-6: 22px; --fs-7: 28px;
  /* space (4-point) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  /* radius */
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-pill: 999px;
  /* elevation */
  --e-1: 0 1px 2px rgb(27 26 23 / .10), 0 0 0 1px var(--line);
  --e-2: 0 4px 16px rgb(27 26 23 / .14), 0 0 0 1px var(--line);
  --e-3: 0 10px 28px rgb(27 26 23 / .22), 0 0 0 1px var(--line);
  /* motion */
  --t-fast: 120ms; --ease: cubic-bezier(.2, 0, 0, 1);
  /* hit size */
  --hit: 36px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #16171A; --dot: #34363B; --surface: #212226; --surface-2: #1B1C1F; --sunken: #2E3035;
    --ink: #ECEAE5; --ink-2: #A9A69E; --ink-3: #A39E95;
    --line: #3A3C42; --line-strong: #7A7772;
    --string: #FF6B57; --on-string: #1B0A07; --focus: #7AA2FF;
    --btn: #ECEAE5; --on-btn: #1B1A17;
    --danger: #FF8A7A; --warn-bg: #3A2F12; --warn-fg: #F2C25B;
    --ev-fg: #A9A69E; --ev-bg: #2E3035;
    --clue-fg: #F2C25B; --clue-bg: #3A2F12;
    --q-fg: #9DBBFF; --q-bg: #1B2A4A;
    --actor-mix: 60%;
    --scrim: rgb(0 0 0 / .6);
    --e-1: 0 1px 2px rgb(0 0 0 / .4), 0 0 0 1px var(--line);
    --e-2: 0 6px 20px rgb(0 0 0 / .5), 0 0 0 1px var(--line);
    --e-3: 0 12px 32px rgb(0 0 0 / .6), 0 0 0 1px var(--line);
  }
}
@media (pointer: coarse), (max-width: 820px) { :root { --hit: 44px; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: var(--fs-3)/1.45 var(--ui); color: var(--ink); background: var(--canvas); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.005em; text-wrap: balance; }
.muted { color: var(--ink-2); }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1.3em; margin: var(--s-2) 0 0; font-size: var(--fs-2); }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; min-height: var(--hit); padding: 0 var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); font-weight: 550; }
button:hover { background: var(--sunken); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--btn); border-color: var(--btn); color: var(--on-btn); font-weight: 600; }
button.primary:hover { opacity: .88; background: var(--btn); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--surface)); background: var(--surface); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
button.small { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-2); }
button.ghost, a.ghost { display: inline-flex; align-items: center; min-height: var(--hit); padding: 0 var(--s-3); border: 1px solid transparent; border-radius: var(--r-1); background: transparent; color: var(--ink-2); text-decoration: none; font-weight: 550; white-space: nowrap; }
button.ghost:hover, a.ghost:hover { background: var(--sunken); color: var(--ink); }
.iconBtn { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; color: var(--ink-3); border-radius: var(--r-1); }
.iconBtn:hover { background: var(--sunken); color: var(--ink); }
.linkBtn { min-height: 28px; padding: 0; border: 0; background: transparent; color: var(--ink); text-decoration: underline; text-decoration-color: var(--string); text-underline-offset: 3px; text-align: left; font-weight: 550; }
.linkBtn:hover { background: transparent; color: var(--string); }
input, select, textarea { width: 100%; min-height: var(--hit); padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--surface); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--btn); }
textarea { resize: vertical; line-height: 1.45; }
label { display: block; margin-top: var(--s-3); font-size: var(--fs-1); font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: var(--s-1); font-weight: 400; font-size: var(--fs-3); }
fieldset { margin: var(--s-4) 0 0; padding: var(--s-2) var(--s-3) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-2); min-width: 0; }
legend { padding: 0 var(--s-1); font-size: var(--fs-1); font-weight: 600; color: var(--ink-2); }

/* ---------- screens: join and case list ---------- */
.screen { min-height: 100%; }
.center { display: grid; place-items: center; padding: var(--s-5) var(--s-4); }
.folder { position: relative; padding: var(--s-5); background: var(--surface); border-radius: var(--r-3); box-shadow: var(--e-1); }
.stamp { font: 600 var(--fs-1)/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--string); }
#joinForm { width: min(380px, 100%); box-shadow: var(--e-2); }
#joinForm h1 { margin-top: var(--s-2); font-size: var(--fs-7); letter-spacing: -.02em; }
#joinForm > .muted { margin: var(--s-1) 0 var(--s-4); }
#joinForm button { width: 100%; margin-top: var(--s-4); min-height: 44px; }

.bar { position: relative; z-index: 5; display: flex; align-items: center; gap: var(--s-2); min-height: 52px; padding: 0 var(--s-3); background: var(--surface); border-bottom: 1px solid var(--line); }
.bar h1 { max-width: 34vw; padding: 0 var(--s-2); font-size: var(--fs-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { padding: 0 var(--s-2); font-size: var(--fs-4); font-weight: 650; letter-spacing: -.01em; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--s-2); border-radius: 50%; background: var(--string); }
.tabs { display: inline-flex; gap: 2px; margin-left: var(--s-2); padding: 3px; background: var(--sunken); border-radius: var(--r-2); }
.tab { min-height: 30px; padding: 0 var(--s-4); border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.tab:hover { background: transparent; color: var(--ink); }
.tab.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .18); }
.conn { padding: 3px 10px; border-radius: var(--r-pill); background: var(--warn-bg); color: var(--warn-fg); font-size: var(--fs-1); font-weight: 600; white-space: nowrap; }
.people { display: flex; align-items: center; padding-left: var(--s-1); }
.person { display: grid; place-items: center; width: 28px; height: 28px; margin-left: 8px; border-radius: 50%; background: var(--sunken); color: var(--ink); font-size: 11px; font-weight: 700; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--line-strong); }
.person:first-child { margin-left: 0; }
.peopleCount { margin-left: var(--s-3); font-size: var(--fs-1); white-space: nowrap; }

.pickerBody { max-width: 1040px; margin: 0 auto; padding: var(--s-6) max(16px, env(safe-area-inset-left, 0px)) var(--s-7); }
.pickerBody > h1 { font-size: var(--fs-7); letter-spacing: -.02em; }
.pickerBody > .muted { margin: var(--s-1) 0 0; }
.storyList { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); margin: var(--s-5) 0 var(--s-6); }
.storyCard { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); color: var(--ink); text-decoration: none; }
.storyCard:hover { box-shadow: var(--e-2); }
.storyCard h2 { font-size: var(--fs-6); line-height: 1.2; letter-spacing: -.015em; overflow-wrap: anywhere; }
.storyCard .summary { margin: 0; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.storyCard p.muted { margin: auto 0 0; padding-top: var(--s-2); font: 500 var(--fs-1) var(--mono); color: var(--ink-3); }
.exampleCard { border-style: dashed; }
.newStory { max-width: 520px; box-shadow: none; border: 1px dashed var(--line-strong); background: transparent; }
.newStory h2 { font-size: var(--fs-5); }
.newStory button { margin-top: var(--s-4); }

/* ---------- one case ---------- */
.storyScreen { height: 100%; display: grid; grid-template-columns: 256px minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
.storyScreen > .bar { grid-column: 1 / -1; }
.pane { padding: var(--s-4); background: var(--surface); border-right: 1px solid var(--line); overflow: auto; }
.paneHead { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.paneHead h2 { font-size: var(--fs-1); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.hint { margin: var(--s-1) 0 var(--s-3); font-size: var(--fs-2); color: var(--ink-2); }
.actorRow { position: relative; display: flex; align-items: center; border-radius: var(--r-1); }
.actorRow:hover, .actorRow.on { background: var(--sunken); }
.actorRow.on { box-shadow: inset 2px 0 0 var(--ink); }
/* The name has the room: a dot, the name, the count; the tag marks go on a second line under the name. */
.actorPick { flex: 1; min-width: 0; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; column-gap: var(--s-2); min-height: var(--hit); padding: 3px var(--s-2) 3px var(--s-3); border: 0; background: transparent; text-align: left; }
.actorPick:hover { background: transparent; }
.actorPick .muted { font: 500 var(--fs-2) var(--mono); color: var(--ink-3); }
.actorName { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; font-weight: 550; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Groups and the drag handle in the actors pane */
.paneBtns { display: inline-flex; gap: var(--s-1); }
.grip { flex: none; display: inline-grid; place-items: center; width: 20px; min-height: var(--hit); color: var(--ink-3); cursor: grab; touch-action: none; opacity: .5; }
.grip:hover { opacity: 1; color: var(--ink); }
.actorRow .actorPick { padding-left: var(--s-1); }
.actorGroup + .actorGroup { margin-top: var(--s-2); }
.groupHead { position: relative; display: flex; align-items: center; border-radius: var(--r-1); }
.groupHead.on { background: var(--sunken); box-shadow: inset 2px 0 0 var(--ink); }
.groupHead.plain { min-height: 30px; padding: 0 var(--s-2) 0 20px; gap: var(--s-2); }
.groupFold { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-1); min-height: var(--hit); padding: 0 var(--s-2) 0 0; border: 0; background: transparent; text-align: left; }
.groupFold:hover { background: transparent; }
.groupFold .icon { flex: none; transform: rotate(90deg); }
.folded .groupFold .icon { transform: none; }
.groupName { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; font-size: var(--fs-2); font-weight: 650; color: var(--ink-2); }
.groupHead .muted { font: 500 var(--fs-2) var(--mono); color: var(--ink-3); }
.groupHead .iconBtn[aria-pressed="true"] { color: var(--ink); background: var(--sunken); }
#actorList.grouped .actorGroup:not(.none) .groupBody { padding-left: var(--s-3); }
.folded .groupBody { display: none; }
.groupEmpty { margin: 0; padding: var(--s-1) var(--s-3) var(--s-2); font-size: var(--fs-1); }
.actorRow.dragged, .actorGroup.dragged { opacity: .4; }
#actorList.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.dropLine { position: fixed; z-index: 20; height: 3px; margin-top: -1px; border-radius: 2px; background: var(--focus); pointer-events: none; }
/* The small buttons of a row lie over the right end of the row. They show on hover and on keyboard focus (and always on a touch screen). */
.rowBtns { position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 1; display: inline-flex; padding-left: var(--s-3); border-radius: var(--r-1);
  background: linear-gradient(90deg, transparent, var(--sunken) 12px); opacity: 0; pointer-events: none; }
.actorRow:hover .rowBtns, .groupHead:hover .rowBtns, .rowBtns:focus-within { opacity: 1; pointer-events: auto; }
@media (hover: none) { .rowBtns { position: static; transform: none; opacity: 1; pointer-events: auto; padding-left: 0; background: none; } }
/* An actor's color is stored data. In the dark theme it is mixed with white so that it stays visible. */
.actorPick i, .chip i { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--a); background: color-mix(in srgb, var(--a) var(--actor-mix), white); }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 22px; padding: 1px 9px 1px 7px; border-radius: var(--r-pill); background: var(--sunken); color: var(--ink); font-size: var(--fs-1); font-weight: 600; overflow-wrap: anywhere; }
.chip i { width: 8px; height: 8px; }
.chip.small { min-height: 20px; }

.editor { grid-column: 3; width: 312px; border-right: 0; border-left: 1px solid var(--line); }
.editForm .row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.editForm .danger { width: 100%; margin-top: var(--s-5); }
.editForm input[name=title] { font-size: var(--fs-4); font-weight: 650; }
.checks { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow: auto; }
.check { display: flex; align-items: center; gap: var(--s-2); min-height: 30px; margin: 0; font-weight: 400; }
.tieRow { margin-bottom: 2px; }
.editForm select[name=tieTo] { margin-top: var(--s-2); }
.ends { margin: var(--s-3) 0 0; overflow-wrap: anywhere; }

/* ---------- canvas ---------- */
.board { position: relative; overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--canvas); background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px); background-size: 24px 24px; }
.board:active { cursor: grabbing; }
.board:focus-visible { outline-offset: -3px; }
#world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
#strings { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
/* The layer over the cards: knots and label pills. A card never hides them. Only the pills can be clicked. */
.stringsTop { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 5; }
.string .leader { fill: none; stroke: var(--string); stroke-width: 1.5; stroke-dasharray: 2 3; stroke-linecap: round; pointer-events: none; }
.yarn { fill: none; stroke: var(--string); stroke-width: 2.5; stroke-linecap: round; }
.string .hit { fill: none; stroke: transparent; stroke-width: 24; pointer-events: stroke; cursor: pointer; }
.string.sel .yarn { stroke-width: 4; }
.string.sel .hit { stroke: var(--focus); stroke-opacity: .35; stroke-width: 12; }
.string.dim { opacity: .2; }
.string .labelBox { fill: var(--surface); stroke: var(--string); stroke-width: 1.25; pointer-events: all; cursor: pointer; }
.string.sel .labelBox { stroke: var(--focus); stroke-width: 2; }
.string .label { font: 600 12px var(--ui); fill: var(--ink); pointer-events: none; }
.yarn.ghost { stroke-dasharray: 6 6; opacity: .85; }

.card { position: absolute; display: flex; flex-direction: column; width: 200px; min-height: 64px; padding: var(--s-3); background: var(--surface); border-radius: var(--r-2); box-shadow: var(--e-1); cursor: grab; }
.card.sel { box-shadow: 0 0 0 2px var(--focus), var(--e-2); z-index: 3; }
.card.lift { box-shadow: 0 0 0 2px var(--focus), var(--e-3); z-index: 4; cursor: grabbing; }
.card.dim { opacity: .3; }
/* The pin is the place where a string joins the card (4px below the top edge, in the middle). */
.knot { fill: var(--string); stroke: var(--surface); stroke-width: 1.5; pointer-events: none; }
.string.sel .knot { fill: var(--focus); }
.card .kind { order: 0; align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px 0 7px; border-radius: var(--r-pill); background: var(--ev-bg); color: var(--ev-fg); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
/* Each kind has a shape and a word, so that color is not the only signal. */
.card .kind::before { content: ""; width: 7px; height: 7px; border: 1.5px solid currentColor; border-radius: 50%; }
.card.kind-clue .kind { background: var(--clue-bg); color: var(--clue-fg); }
.card.kind-clue .kind::before { border-radius: 1px; transform: rotate(45deg); background: currentColor; }
.card.kind-question .kind { background: var(--q-bg); color: var(--q-fg); }
.card.kind-question .kind::before { content: "?"; width: auto; height: auto; border: 0; font-weight: 800; font-size: 12px; line-height: 1; }
.card .title { order: 1; margin-top: var(--s-2); font-size: 15px; line-height: 1.3; font-weight: 650; letter-spacing: -.005em; overflow-wrap: anywhere; }
.card .when { order: 2; margin-top: 2px; font: 500 var(--fs-1) var(--mono); color: var(--ink-3); }
.card .body { order: 3; margin-top: var(--s-2); font-size: var(--fs-2); color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .chips { order: 4; display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--s-3); }
.card .body:empty, .card .when:empty, .card .chips:empty { display: none; }
/* The tie handle: drag it to a different card to make a string. */
.card .tie, .tieDot { border-radius: 50%; background: var(--string); box-shadow: 0 0 0 2px var(--surface); }
.card .tie { position: absolute; right: -11px; bottom: -11px; width: 24px; height: 24px; cursor: crosshair; opacity: 0; display: grid; place-items: center; }
.card .tie::before { content: ""; width: 10px; height: 2px; background: var(--on-string); box-shadow: 0 0 0 0 transparent; border-radius: 1px; }
.card .tie::after { content: ""; position: absolute; width: 2px; height: 10px; background: var(--on-string); border-radius: 1px; }
.card:hover .tie, .card.sel .tie { opacity: 1; }
@media (hover: none) { .card .tie { opacity: 1; } }
.tieDot { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; }

.boardTools { position: absolute; left: 50%; bottom: var(--s-4); z-index: 4; transform: translateX(-50%); display: flex; align-items: center; gap: var(--s-1); padding: var(--s-1); background: var(--surface); border-radius: var(--r-3); box-shadow: var(--e-2); cursor: default; }
.boardTools button { min-height: 36px; border-color: transparent; border-radius: var(--r-2); white-space: nowrap; }
.boardTools button.primary { border-color: var(--btn); }
.boardHint { position: absolute; left: var(--s-4); top: var(--s-4); max-width: calc(100% - 32px); padding: 6px var(--s-3); border-radius: var(--r-2); background: var(--surface); box-shadow: var(--e-1); color: var(--ink-2); font-size: var(--fs-1); pointer-events: none; }
.emptyNote { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); max-width: 340px; padding: var(--s-4) var(--s-5); text-align: center; color: var(--ink-2); pointer-events: none; }
.emptyNote b { display: block; margin-bottom: var(--s-1); color: var(--ink); font-size: var(--fs-4); font-weight: 650; }
.emptyNote.static { position: static; transform: none; margin: var(--s-7) auto; }

/* ---------- timelines ---------- */
.timelines { padding: var(--s-4); overflow: auto; background: var(--canvas); }
.tlBar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.tlTabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--sunken); border-radius: var(--r-2); }
.tlTabs:empty { display: none; }
.tlGrid { display: grid; min-width: max-content; background: var(--surface); border-radius: var(--r-3); box-shadow: var(--e-1); overflow: hidden; }
.tlGrid > div { padding: var(--s-3); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tlCorner { position: sticky; left: 0; z-index: 2; background: var(--surface-2); font-size: var(--fs-1); font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.tlTime { display: flex; flex-direction: column; gap: 1px; background: var(--surface-2); font: 500 var(--fs-1) var(--mono); color: var(--ink-3); }
.tlTime b { color: var(--ink); font-weight: 600; font-size: var(--fs-2); }
.tlTime b:empty { display: none; }
.tlTime.undated b { color: var(--ink-3); }
.tlActor { position: sticky; left: 0; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); background: var(--surface); }
.tlCell { display: flex; flex-direction: column; gap: var(--s-2); min-height: 72px; }
.tlEvent { display: flex; flex-direction: column; gap: 2px; max-width: 260px; min-height: 0; padding: var(--s-2) var(--s-3); text-align: left; background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--a); border-left-color: color-mix(in srgb, var(--a) var(--actor-mix), white); border-radius: var(--r-1); font-weight: 400; }
.tlEvent.kind-clue { background: var(--clue-bg); }
.tlEvent.kind-question { background: var(--q-bg); }
.tlEvent.undated { border-style: dashed; border-left-style: solid; }
.tlEvent.sel { outline: 2px solid var(--focus); outline-offset: 1px; }
.tlEvent .title { font-size: var(--fs-2); font-weight: 650; overflow-wrap: anywhere; }
.tlEvent .muted { font-size: var(--fs-1); }

/* ---------- dialog and toast ---------- */
dialog { width: min(440px, calc(100vw - 32px)); padding: var(--s-5); border: 0; border-radius: var(--r-3); background: var(--surface); color: var(--ink); box-shadow: var(--e-3); }
dialog::backdrop { background: var(--scrim); }
dialog h2 { font-size: var(--fs-5); }
.dialogActions { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-5); }
.swatches { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.swatch { width: 32px; height: 32px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: var(--a); background: color-mix(in srgb, var(--a) var(--actor-mix), white); }
.swatch:hover { background: var(--a); background: color-mix(in srgb, var(--a) var(--actor-mix), white); opacity: .85; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
#toast { position: fixed; left: 50%; bottom: 76px; z-index: 50; max-width: 90vw; padding: 10px var(--s-4); border-radius: var(--r-2); background: var(--btn); color: var(--on-btn); font-weight: 550; box-shadow: var(--e-3); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: no-preference) {
  button, .tab, .actorRow, .card, a.ghost, .storyCard { transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
  #toast { transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
}

/* ---------- phone ---------- */
@media (max-width: 820px) {
  input, select, textarea, label > input, label > select, label > textarea { font-size: var(--fs-4); } /* stops the zoom on focus on iOS */
  .storyScreen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .bar { flex-wrap: wrap; padding: var(--s-1) var(--s-2); row-gap: 0; }
  .storyScreen > .bar h1 { flex: 1; min-width: 0; max-width: none; }
  .storyScreen > .bar .conn, .storyScreen > .bar .people { order: 1; }
  .storyScreen > .bar .spacer { order: 2; flex: 0 0 100%; height: 0; } /* line break: tabs go on a second row */
  .tabs { order: 3; flex: 1; margin: 0 0 var(--s-1); }
  #storyDetails { order: 3; margin-bottom: var(--s-1); }
  .tab { flex: 1; min-height: 34px; }
  .peopleCount, .boardHint { display: none; }
  #actorsPane { max-height: 112px; padding: var(--s-2) var(--s-3); border-right: 0; border-bottom: 1px solid var(--line); }
  #actorsPane .hint { display: none; }
  #actorList { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); }
  .actorRow { border: 1px solid var(--line-strong); border-radius: var(--r-pill); padding-right: var(--s-1); }
  .actorPick { display: flex; gap: var(--s-2); }
  .rowBtns { position: static; transform: none; opacity: 1; pointer-events: auto; padding-left: 0; background: none; }
  .actorName { display: block; }
  .actorRow.on { box-shadow: none; border-color: var(--ink); }
  .actorPick { min-height: 36px; }
  .editor { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; width: auto; max-height: 62vh; grid-column: auto; border-left: 0; border-radius: 18px 18px 0 0; box-shadow: var(--e-3); padding-bottom: max(var(--s-4), env(safe-area-inset-bottom, 0px)); }
  .editor::before { content: ""; display: block; width: 36px; height: 4px; margin: -4px auto var(--s-3); border-radius: 2px; background: var(--line-strong); }
  .boardTools { bottom: var(--s-3); }
  .pickerBody { padding-top: var(--s-5); }
}

/* Small screens: the actors are a row of pills. A group name is a full row; to move an actor there, use "Change" and the Group list. */
@media (max-width: 820px) {
  .grip { display: none; }
  .actorGroup, .groupBody { display: contents; }
  .folded .groupBody { display: none; }
  .groupHead { flex-basis: 100%; }
  .groupHead.plain { padding-left: 0; }
  .groupEmpty { display: none; }
  .actorRow .actorPick { padding-left: var(--s-3); }
}
