/* Misdir — calm, warm, theatrical. Paper and ink with one velvet accent for everything that marks a moment. */
:root {
  --paper: #f3f1ec;
  --surface: #ffffff;
  --ink: #1c1b1a;
  --ink-soft: #3d3b38;
  --muted: #76726b;
  --line: #e5e1d9;
  --line-strong: #cfc9bf;
  --velvet: #7b2d3b;
  --velvet-deep: #5e2130;
  --velvet-tint: #f6e9ec;
  --danger: #b4362b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 27, 26, 0.06), 0 10px 30px rgba(28, 27, 26, 0.07);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
a.link, button.link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a.link:hover, button.link:hover { text-decoration-color: var(--velvet); color: var(--velvet-deep); }
main { max-width: 820px; margin: 0 auto; padding: 36px 20px 96px; }
body.wide main { max-width: 1000px; }
h1 { font-family: var(--display); font-weight: 500; font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 8px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--display); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.01em; text-decoration: none; }
.top nav { display: flex; gap: 18px; align-items: center; font-size: 0.92rem; color: var(--ink-soft); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.inline { display: inline; }
.avatar { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--velvet); color: #fff; font-weight: 600; font-size: 0.8rem; align-items: center; justify-content: center; flex: none; }
.eyebrow { margin: 0 0 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 500; }
.dev a { word-break: break-all; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.panel-head h1 { margin-bottom: 0; }
.panel-head p.muted { margin: 6px 0 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
input, textarea { width: 100%; padding: 11px 13px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, textarea:focus { outline: none; border-color: var(--velvet); box-shadow: 0 0 0 3px var(--velvet-tint); }
input::placeholder, textarea::placeholder { color: #a39e95; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--radius-sm); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.1s; }
button:hover, .button:hover { background: var(--ink-soft); }
button:active, .button:active { transform: translateY(1px); }
button.link { background: none; border: 0; color: var(--ink); padding: 0; font-weight: 400; }
button.link:hover { background: none; }
button.link.danger { color: var(--danger); text-decoration-color: rgba(180, 54, 43, 0.4); }
button:disabled { opacity: 0.45; cursor: default; }
ul, ol { list-style: none; padding: 0; margin: 0; }
/* spaces as cards */
.spaces { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.spaces li a { display: flex; flex-direction: column; gap: 6px; min-height: 150px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; }
.spaces li a:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.spaces .name { font-family: var(--display); font-weight: 500; font-size: 1.25rem; line-height: 1.2; }
.spaces .desc { color: var(--muted); font-size: 0.9rem; flex: 1; }
.spaces .open { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
.spaces .open b { font-weight: 500; color: var(--velvet); }
.spaces li a:hover .open b { text-decoration: underline; text-underline-offset: 3px; }
.spaces li.new a { border-style: dashed; align-items: center; justify-content: center; color: var(--muted); }
.spaces li.new a:hover { color: var(--velvet); border-color: var(--velvet); }
/* materials */
.materials li { display: flex; gap: 14px; align-items: center; padding: 13px 10px; margin: 0 -10px; border-top: 1px solid var(--line); border-radius: var(--radius-sm); }
.materials li:first-child { border-top: 0; }
.materials li:hover { background: #faf8f4; }
.materials li[data-status="uploading"], .materials li[data-status="processing"] { opacity: 0.55; }
.materials .cell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.materials .title { font-weight: 500; text-decoration: none; }
.materials a.title:hover { color: var(--velvet-deep); }
.materials .meta { color: var(--muted); font-size: 0.84rem; }
.tag { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; padding: 4px 8px; border-radius: 999px; flex: none; }
.tag.video { background: #e8e4f4; color: #45377a; }
.tag.pdf { background: #f7e9d7; color: #7a4a12; }
.tag.epub { background: #dfeee6; color: #1f5a3c; }
.dropzone { margin-top: 22px; padding: 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: #faf8f4; transition: border-color 0.15s, background 0.15s; }
.dropzone.over { border-color: var(--velvet); background: var(--velvet-tint); }
.uploads li { padding: 10px 0; border-top: 1px solid var(--line); }
.uploads .row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.uploads progress { width: 100%; height: 6px; accent-color: var(--velvet); margin-top: 6px; }
.uploads .err { color: var(--danger); }
/* work page */
.work-head { margin-bottom: 16px; }
.back { display: inline-block; margin-bottom: 6px; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--velvet-deep); }
.stage { position: relative; background: #0f0e0d; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; box-shadow: var(--shadow); }
.stage-video { aspect-ratio: 16 / 9; }
.stage-video video { width: 100%; height: 100%; display: block; background: #000; }
.bigplay { position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: var(--ink); border: 0; font-size: 1.6rem; padding: 0 0 0 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
.bigplay:hover { background: #fff; }
.bigplay.hidden { display: none; }
.stage-pdf { background: #e7e3db; height: min(68vh, 820px); overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 18px; }
.stage-pdf canvas { background: #fff; box-shadow: 0 8px 30px rgba(28, 27, 26, 0.18); max-width: 100%; }
.stage-epub { background: var(--surface); height: min(68vh, 820px); }
#epub-view { height: 100%; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.ctl { padding: 6px 10px; min-width: 36px; background: var(--surface); color: var(--ink); border-color: var(--line); font-size: 0.9rem; }
.ctl:hover { background: var(--paper); border-color: var(--line-strong); }
.time { font-variant-numeric: tabular-nums; font-size: 0.84rem; color: var(--muted); white-space: nowrap; min-width: 84px; }
.tl { position: relative; flex: 1; height: 46px; cursor: pointer; touch-action: none; outline: none; }
.tl:focus-visible .tl-track { box-shadow: 0 0 0 3px var(--velvet-tint); }
.tl-track { position: absolute; left: 0; right: 0; top: 25px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.tl-fill { height: 100%; width: 0; background: var(--velvet); }
.tl-head { position: absolute; top: 21px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; border: 3px solid var(--velvet); left: 0; pointer-events: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.tl-markers { position: absolute; left: 0; right: 0; top: 0; height: 22px; }
.mk { position: absolute; top: 0; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--velvet); color: #fff; font-size: 0.68rem; font-weight: 600; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); cursor: pointer; transition: transform 0.12s; }
.mk:hover, .mk.active { transform: scale(1.2); z-index: 2; }
.mk.private { background: #fff; color: var(--velvet); border-color: var(--velvet); }
.mk .tip { display: none; position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); min-width: 190px; max-width: 280px; padding: 9px 11px; background: var(--ink); color: #fff; font-size: 0.8rem; font-weight: 400; line-height: 1.4; border-radius: var(--radius-sm); white-space: normal; pointer-events: none; z-index: 5; box-shadow: var(--shadow); }
.mk .tip b { color: #f0d9de; font-weight: 500; }
.mk:hover .tip { display: block; }
.composer { display: flex; gap: 10px; align-items: center; margin: 20px 0 10px; }
.composer input[name="body"] { flex: 1; }
.composer .lock { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.composer .lock input { width: 15px; height: 15px; accent-color: var(--velvet); margin: 0; }
.composer .lock input:checked + span { color: var(--velvet-deep); font-weight: 500; }
.composer-hint { margin: 20px 0 10px; }
.notes { margin-top: 6px; }
.notes li { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 12px; align-items: start; padding: 13px 10px; margin: 0 -10px; border-top: 1px solid var(--line); border-radius: var(--radius-sm); transition: background 0.2s; }
.notes li.active { background: var(--velvet-tint); }
.notes .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.notes .head .name { color: var(--ink); font-weight: 500; }
.notes .jump { color: var(--velvet-deep); background: var(--velvet-tint); padding: 1px 7px; border-radius: 999px; font-weight: 500; text-decoration: none; font-variant-numeric: tabular-nums; }
.notes .jump:hover { background: var(--velvet); color: #fff; }
.notes .body { grid-column: 2; margin: 0; white-space: pre-wrap; color: var(--ink-soft); }
.notes .del { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-size: 0.85rem; }
.notes .only-me { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; border: 1px solid var(--line-strong); padding: 1px 6px; border-radius: 999px; }
@media (max-width: 640px) {
  main { padding-top: 24px; }
  h1 { font-size: 1.65rem; }
  .panel { padding: 20px; }
  .time { min-width: 0; }
  .bar { flex-wrap: wrap; }
  .tl { flex-basis: 100%; order: 10; }
  .composer { flex-wrap: wrap; }
  .composer input[name="body"] { flex-basis: 100%; order: -1; }
  .notes li { grid-template-columns: 28px 1fr; }
  .notes .del { grid-column: 2; grid-row: auto; justify-self: start; }
}

/* ---- full screen reading mode (native fullscreen or the fixed-overlay fallback) */
#toggle-notes { display: none; }
.fs-label { margin-left: 4px; }
.reader-notes { margin-top: 6px; }
#viewer:fullscreen, #viewer.is-full { position: fixed; inset: 0; z-index: 50; width: 100vw; height: 100vh; margin: 0; padding: 12px 16px; background: var(--paper); display: flex; flex-direction: column; overflow: hidden; }
#viewer:fullscreen .work-head, #viewer.is-full .work-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 10px; }
#viewer:fullscreen .work-head h1, #viewer.is-full .work-head h1 { font-size: 1.15rem; margin: 0; }
#viewer:fullscreen .work-head .back, #viewer.is-full .work-head .back { margin: 0; }
#viewer:fullscreen .reader, #viewer.is-full .reader { flex: 1; min-height: 0; display: flex; gap: 16px; }
#viewer:fullscreen .reader-main, #viewer.is-full .reader-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#viewer:fullscreen .stage, #viewer.is-full .stage { flex: 1; min-height: 0; height: auto; aspect-ratio: auto; }
#viewer:fullscreen .stage-video video, #viewer.is-full .stage-video video { object-fit: contain; }
#viewer:fullscreen .composer, #viewer.is-full .composer { margin: 10px 0 0; }
#viewer:fullscreen .composer-hint, #viewer.is-full .composer-hint { margin: 10px 0 0; }
#viewer:fullscreen .reader-notes, #viewer.is-full .reader-notes { display: none; width: 360px; flex: none; margin: 0; overflow: auto; padding: 0 4px 0 16px; border-left: 1px solid var(--line); }
#viewer:fullscreen.show-notes .reader-notes, #viewer.is-full.show-notes .reader-notes { display: block; }
#viewer:fullscreen #toggle-notes, #viewer.is-full #toggle-notes { display: inline-flex; }
#viewer:fullscreen.show-notes #toggle-notes, #viewer.is-full.show-notes #toggle-notes { background: var(--velvet-tint); border-color: var(--velvet); color: var(--velvet-deep); }
#viewer:fullscreen .fs-label, #viewer.is-full .fs-label { display: none; }
#viewer:fullscreen .notes li, #viewer.is-full .notes li { margin: 0; padding: 12px 4px; }
@media (max-width: 760px) { .fs-label { display: none; } #viewer:fullscreen .reader-notes, #viewer.is-full .reader-notes { position: absolute; right: 0; top: 0; bottom: 0; width: min(360px, 90vw); background: var(--surface); padding: 16px; box-shadow: var(--shadow); } }

/* ---- landing */
body.plain main { max-width: 900px; }
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); line-height: 1.05; margin: 10px 0 22px; letter-spacing: -0.015em; }
.hero .lead { font-size: 1.15rem; max-width: 620px; color: var(--ink-soft); margin: 0 0 26px; }
.hero-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 0 0 54px; }
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 36px; }
.pillars li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.pillars b { font-family: var(--display); font-weight: 500; font-size: 1.35rem; }
.pillars span { color: var(--muted); font-size: 0.95rem; }
.fine { color: var(--muted); font-size: 0.85rem; }
@media (max-width: 700px) { .pillars { grid-template-columns: 1fr; } .hero { padding-top: 24px; } }
/* ---- shared bits */
.navlink { text-decoration: none; color: var(--ink-soft); }
.navlink:hover { color: var(--velvet-deep); }
.button.secondary, button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover, button.secondary:hover { background: var(--paper); }
.flash { background: var(--velvet-tint); color: var(--velvet-deep); padding: 10px 14px; border-radius: var(--radius-sm); margin: 0 0 16px; }
.quote { margin: 0 0 14px; padding: 0 0 0 14px; border-left: 3px solid var(--velvet); font-family: var(--display); font-style: italic; font-size: 1.1rem; color: var(--ink-soft); }
.plain-list { margin: 0 0 18px; padding-left: 18px; list-style: disc; }
.chip { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; border: 1px solid var(--line-strong); padding: 1px 6px; border-radius: 999px; color: var(--muted); vertical-align: middle; }
h2 { font-family: var(--display); font-weight: 500; font-size: 1.4rem; margin: 0 0 14px; }
h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
/* ---- manage block on a space */
.manage { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #faf8f4; }
.manage summary { cursor: pointer; padding: 10px 14px; color: var(--ink-soft); font-size: 0.92rem; }
.manage-body { padding: 4px 14px 14px; font-size: 0.92rem; }
.copyable { display: inline-block; background: var(--surface); border: 1px solid var(--line); padding: 4px 8px; border-radius: 6px; font-size: 0.82rem; margin: 6px 6px 6px 0; user-select: all; }
/* ---- people */
.invite .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.invite .row input { flex: 1; min-width: 200px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 4px 0 10px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--velvet); }
.check.all { flex-basis: 100%; }
.invite textarea { margin-bottom: 10px; }
.rows li { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rows li:first-child { border-top: 0; }
.rows .cell { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
.rows .meta { color: var(--muted); font-size: 0.84rem; }
.table-wrap { overflow: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.grid th { text-align: center; font-weight: 500; color: var(--muted); font-size: 0.78rem; padding: 6px 8px; border-bottom: 1px solid var(--line); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid th:first-child { text-align: left; }
.grid td { text-align: center; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.grid td.person { text-align: left; display: flex; gap: 10px; align-items: center; }
.grid td.person .meta { display: block; color: var(--muted); font-size: 0.82rem; }
.grid input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--velvet); margin: 0; }

/* ---- material rows: reorder and rename */
.materials .handle { color: var(--line-strong); cursor: grab; font-size: 0.9rem; letter-spacing: -2px; user-select: none; }
.materials li:hover .handle { color: var(--muted); }
.materials li.dragging { opacity: 0.4; }
.materials li.moved { background: var(--velvet-tint); }
.materials .actions { display: flex; gap: 10px; align-items: center; flex: none; }
.ctl.mini { min-width: 28px; padding: 2px 6px; font-size: 0.8rem; color: var(--muted); }
.materials .rename { padding: 6px 8px; font-weight: 500; max-width: 420px; }
@media (max-width: 640px) { .materials li { flex-wrap: wrap; } .materials .actions { flex-basis: 100%; justify-content: flex-end; } }
