/* RobotLab "Studio" design system: warm paper, serif display, engineering mono. Tokens, shell and shared components. */

@font-face { font-family: Fraunces; font-weight: 500; font-display: swap; src: url(../vendor/fonts/Fraunces-500.woff2) format('woff2'); }
@font-face { font-family: Fraunces; font-weight: 700; font-display: swap; src: url(../vendor/fonts/Fraunces-700.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 400; font-display: swap; src: url(../vendor/fonts/InstrumentSans-400.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 500; font-display: swap; src: url(../vendor/fonts/InstrumentSans-500.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 600; font-display: swap; src: url(../vendor/fonts/InstrumentSans-600.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(../vendor/fonts/IBMPlexMono-400.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(../vendor/fonts/IBMPlexMono-500.woff2) format('woff2'); }

:root {
  --serif: Fraunces, Georgia, 'Times New Roman', serif;
  --font: 'Instrument Sans', 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --bg: #f3efe7;
  --bg-deep: #ebe5d9;
  --surface: #fffdf9;
  --surface-2: #f6f1e8;
  --surface-3: #ede6da;
  --line: #e6dfd2;
  --line-strong: #d6cdbd;
  --text: #1f1d1a;
  --text-2: #5e5951;
  --text-3: #9a948a;
  --accent: #1f5f4a;
  --accent-hover: #184d3c;
  --accent-2: #2c7a61;
  --accent-weak: #e2eee8;
  --accent-text: #ffffff;
  --tomato: #e4572e; --tomato-weak: #fbe4db;
  --butter: #f6d77a; --butter-weak: #fbf0cf;
  --sky: #cfe3f2; --lilac: #e5dcf6; --peach: #f9dccb; --mint: #d6ecdf;
  --ok: #2c7a61; --ok-weak: #e2eee8;
  --warn: #b7791f; --warn-weak: #fbf0cf;
  --danger: #c4442a; --danger-weak: #fbe4db;
  --violet: #6e4fc2; --violet-weak: #ece5fa;
  --teal: #1f7d86; --teal-weak: #dcf0f1;
  --pink: #b8487c; --pink-weak: #f9e3ed;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-1: 0 1px 1px rgba(60, 45, 20, .04), 0 2px 6px rgba(60, 45, 20, .05);
  --shadow-2: 0 1px 1px rgba(60, 45, 20, .04), 0 4px 10px rgba(60, 45, 20, .05), 0 18px 40px -20px rgba(60, 45, 20, .28);
  --shadow-3: 0 30px 70px -24px rgba(50, 35, 15, .4), 0 6px 18px rgba(50, 35, 15, .08);
  --focus: 0 0 0 3px rgba(44, 122, 97, .3);
  --head-h: 68px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #15130f;
  --bg-deep: #100e0b;
  --surface: #1f1c17;
  --surface-2: #28241e;
  --surface-3: #322d25;
  --line: #34302a;
  --line-strong: #474036;
  --text: #f1ece2;
  --text-2: #b9b1a3;
  --text-3: #7f786c;
  --accent: #5fbf98;
  --accent-hover: #78d0ad;
  --accent-2: #5fbf98;
  --accent-weak: #1d3129;
  --accent-text: #0d1a14;
  --tomato: #ff7a52; --tomato-weak: #3a2018;
  --butter: #e9c867; --butter-weak: #362e17;
  --sky: #233645; --lilac: #2e2840; --peach: #3a2a20; --mint: #1f3328;
  --ok: #5fbf98; --ok-weak: #1d3129;
  --warn: #e3a33f; --warn-weak: #362e17;
  --danger: #ff7a52; --danger-weak: #3a2018;
  --violet: #a98bff; --violet-weak: #2a2340;
  --teal: #5cc6cf; --teal-weak: #16302f;
  --pink: #f07aae; --pink-weak: #36202b;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 14px 36px -14px rgba(0, 0, 0, .65), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-3: 0 30px 80px -20px rgba(0, 0, 0, .8);
  --focus: 0 0 0 3px rgba(95, 191, 152, .35);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.55 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme='dark'] body::before { opacity: .5; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--butter); color: #1f1d1a; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
.display { font: 600 clamp(38px, 5.4vw, 64px)/1.0 var(--serif); letter-spacing: -0.035em; }
.display em, .page-title em, .h1 em { font-style: italic; color: var(--accent); }
.h1 { font: 600 clamp(30px, 3.6vw, 44px)/1.05 var(--serif); letter-spacing: -0.03em; }
.page-title { font: 600 clamp(30px, 3.6vw, 44px)/1.05 var(--serif); letter-spacing: -0.03em; }
.page-sub { color: var(--text-2); margin-top: 10px; max-width: 62ch; font-size: 16px; }
.h2 { font: 600 24px/1.15 var(--serif); letter-spacing: -0.02em; }
.h3 { font: 600 17px/1.25 var(--serif); letter-spacing: -0.01em; }
.eyebrow { font: 600 11.5px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.lede { font-size: 17px; color: var(--text-2); max-width: 64ch; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mono { font-size: 13px; }
.big-num { font: 600 52px/1 var(--serif); letter-spacing: -0.03em; font-variant-numeric: lining-nums; }
.unit { font: 500 14px var(--font); color: var(--text-3); margin-left: 4px; letter-spacing: 0; }

/* ---------- app shell: top bar with pill navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--head-h); display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s6); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.3) blur(14px); -webkit-backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font: 700 23px/1 var(--serif); letter-spacing: -0.02em; color: var(--text); text-decoration: none !important; flex: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 11px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.brand small { display: block; font: 500 11px/1.2 var(--font); color: var(--text-3); letter-spacing: .02em; margin-top: 3px; }
.pillnav { margin: 0 auto; display: flex; gap: 2px; padding: 5px; background: var(--bg-deep); border-radius: 999px; box-shadow: inset 0 1px 2px rgba(60, 45, 20, .06); }
.pillnav a {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 17px; border-radius: 999px;
  color: var(--text-2); font-weight: 500; text-decoration: none !important; white-space: nowrap; transition: background .2s, color .2s, box-shadow .2s;
}
.pillnav a svg { opacity: .7; }
.pillnav .lbl-short { display: none; }
.pillnav a:hover { color: var(--text); }
.pillnav a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 12px rgba(60, 45, 20, .08); }
.pillnav a.on svg { opacity: 1; color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.search-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-3); box-shadow: var(--shadow-1); transition: border-color .15s, color .15s;
}
.search-btn:hover { border-color: var(--line-strong); color: var(--text-2); }
.me-btn { border: 0; padding: 0; background: transparent; border-radius: 50%; }
.view { min-width: 0; animation: viewIn .5s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tabbar { display: none; }
.mobile-only { display: none !important; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; transition: background .3s; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.sync-dot.off { background: var(--warn); }

/* ---------- page layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: var(--s5) var(--s6) var(--s8); }
.page.narrow { max-width: 920px; }
.page.wide { max-width: none; }
.page.full { max-width: none; padding: 0 var(--s5) var(--s5); height: calc(100vh - var(--head-h)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin: var(--s4) 0 var(--s6); flex-wrap: wrap; }
.split { display: grid; grid-template-columns: 300px 1fr; gap: var(--s5); }
.split > .side { min-width: 0; }
.split > .main { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s4); }
.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow-1);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .5; cursor: default; pointer-events: none; }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); box-shadow: 0 6px 16px -8px rgba(30, 25, 15, .6); }
.btn-primary:hover { background: color-mix(in srgb, var(--text) 86%, var(--accent)); border-color: transparent; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; gap: 6px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ''; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-3) transparent var(--text-3) transparent; animation: spin .7s linear infinite;
}
.btn-primary.busy::after { border-color: var(--bg) transparent var(--bg) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 9px; }
.icon-btn.danger:hover { background: var(--danger-weak); color: var(--danger); }

/* ---------- forms ---------- */
.input, .textarea, .select {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 100px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent-2); box-shadow: var(--focus); }
.input.sm { height: 34px; font-size: 13.5px; border-radius: 10px; }
.select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--text-3); }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-wrap > .input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ---------- surfaces ---------- */
.card { position: relative; background: var(--surface); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.card-pad { padding: var(--s5); }
.card-hover { transition: box-shadow .25s var(--ease), transform .35s var(--spring); cursor: pointer; }
.card-hover:hover { box-shadow: var(--shadow-3); transform: translateY(-3px); }
.panel { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--line); font: 600 17px var(--serif); }
.panel-body { padding: 20px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 2px; padding: 4px; background: var(--bg-deep); border-radius: 999px; }
.tab { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--text); }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item.on { background: var(--accent-weak); }
.tinted { background: var(--surface-2); border-radius: var(--radius); padding: var(--s4); }

/* ---------- chips, tags, badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip.plain::before { display: none; }
button.chip:hover { border-color: var(--line-strong); }
.chip-idea, .chip-open { background: var(--butter-weak); color: var(--warn); }
.chip-chosen, .chip-agreed { background: var(--accent-weak); color: var(--accent); }
.chip-option { background: var(--surface-3); color: var(--text-2); }
.chip-ordered { background: var(--warn-weak); color: var(--warn); }
.chip-arrived { background: var(--teal-weak); color: var(--teal); }
.chip-installed { background: var(--ok-weak); color: var(--ok); }
.chip-dropped { background: var(--surface-2); color: var(--text-3); text-decoration: line-through; }
.chip-later { background: var(--lilac); color: var(--violet); }
.chip-bh { background: var(--tomato-weak); color: var(--tomato); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-weak); color: var(--accent); font-size: 11.5px; font-weight: 700; }
.kbd { display: inline-flex; align-items: center; height: 21px; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; font: 500 11px var(--mono); color: var(--text-3); background: var(--surface); }
.c-accent { --c: var(--accent); --cw: var(--accent-weak); } .c-ok { --c: var(--ok); --cw: var(--ok-weak); }
.c-warn { --c: var(--warn); --cw: var(--warn-weak); } .c-danger { --c: var(--danger); --cw: var(--danger-weak); }
.c-violet { --c: var(--violet); --cw: var(--violet-weak); } .c-teal { --c: var(--teal); --cw: var(--teal-weak); }
.c-pink { --c: var(--pink); --cw: var(--pink-weak); }

/* ---------- avatar ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 600;
  letter-spacing: .01em; user-select: none; box-shadow: 0 0 0 2.5px var(--bg);
}
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -8px; }

/* ---------- empty, skeleton, error ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 24px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; background: var(--accent-weak); color: var(--accent); margin-bottom: 4px; }
.empty h3 { color: var(--text); font: 600 20px var(--serif); }
.empty p { max-width: 42ch; }
.empty .btn { margin-top: 8px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 12px; min-height: 14px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.error-box { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); background: var(--danger-weak); color: var(--danger); }

/* ---------- markdown ---------- */
.md { line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.md > * + * { margin-top: .75em; }
.md h1, .md h2, .md h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -0.015em; margin-top: 1.3em; }
.md h1 { font-size: 26px; } .md h2 { font-size: 21px; } .md h3 { font-size: 17px; }
.md ul, .md ol { padding-left: 1.4em; margin-bottom: 0; } .md li + li { margin-top: .3em; }
.md code { font: 13px var(--mono); padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.md pre { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); overflow: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { margin: 0; padding: 4px 16px; border-left: 3px solid var(--butter); color: var(--text-2); }
.md img { border-radius: var(--radius); max-height: 480px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.md th { font-weight: 600; color: var(--text-2); }
.md hr { border: 0; height: 1px; background: var(--line); }
.md a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.md-placeholder { color: var(--text-3); font-style: italic; cursor: text; }

/* ---------- markdown editor ---------- */
.mde { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.mde:focus-within { border-color: var(--accent-2); box-shadow: var(--focus); }
.mde-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.mde-bar .tabs { background: transparent; padding: 0; margin-right: 6px; }
.mde-bar .sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.mde textarea { display: block; width: 100%; min-height: 160px; padding: 14px 16px; border: 0; resize: vertical; background: transparent; line-height: 1.6; outline: none; }
.mde .mde-preview { padding: 14px 16px; min-height: 160px; }
.mde-foot { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.mde-foot .hint { margin-right: auto; color: var(--text-3); font-size: 12.5px; }
.mde.drop { border-color: var(--accent); background: var(--accent-weak); }

/* ---------- inline edit ---------- */
.ie { border-radius: 8px; cursor: text; transition: background .15s; outline: none; }
.ie:hover { background: var(--surface-2); box-shadow: 0 0 0 4px var(--surface-2); }
.ie.empty-val { color: var(--text-3); }
.ie-input { width: 100%; border: 0; padding: 0; margin: 0; background: transparent; font: inherit; color: inherit; letter-spacing: inherit; outline: none; box-shadow: 0 0 0 4px var(--accent-weak), 0 0 0 5px var(--accent-2); border-radius: 6px; resize: none; }

/* ---------- uploader ---------- */
.upload-zone {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius); color: var(--text-2); background: transparent; transition: border-color .15s, background .15s, color .15s; cursor: pointer; font-weight: 600;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent-2); color: var(--accent); background: var(--accent-weak); }
.upload-progress { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.upload-progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- overlays: modal, drawer, menu, toast, lightbox, palette ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(30, 24, 14, .38); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s ease; backdrop-filter: blur(3px); }
[data-theme='dark'] .overlay { background: rgba(0, 0, 0, .6); }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(540px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); animation: pop .3s var(--spring); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 20px 22px 0; }
.modal-head h2 { font: 600 21px var(--serif); flex: 1; letter-spacing: -0.01em; }
.modal-body { padding: 14px 22px; overflow: auto; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
.drawer-overlay { place-items: stretch end; padding: 12px; overflow: hidden; background: rgba(30, 24, 14, .22); }
.drawer { width: min(680px, 100%); height: calc(100dvh - 24px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); animation: slideIn .45s var(--ease); overflow: hidden; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 22px 26px 48px; }
.menu { position: fixed; z-index: 120; min-width: 200px; padding: 6px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3); animation: pop .2s var(--spring); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 14px; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); box-shadow: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-weak); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 2px; }
.toasts { position: fixed; z-index: 200; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(480px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-3); pointer-events: auto; animation: toastIn .35s var(--spring); }
.toast.ok svg { color: #8fe0bd; } .toast.error svg { color: #ffab92; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; padding: 0 0 0 6px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.lightbox { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-rows: auto 1fr auto; background: rgba(18, 14, 8, .94); color: #fff; animation: fadeIn .2s; }
.lightbox-top { display: flex; justify-content: flex-end; gap: 4px; padding: 10px; }
.lightbox-top .icon-btn, .lightbox-nav { color: #fff; }
.lightbox-top .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lightbox-stage { display: grid; place-items: center; min-height: 0; padding: 0 64px; position: relative; }
.lightbox-stage img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 10px; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .1); display: grid; place-items: center; }
.lightbox-nav:hover { background: rgba(255, 255, 255, .2); }
.lightbox-nav.prev { left: 12px; } .lightbox-nav.next { right: 12px; }
.lightbox-cap { text-align: center; padding: 14px; color: rgba(255, 255, 255, .8); }
.palette { width: min(640px, 100%); align-self: start; margin-top: 12vh; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); overflow: hidden; animation: pop .25s var(--spring); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.palette-input input { flex: 1; height: 58px; border: 0; background: transparent; font-size: 16px; outline: none; color: var(--text); }
.palette-list { max-height: 52vh; overflow: auto; padding: 8px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; color: var(--text); }
.palette-item.on { background: var(--surface-2); }
.palette-item .ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.palette-item.on .ico { background: var(--accent-weak); color: var(--accent); }
.palette-item small { display: block; color: var(--text-3); font-size: 12.5px; }
.palette-item mark { background: var(--butter); color: #1f1d1a; border-radius: 3px; padding: 0 1px; }
.palette-empty { padding: 28px; text-align: center; color: var(--text-3); }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12.5px; }

/* ---------- comments ---------- */
.comments { display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 12px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); margin-bottom: 3px; }
.comment-meta b { color: var(--text); font-weight: 600; }
.comment-actions { margin-left: auto; opacity: 0; transition: opacity .15s; }
.comment:hover .comment-actions, .comment:focus-within .comment-actions { opacity: 1; }
.comment-new { display: flex; gap: 12px; align-items: flex-start; }

/* ---------- sortable ---------- */
.dragging { opacity: .45; }
.drag-ghost { position: fixed; z-index: 300; pointer-events: none; box-shadow: var(--shadow-3); transform: rotate(2deg); opacity: .96; }
.drop-line { height: 3px; background: var(--accent-2); border-radius: 3px; margin: -1px 0; }
.drag-handle { cursor: grab; color: var(--text-3); touch-action: none; }
.drag-handle:active { cursor: grabbing; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent), var(--bg); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .pillnav a { padding: 0 12px; }
  .pillnav a .lbl-long { display: none; }
  .pillnav a .lbl-short { display: inline; }
  .search-btn .label-text, .search-btn .kbd { display: none; }
  .search-btn { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 960px) { .brand small { display: none; } .pillnav a svg { display: none; } }
@media (max-width: 820px) {
  :root { --head-h: 60px; }
  .topbar { padding: 0 var(--s4); gap: var(--s3); }
  .pillnav { display: none; }
  .top-right { margin-left: auto; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .page { padding: var(--s4) var(--s4) 110px; }
  .page.full { padding: 0 0 70px; height: calc(100vh - var(--head-h)); }
  .page-head { margin: var(--s3) 0 var(--s5); }
  .split { grid-template-columns: 1fr; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: 64px; padding: 6px; border-radius: 24px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow-3);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 18px; color: var(--text-3); font-size: 11px; font-weight: 600; text-decoration: none !important; }
  .tabbar a.on { color: var(--accent); background: var(--accent-weak); }
  .toasts { bottom: 92px; }
  .drawer-overlay { padding: 0; }
  .drawer { width: 100vw; height: 100dvh; border-radius: 0; }
  .drawer-body { padding: 18px 18px 48px; }
  .lightbox-stage { padding: 0 8px; }
  .lightbox-nav { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
