/* Worldbuilder · Atlas: a lit desk in a dark study. Sidebar + one shared clock. */
:root {
  --bg: #1C1714; --bg-raise: #201A16; --bg2: #241E1A; --bg3: #2A221D; --bg4: #2E2520;
  --line: #342B25; --line2: #3A302A; --dash: #4A3E36; --dash2: #5A4C42; --dash3: #7A6B5F;
  --text: #EDE4D8; --text2: #D6CABC; --text3: #C9BCAD; --muted: #A89A8A; --faint: #6E6258;
  --accent: #D9A066; --accent2: #E2AE74; --accent3: #F0C796; --on-accent: #1C1714; --glow: rgba(217,160,102,.18);
  --red: #C98B7A; --green: #9DB38A; --blue: #8FA9C9; --plum: #B58AC2; --rose: #C98B7A;
  --avatar: #5B3F2E; --avatar-fg: #F3D9BC;
  --cork: #3a2a1e;
  --note-cream: #f3e8c8; --note-white: #f7f3ec; --note-rose: #f2c9c4; --note-sun: #f5dc8a; --note-leaf: #cfe3b4; --note-sky: #c4dcf0; --note-plum: #dcc8ea; --note-ink: #2b2a33;
  --r: 14px; --r-sm: 10px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --ease: cubic-bezier(.2,.7,.2,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
#app { min-height: 100%; display: flex; flex-direction: column; }
a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent3); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 2.6rem; line-height: 1.05; } h2 { font-size: 1.45rem; } h3 { font-size: 1.2rem; } h4 { font-size: 1.25rem; }
p { margin: .4em 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .86rem; }
.kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kicker.accent { color: var(--accent2); }
.boot { padding: 3rem; text-align: center; color: var(--muted); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::placeholder { color: var(--muted); opacity: 1; }
kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 4px; padding: 1px 5px; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text3); white-space: nowrap; transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease); }
.btn:hover { border-color: var(--dash3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: .85rem; }
.btn.icon-only { padding: 0 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.grow { flex: 1; min-width: 0; }
.iconbtn { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 6px; display: inline-flex; }
.iconbtn:hover { color: var(--text); background: var(--bg3); }
.iconbtn.danger:hover { color: var(--red); }
.iconbtn-sq { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text3); display: grid; place-items: center; font-size: 18px; line-height: 1; }
.iconbtn-sq:hover { color: var(--text); border-color: var(--dash3); }
input[type=text], input[type=password], input:not([type]), textarea, select { background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-sm); padding: .55em .75em; color: var(--text); width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 2.2em; }
textarea.auto { resize: none; overflow: hidden; }
.auto.saving { border-color: var(--accent); }
input.auto { background: transparent; border-color: transparent; padding-left: .3em; }
input.auto:hover, input.auto:focus { border-color: var(--line2); background: var(--bg); }
input.auto.name { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; }
input.auto.subtitle { color: var(--text3); font-style: italic; font-family: var(--serif); font-size: 1.15rem; }
textarea.auto.quiet { background: transparent; border-color: transparent; padding: .3em; font-family: var(--serif); font-size: 1.1rem; line-height: 1.45; }
textarea.auto.quiet:hover, textarea.auto.quiet:focus { border-color: var(--line2); background: var(--bg); }
label.field { display: flex; flex-direction: column; gap: .3em; font-size: .88rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px dashed var(--dash2); background: transparent; color: var(--text3); font-size: .9rem; }
.pill:hover { border-color: var(--dash3); color: var(--text); }
.pill.tag { border-style: solid; border-color: var(--line2); background: var(--bg3); color: var(--text2); }
.pill.tag:hover { border-color: var(--accent); color: var(--accent3); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ghost-wide { width: 100%; min-height: 48px; border-radius: var(--r); border: 1px dashed var(--dash2); background: transparent; color: var(--text3); display: inline-flex; align-items: center; justify-content: center; gap: .3em; }
.ghost-wide:hover { border-color: var(--dash3); color: var(--text); }

.toggle-row { display: flex; gap: .7rem; align-items: flex-start; margin: .5rem 0; cursor: pointer; }
.toggle-row input { width: auto; margin-top: .3rem; }
.toggle-row > span { display: flex; flex-direction: column; gap: .15rem; }

/* ---------- header ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg-raise); position: sticky; top: 0; z-index: 20; }
.hdr-left { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 0; }
.hdr-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 1 1 240px; }
.topbar .spacer { flex: 2 1 auto; }
.topbar .brand { font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.topbar .brand:hover { color: var(--accent3); }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.topbar .sep { color: var(--faint); }
.world-title { display: flex; align-items: center; min-width: 0; }
.topbar select.switcher { width: auto; max-width: 38vw; background: transparent; border-color: transparent; font-family: var(--serif); font-size: 17px; padding: 6px 1.6em 6px 4px; color: var(--text); min-height: 40px; }
.topbar select.switcher:hover { border-color: var(--line2); }
.searchbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text3); }
.searchbtn:hover { border-color: var(--dash3); color: var(--text); }
.clock { display: flex; align-items: center; gap: 6px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 999px; padding: 4px; flex: 0 1 auto; }
.clock-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.clock-btn:hover:not(:disabled) { background: var(--bg4); color: var(--text); }
.clock-btn:disabled { opacity: .35; cursor: default; }
.clock-mid { display: flex; align-items: center; gap: 10px; padding: 0 8px; background: none; border: 0; color: var(--text); min-height: 36px; }
.clock-title { font-family: var(--serif); font-size: 15px; max-width: 28vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-badge { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; display: grid; place-items: center; flex: none; }
.now-badge.sq { border-radius: 5px; background: var(--accent2); }

/* ---------- shell: sidebar + main ---------- */
.shell { display: flex; flex: 1; align-items: stretch; }
.sidebar { flex: 0 0 240px; padding: 20px 12px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; position: sticky; top: 61px; align-self: flex-start; max-height: calc(100vh - 61px); overflow: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 8px; color: var(--text2); }
.nav-item:hover { background: var(--bg2); color: var(--text); }
.nav-item.active { background: var(--bg4); color: var(--text); font-weight: 500; }
.nav-item.nav-home { justify-content: flex-start; }
.nav-item .count { font-size: 12px; color: var(--muted); }
main.page { flex: 1; min-width: 0; padding: 40px 48px 64px; }
main.page > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
main.page.solo { max-width: 1100px; margin: 0 auto; width: 100%; }
main.page.wide { padding: 0; display: flex; flex-direction: column; }
main.page.wide > * { max-width: none; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { flex: 1; min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.empty { padding: 2rem 1.4rem; color: var(--muted); border: 1px dashed var(--dash); border-radius: var(--r); font-family: var(--serif); font-size: 1.1rem; line-height: 1.5; }
.empty-voice { display: flex; flex-direction: column; gap: .8rem; align-items: flex-start; }
.empty-voice p { margin: 0; font-family: var(--serif); font-size: 1.15rem; color: var(--text3); max-width: 60ch; }

/* ---------- lock ---------- */
.lock { flex: 1; display: grid; place-items: center; padding: 2rem; }
.lock form { width: min(380px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 1.8rem; display: flex; flex-direction: column; gap: .9rem; box-shadow: var(--shadow); }
.lock h1 { display: flex; align-items: center; gap: .5em; font-size: 1.8rem; }
.error { color: var(--red); font-size: .9rem; }

/* ---------- cards & lists ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: flex; flex-direction: column; gap: .4rem; position: relative; color: var(--text); transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease); }
.card.link { cursor: pointer; }
.card.link:hover { border-color: var(--dash3); transform: translateY(-2px); box-shadow: var(--shadow); color: var(--text); }
.card .title { font-family: var(--serif); font-size: 1.2rem; }
.card .thumb { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; background: var(--bg3); }
.card .actions { position: absolute; top: .5rem; right: .5rem; display: flex; gap: .1rem; opacity: 0; transition: opacity .15s; }
.card:hover .actions, .card:focus-within .actions { opacity: 1; }
@media (hover: none) { .card .actions { opacity: 1; } }
.card-sec { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-head h2 { font-size: 1.35rem; }
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .15em .65em; border-radius: 999px; background: var(--bg3); border: 1px solid var(--line2); font-size: .8rem; color: var(--text3); white-space: nowrap; }
.chip.accent { border-color: var(--accent); color: var(--accent3); }
button.chip:hover, a.chip:hover { border-color: var(--dash3); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.type-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4em; vertical-align: middle; }
.t-character { background: var(--accent); } .t-location { background: var(--green); } .t-object { background: var(--blue); } .t-event { background: var(--plum); } .t-point { background: var(--rose); }
.list { display: flex; flex-direction: column; gap: .35rem; }
.list-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: var(--r-sm); background: var(--bg2); border: 1px solid var(--line); color: var(--text); }
.list-item:hover { border-color: var(--dash3); color: var(--text); }
.list-item img, .list-item .ph { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--avatar); color: var(--avatar-fg); flex: none; display: grid; place-items: center; font-family: var(--serif); }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--avatar); color: var(--avatar-fg); font-family: var(--serif); font-size: 18px; display: grid; place-items: center; flex: none; }
.avatar.t-location { background: #3C4A33; color: #DCE8CF; } .avatar.t-object { background: #33404E; color: #D4E0EE; } .avatar.t-event { background: #47364F; color: #E7D6EE; }
.searchbox { position: relative; }
.searchbox .icon { position: absolute; left: .7em; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { padding-left: 2.3em; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }

/* ---------- modal, toast, palette ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; padding: 1.4rem; width: min(540px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin-bottom: .9rem; font-size: 1.4rem; }
.modal-form { display: flex; flex-direction: column; gap: .9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.menu { display: flex; flex-direction: column; gap: .5rem; }
ul.lose { margin: 0 0 .6rem; padding-left: 1.2rem; color: var(--text2); }
ul.lose li { margin: .2rem 0; }
.menu .btn { justify-content: flex-start; }
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 200; pointer-events: none; }
.toast { background: var(--bg3); border: 1px solid var(--line2); padding: .55em 1em; border-radius: 10px; opacity: 0; transform: translateY(8px); transition: all .25s; font-size: .9rem; }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: var(--red); color: var(--red); }
.pal-overlay { align-items: start; padding-top: 12vh; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.palette { width: min(640px, 100%); background: var(--bg2); border: 1px solid var(--line2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.6); overflow: hidden; animation: fadeUp .18s var(--ease) both; }
.pal-search { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-search input { background: transparent; border: 0; padding: .2em 0; font-size: 1.15rem; font-family: var(--serif); }
.pal-list { max-height: 55vh; overflow: auto; padding: .4rem; }
.pal-item { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .6rem .75rem; border-radius: 8px; cursor: pointer; min-height: 44px; }
.pal-item.active { background: var(--bg4); }
.pal-item .pal-label { font-size: 1rem; }
.pal-item .pal-sub { color: var(--muted); font-size: .8rem; text-align: right; }
.pal-empty { padding: 1.2rem; color: var(--muted); text-align: center; }
.t-make { background: var(--accent2); } .t-view { background: var(--faint); }

/* ---------- swatches ---------- */
.swatches { display: flex; gap: .3rem; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatch.active { border-color: var(--text); }
.c-cream { background: var(--note-cream); } .c-white { background: var(--note-white); } .c-rose { background: var(--note-rose); } .c-sun { background: var(--note-sun); }
.c-leaf { background: var(--note-leaf); } .c-sky { background: var(--note-sky); } .c-plum { background: var(--note-plum); } .c-ink { background: var(--note-ink); }

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; gap: 28px; }
.home-top { display: flex; flex-direction: column; gap: 10px; }
.home-title { font-size: 3rem; }
textarea.auto.premise { font-family: var(--serif); font-size: 1.5rem; line-height: 1.4; background: transparent; border: 0; border-bottom: 1px dashed var(--dash); border-radius: 0; padding: 4px 0 10px; }
textarea.auto.premise:hover, textarea.auto.premise:focus { border-color: var(--dash3); background: transparent; }
.home-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.recent-list { display: flex; flex-direction: column; }
.recent { display: flex; align-items: center; gap: 14px; padding: 10px; margin: 0 -10px; border-radius: var(--r-sm); background: none; border: 0; }
.recent:hover { background: var(--bg3); }
.recent-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.recent-name { font-family: var(--serif); font-size: 1.15rem; }
.recent .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.steps { display: flex; flex-direction: column; }
.step { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text2); }
.step:hover { color: var(--text); }
.step .tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--dash3); display: grid; place-items: center; flex: none; }
.step.done .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.step.done .tick .icon { width: 12px; height: 12px; stroke-width: 3; }
.step.done { color: var(--muted); }
.library { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.library .lib { display: inline-flex; align-items: baseline; gap: 8px; min-height: 44px; align-items: center; color: var(--text2); }
.library .lib b { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; color: var(--text); }
.library .lib:hover { color: var(--text); }

/* ---------- entity page ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 1.2rem; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--accent3); }
.hero { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; margin-bottom: 1.6rem; }
.hero .portrait { width: 168px; height: 208px; object-fit: cover; border-radius: var(--r); flex: none; background: var(--bg2); border: 1px solid var(--line); }
.hero .portrait.empty { border: 1px dashed var(--dash2); color: var(--text3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 13px; }
.hero .portrait.empty .icon { width: 28px; height: 28px; stroke-width: 1.4; }
.hero .portrait.empty:hover { border-color: var(--dash3); color: var(--text); }
.hero-body { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
input.auto.hero-name { font-family: var(--serif); font-size: 3.2rem; font-weight: 500; line-height: 1; padding: 0 .1em; margin-left: -.1em; }
input.auto.hero-sub { font-family: var(--serif); font-style: italic; font-size: 1.4rem; color: var(--text3); padding: 0 .1em; margin-left: -.1em; }
.hero .more { align-self: flex-start; }
.block { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 22px; margin-bottom: 14px; }
.block > .block-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.block > .block-head h3, .block > .block-head h4 { flex: 1; }
.block > .block-head input.auto { font-family: var(--serif); font-weight: 500; font-size: 1.3rem; color: var(--text); flex: 1; }
.block .tools { display: flex; gap: .1rem; opacity: .55; }
.block:hover .tools { opacity: 1; }
.badge-txt { font-size: 12px; color: var(--muted); white-space: nowrap; }
.block.at { border-color: var(--accent); background: var(--bg-raise); }
.block.same { opacity: .94; }
.block.changed { border-left: 3px solid var(--accent); }
.add-section { display: flex; flex-direction: column; gap: 10px; margin: .2rem 0 1.2rem; }
.fade-in { animation: fadeUp .28s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in, .palette { animation: none; } .card.link:hover { transform: none; } }
.gallery { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .5rem; }
.gallery .g { position: relative; width: 110px; }
.gallery .g img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--line2); }
.gallery .g .note-mini { width: 110px; height: 110px; border-radius: 8px; padding: .4rem; font-size: .72rem; overflow: hidden; color: #2a241e; line-height: 1.3; }
.gallery .g .note-mini.c-ink { color: var(--text); }
.gallery .g .cap { font-size: .72rem; color: var(--muted); margin-top: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery .g .rm { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); border-radius: 50%; color: #fff; display: none; }
.gallery .g:hover .rm { display: inline-flex; }
.gallery .add { width: 110px; height: 110px; border: 1px dashed var(--dash2); border-radius: 8px; display: grid; place-items: center; color: var(--text3); background: none; }
.gallery .add:hover { border-color: var(--dash3); color: var(--text); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; max-height: 55vh; overflow: auto; padding: 2px; }
.picker-grid .p { border: 2px solid transparent; border-radius: 8px; padding: 0; background: none; overflow: hidden; aspect-ratio: 1; position: relative; }
.picker-grid .p img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-grid .p .note-mini { width: 100%; height: 100%; padding: .3rem; font-size: .68rem; text-align: left; overflow: hidden; color: #2a241e; }
.picker-grid .p.on { border-color: var(--accent); }
.picker-grid .p.used { opacity: .35; }
.rel-list { display: flex; flex-direction: column; gap: .4rem; }
.rel { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: var(--r-sm); background: var(--bg3); }
.rel .who { font-weight: 500; color: var(--text); }
.rel .lbl { color: var(--muted); font-size: .9rem; }
.rel .arrow { color: var(--faint); }
.rel.ended .who, .rel.ended .lbl { text-decoration: line-through; opacity: .6; }
.rel.changed { border-left: 3px solid var(--accent); }
.rel input.auto.small, .rel textarea.auto.small { font-size: .9rem; }
select.inline { width: auto; padding: .25em .6em; font-size: .86rem; }
select.btn { appearance: auto; padding-right: .6em; }
.ref { font-size: .95rem; color: var(--muted); background: var(--bg3); border-radius: 8px; padding: .4rem .7rem; margin: .1rem 0 .5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; white-space: pre-wrap; font-family: var(--serif); }
.ref.open { display: block; }
.ref .ref-lbl { color: var(--accent2); font-family: var(--font); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-right: .4rem; }
.block.same .ref { border-left: 2px solid var(--line2); }
.copy-from, .changes { margin-top: .4rem; }
.copy-from .chip, .changes .chip, .import-row .chip { cursor: pointer; }
.import-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: 0 0 .6rem; }
.state-list { display: flex; flex-direction: column; gap: .5rem; }
.state { display: grid; grid-template-columns: 140px 1fr auto; gap: .6rem; align-items: start; padding: .6rem; border-radius: var(--r-sm); background: var(--bg3); }
.state .when { font-size: .9rem; color: var(--accent2); }
.state .when .lbl { color: var(--muted); display: block; font-size: .75rem; }

/* scope card: the time bar on a page */
.lens-host { position: sticky; top: 61px; z-index: 10; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 22px 10px; margin: .2rem 0 1rem; display: flex; flex-direction: column; gap: 4px; }
.scope-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }

/* ---------- the strip ---------- */
.tl-wrap { overflow-x: auto; padding: 1.2rem .3rem .8rem; }
.tl-wrap.compact { padding: .8rem .2rem .3rem; }
.tl { position: relative; display: flex; align-items: flex-start; min-width: max-content; padding: 0 .4rem; }
.tl::before { content: ''; position: absolute; left: 0; right: 0; top: 18px; height: 2px; background: var(--line2); }
.tl .tp { position: relative; width: 170px; flex: none; padding: 0 .5rem; }
.tl .tp .knot { width: 26px; height: 26px; border-radius: 50%; margin: 5px auto 10px; border: 2px solid var(--dash3); background: var(--bg-raise); display: grid; place-items: center; cursor: pointer; position: relative; z-index: 1; color: var(--text3); font-size: 11px; font-weight: 600; font-family: var(--font); }
.tl .tp .knot .ltr { line-height: 1; }
.tl .tp.has .knot { border-color: var(--accent); color: var(--accent2); }
.tl .tp.active .knot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 5px var(--glow); }
.tl .tp .tcard { background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r-sm); padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; min-width: 130px; color: var(--text2); }
.tl .tp .tcard:hover { border-color: var(--dash3); }
.tl .tp.active .tcard { border-color: var(--accent); background: var(--bg4); color: var(--text); }
.tl .tp .tcard .lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tl .tp.active .tcard .lbl { color: var(--accent2); }
.tl .tp .tcard .ttl { font-family: var(--serif); font-size: 16px; line-height: 1.2; }
.tl .tp .tcard .cnt { font-size: 12px; color: var(--muted); margin-top: 3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl .tp .tcard .cnt.carried { color: var(--faint); font-style: italic; }
.tl .tp .ins { position: absolute; top: 6px; width: 24px; height: 24px; border-radius: 50%; border: 1px dashed var(--dash3); background: var(--bg); color: var(--muted); display: none; place-items: center; z-index: 2; }
.tl .tp .ins.before { left: -12px; } .tl .tp .ins.after { right: -12px; }
.tl .tp:hover .ins, .tl .tp.active .ins { display: grid; }
@media (hover: none) { .tl .tp .ins { display: grid; } }
.tl .tp .ins:hover { border-color: var(--accent); color: var(--accent2); }
.tl .tp .ins .icon { width: 12px; height: 12px; }
.tl .tp.mini { width: 130px; }
.tl .tp.dim { opacity: .45; }
.tl .tp.always .knot.square { border-radius: 6px; }
.tl .tp.always.active .knot.square { background: var(--accent2); border-color: var(--accent2); }
.tl .tp.addpt .knot.dashed { width: 18px; height: 18px; margin-top: 9px; border: 1.5px dashed var(--dash3); background: var(--bg-raise); }
.tl .tp.addpt .tcard { background: transparent; border-style: dashed; border-color: var(--dash); color: var(--muted); width: 100%; font: inherit; text-align: left; }
.tl .tp.addpt .tcard .ttl { display: flex; align-items: center; gap: .2em; font-family: var(--font); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.tl .tp.addpt .tcard .ttl .icon { width: 12px; height: 12px; }
.tl .tp.addpt .tcard .cnt { font-size: 13px; color: var(--muted); }
.tl.compact .tp { width: 160px; }
.tl.compact::before { top: 18px; }
.tl-tip { position: fixed; z-index: 200; max-width: 320px; background: var(--bg2); border: 1px solid var(--accent); border-radius: 10px; padding: .6rem .8rem; font-size: .85rem; color: var(--text); box-shadow: var(--shadow); pointer-events: none; }
.tl-tip div { margin: .15rem 0; }
.tl-tip div:first-child { color: var(--accent2); }

/* ---------- question panel (interview) ---------- */
.side { position: sticky; top: 76px; }
.qpanel { background: var(--bg3); border: 1px solid var(--line2); border-radius: 16px; overflow: hidden; }
.qpanel > .qhead { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line2); cursor: pointer; }
.qpanel > .qhead h4 { flex: 1; font-size: 1.1rem; }
.qpanel .qbody { padding: 1rem 1.2rem 1.2rem; max-height: calc(100vh - 160px); overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.qpanel.closed .qbody { display: none; }
.interview { display: flex; flex-direction: column; gap: 12px; }
.interview .progress { display: flex; gap: 4px; }
.interview .progress span { flex: 1; height: 3px; border-radius: 2px; background: var(--dash); }
.interview .progress span.on { background: var(--accent); }
.interview .progress span.cur { outline: 1px solid var(--accent2); outline-offset: 1px; }
.interview .question { margin: 0; font-family: var(--serif); font-size: 1.5rem; line-height: 1.3; color: var(--text); }
.interview textarea.answer { font-family: var(--serif); font-size: 1.1rem; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-sm); padding: 12px; }
.interview .btn.primary { min-height: 44px; }
.qgroups { border-top: 1px solid var(--line2); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.qgroup-link { display: flex; justify-content: space-between; align-items: center; min-height: 36px; background: none; border: 0; color: var(--text2); padding: 0 2px; text-align: left; border-radius: 6px; }
.qgroup-link:hover { color: var(--text); background: var(--bg4); }
.qgroup-link.deeper { color: var(--muted); }
.qall > summary { cursor: pointer; font-size: 13px; color: var(--accent2); min-height: 36px; display: flex; align-items: center; }
.qall-body { padding-top: .4rem; }
.qgroup { margin-top: .7rem; }
.qgroup h5 { margin: 0 0 .3rem; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.q { margin-bottom: .6rem; }
.q .qt { font-size: .9rem; color: var(--text3); margin-bottom: .15rem; }
.q.answered .qt { color: var(--accent2); }
.q textarea { font-size: .95rem; }
.qdeeper { border-top: 1px dashed var(--line2); margin-top: .9rem; padding-top: .5rem; }
.qdeeper summary { cursor: pointer; font-size: .86rem; color: var(--muted); }
.qmini { border-top: 1px dashed var(--line2); margin-top: .7rem; padding-top: .5rem; }
.qmini summary { cursor: pointer; font-size: .86rem; color: var(--muted); }
.qmini .q { margin-top: .4rem; }

/* ---------- tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 1.2rem; border-left: 1px dashed var(--dash); margin-left: .7rem; }
.tree li { margin: .15rem 0; }
.tree .node { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: 8px; min-height: 44px; }
.tree .node:hover { background: var(--bg2); }
.tree .node > a:not(.chip) { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-size: 1.1rem; }
.tree .node .sub { color: var(--muted); font-size: .86rem; font-family: var(--font); }
.tree .node .iconbtn { opacity: .4; }
.tree .node:hover .iconbtn { opacity: 1; }
.tree .node img { width: 30px; height: 30px; object-fit: cover; border-radius: 50%; }
.tree .toggle { width: 18px; color: var(--muted); display: inline-flex; }
.tree .toggle.leaf { visibility: hidden; }
.tree .toggle .icon { transition: transform .15s; }
.tree li.open > .node .toggle .icon { transform: rotate(90deg); }
.tree li:not(.open) > ul { display: none; }
.tree .node a.chip { flex: none; color: var(--muted); font-family: var(--font); }

/* ---------- pin board ---------- */
.board-wrap { flex: 1; display: flex; flex-direction: column; min-height: calc(100vh - 62px); }
.board-tools { display: flex; gap: .6rem; align-items: center; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg-raise); flex-wrap: wrap; }
.board { flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--cork);
  background-image: radial-gradient(rgba(255,255,255,.045) 1px, transparent 1px), radial-gradient(rgba(0,0,0,.25) 1px, transparent 1px);
  background-size: 22px 22px, 37px 37px; background-position: 0 0, 11px 7px; }
.board.panning { cursor: grabbing; }
.board.dropping { outline: 3px dashed var(--accent); outline-offset: -6px; }
.board-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pin { position: absolute; border-radius: 3px; box-shadow: 0 6px 14px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.3); color: #2a241e; display: flex; flex-direction: column; user-select: none; touch-action: none; }
.pin.c-ink { color: var(--text); }
.pin.c-ink textarea, .pin.c-ink input { color: var(--text); }
.pin::before { content: ''; position: absolute; top: -7px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8a7a, #b3291a); box-shadow: 0 2px 3px rgba(0,0,0,.5); z-index: 2; }
.pin.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.pin .pin-title { font-family: var(--serif); font-weight: 600; font-size: .95rem; padding: .55rem .6rem .1rem; background: transparent; border: 0; width: 100%; outline: none; color: inherit; border-radius: 0; }
.pin .pin-text { flex: 1; background: transparent; border: 0; padding: .2rem .6rem .6rem; resize: none; outline: none; font-size: 1rem; line-height: 1.4; color: inherit; overflow: auto; font-family: var(--serif); }
.pin.image { padding: 8px 8px 24px; background: #fbf8f2; }
.pin.image img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; border-radius: 1px; }
.pin.image .pin-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 8px 5px; font-size: .8rem; text-align: center; }
.pin .pin-bar { position: absolute; top: -34px; left: 0; display: none; gap: 2px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 2px; z-index: 3; }
.pin.selected .pin-bar { display: flex; }
.pin .pin-bar .iconbtn { color: var(--text); }
.pin .resize { position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; cursor: nwse-resize; border-right: 2px solid rgba(0,0,0,.35); border-bottom: 2px solid rgba(0,0,0,.35); border-radius: 0 0 3px 0; }
.board-hint { position: absolute; bottom: .7rem; left: 1rem; color: rgba(255,255,255,.5); font-size: .8rem; pointer-events: none; }
.zoom-pill { position: absolute; bottom: .6rem; right: .8rem; background: var(--bg2); border: 1px solid var(--line2); border-radius: 999px; padding: .2em .7em; font-size: .8rem; color: var(--muted); display: flex; gap: .4em; align-items: center; }
.zoom-pill button { background: none; border: 0; color: var(--text); padding: 0 .3em; }

/* ---------- character lanes ---------- */
.char-rows { overflow-x: auto; }
.char-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; border-top: 1px solid var(--line); min-width: max-content; }
.char-row:first-child { border-top: 0; }
.char-row .who { position: sticky; left: 0; background: var(--bg); padding: .5rem .6rem; display: flex; align-items: center; gap: .6rem; z-index: 1; border-right: 1px solid var(--line); }
.char-row .who img, .char-row .who .ph { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--avatar); color: var(--avatar-fg); flex: none; display: grid; place-items: center; font-family: var(--serif); }
.char-row .who a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-size: 1.1rem; }
.char-row .lane { display: flex; position: relative; height: 48px; align-items: center; padding: 0 1rem; }
.char-row .lane::before { content: ''; position: absolute; left: 1rem; right: 1rem; top: 50%; height: 2px; background: var(--line); }
.char-row .lane .cell { width: 170px; flex: none; display: grid; place-items: center; position: relative; }
.char-row .lane .cell .mark { display: block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--dash3); background: var(--bg); cursor: pointer; }
.char-row .lane .cell .mark.on { background: var(--accent); border-color: var(--accent); }
.char-row .lane .cell .mark:hover { border-color: var(--accent2); }
.char-row .lane .cell .mark.on + .tip, .char-row .lane .cell:hover .tip { display: block; }
.char-row .lane .cell .tip { display: none; position: absolute; top: 32px; font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.lane-head { display: grid; grid-template-columns: 220px 1fr; min-width: max-content; }
.lane-head .cells { display: flex; padding: 0 1rem; }
.lane-head .cells .cell { width: 170px; flex: none; text-align: center; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .3rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-head .cells .cell b { color: var(--accent2); }

/* ---------- graph ---------- */
.graph-wrap { flex: 1; position: relative; min-height: calc(100vh - 62px); background: radial-gradient(ellipse at center, #241C17, var(--bg) 70%); overflow: hidden; touch-action: none; }
.graph-wrap > svg { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-wrap > svg.panning { cursor: grabbing; }
.graph-wrap .node { cursor: pointer; }
.graph-wrap .node circle, .graph-wrap .node rect { stroke: var(--bg); stroke-width: 2; }
.graph-wrap .node text { fill: var(--text); font-size: 12px; pointer-events: none; font-family: var(--font); }
.graph-wrap .node .sub { fill: var(--muted); font-size: 10px; }
.graph-wrap .edge line, .graph-wrap .edge path { stroke: var(--faint); stroke-width: 1.5; fill: none; }
.graph-wrap .edge.rel path { stroke: var(--accent); opacity: .8; }
.graph-wrap .edge.tree line { stroke-dasharray: 4 4; }
.graph-wrap .edge.state line { stroke: var(--rose); opacity: .5; }
.graph-wrap .edge.event line { stroke: var(--plum); opacity: .6; }
.graph-wrap .edge text { fill: var(--muted); font-size: 10px; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; font-family: var(--font); }
.graph-wrap .edge.rel text { fill: var(--accent2); }
.graph-wrap .dim { opacity: .12; }
.graph-tools { position: absolute; top: .7rem; left: .7rem; display: flex; gap: .4rem; flex-wrap: wrap; z-index: 2; }
.graph-tools .btn { background: rgba(32,26,22,.92); }
.graph-tools .btn.on { border-color: var(--accent); color: var(--accent2); }
.graph-legend { position: absolute; bottom: .7rem; left: .7rem; display: flex; gap: .8rem; font-size: .75rem; color: var(--muted); background: rgba(32,26,22,.9); padding: .3rem .6rem; border-radius: 8px; flex-wrap: wrap; }
.graph-info { position: absolute; top: .7rem; right: .7rem; width: min(320px, 85vw); background: rgba(32,26,22,.96); border: 1px solid var(--line2); border-radius: 12px; padding: .9rem; z-index: 2; }
.graph-info h3 { margin-bottom: .3rem; }

/* ---------- musings & events ---------- */
.musings { columns: 240px; column-gap: .8rem; }
.musing { break-inside: avoid; margin-bottom: .8rem; border-radius: 4px; padding: .7rem .8rem .5rem; color: #2a241e; box-shadow: 0 3px 8px rgba(0,0,0,.35); position: relative; }
.musing.c-ink { color: var(--text); }
.musing textarea { background: transparent; border: 0; padding: 0; width: 100%; color: inherit; font-size: 1rem; resize: none; font-family: var(--serif); line-height: 1.45; }
.musing .mbar { display: flex; align-items: center; justify-content: space-between; margin-top: .4rem; opacity: .6; font-size: .7rem; }
.musing .mbar .iconbtn { color: inherit; padding: 2px; }
.musing .swatches { gap: .15rem; } .musing .swatch { width: 12px; height: 12px; }
.musing-new { margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.event-list { display: flex; flex-direction: column; gap: .5rem; }
.event-item { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .8rem 1rem; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.event-item:hover { border-color: var(--dash3); }
.event-item .ttl { font-family: var(--serif); font-size: 1.15rem; }
.event-item .meta { font-size: .85rem; color: var(--muted); display: flex; gap: .6rem; flex-wrap: wrap; }
.project-desc { color: var(--muted); max-width: 70ch; }

/* ---------- responsive ---------- */
.hide-sm { }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .side { position: static; order: -1; } .qpanel .qbody { max-height: none; } }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; max-height: none; flex: none; flex-direction: row; overflow-x: auto; gap: 4px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 4px; }
  .nav-kicker { display: none; }
  .nav-item { white-space: nowrap; }
  .nav-item .count { display: none; }
  main.page { padding: 24px 20px 56px; }
  .lens-host { position: static; }
  .topbar { gap: 10px; }
  .clock { order: 3; flex: 1 1 100%; justify-content: center; }
  .hdr-right { flex: 0 0 auto; }
  .hdr-left { flex: 1 1 auto; }
}
@media (max-width: 640px) {
  .hide-sm, .searchbtn kbd { display: none; }
  main.page { padding: 18px 16px 48px; }
  .home-title { font-size: 2.2rem; }
  input.auto.hero-name { font-size: 2.2rem; }
  .hero { gap: 18px; }
  .hero .portrait { width: 120px; height: 150px; }
  .block { padding: 14px 16px; }
  .block-head > .muted.small { display: none; }
  .block-head { flex-wrap: wrap; }
  .state { grid-template-columns: 1fr; }
  .tl.compact .tp { width: 140px; }
}
