/* Riemann Research — design system prototype */
:root {
  --bg: #f7f6f2;
  --bg-elev: #ffffff;
  --bg-sunk: #efede7;
  --ink: #12141a;
  --ink-2: #4a4f5c;
  --ink-3: #8a8f9b;
  --rule: #dedbd2;
  --rule-strong: #c9c5b9;
  --accent: #d9481e;          /* "critical line" vermilion */
  --blue: #2357c6;
  --green: #1f8a5b;
  --amber: #b7791f;
  --grid: #12141a0a;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --maxw: 1200px;
  --radius: 4px;
}
[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-sunk: #080a0e;
  --ink: #e9e7e1;
  --ink-2: #a7abb5;
  --ink-3: #6b7080;
  --rule: #23272f;
  --rule-strong: #333844;
  --accent: #ff6a3d;
  --blue: #6c9bff;
  --green: #4cc38a;
  --amber: #e5a93b;
  --grid: #ffffff08;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }
.label {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.label .dot { display:inline-block; width:6px; height:6px; border-radius:50%; background:var(--accent); margin-right:8px; vertical-align:1px; }

/* Photo treatment: slightly desaturated, full colour on hover */
.photo { position: relative; overflow: hidden; background: var(--bg-sunk); }
.photo img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.7) contrast(1.05); transition: filter .4s, transform .6s; }
a:hover .photo img, .photo:hover img { filter: none; transform: scale(1.02); }
.photo .credit { position:absolute; right:8px; bottom:6px; font-family: var(--mono); font-size: 10px; color: #ffffffb0; text-shadow: 0 1px 2px #0008; }
.photo .fig-id { position:absolute; left:12px; top:12px; font-family: var(--mono); font-size: 10.5px; color:#fff; background:#0009; padding: 3px 7px; border-radius: 3px; letter-spacing: .05em; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.nav .wrap { display:flex; align-items:center; height:64px; gap:40px; }
.brand { display:flex; align-items:center; gap:12px; font-family: var(--serif); font-size: 21px; font-weight: 500; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border: 1.5px solid var(--ink); border-radius: 50%;
  display:grid; place-items:center; font-family: var(--serif); font-style: italic; font-size: 17px; position: relative;
}
.brand-mark::after { content:""; position:absolute; left:50%; top:-4px; bottom:-4px; width:1.5px; background: var(--accent); transform: translateX(-50%); }
.brand-mark span { background: var(--bg); position: relative; z-index: 1; padding: 0 1px; line-height: 1; }
.nav-links { display:flex; gap:28px; font-size:14px; color: var(--ink-2); }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-right { margin-left:auto; display:flex; align-items:center; gap:14px; }
.icon-btn {
  width:34px; height:34px; border:1px solid var(--rule); border-radius: var(--radius);
  background: transparent; color: var(--ink-2); cursor:pointer; display:grid; place-items:center;
  font-family: var(--mono); font-size: 13px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--rule-strong); }
.btn {
  display:inline-flex; align-items:center; gap:8px; height:36px; padding: 0 16px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor:pointer; font-family: var(--sans);
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg); white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }

/* ---------- Hero ---------- */
.hero { position: relative; border-bottom: 1px solid var(--rule); overflow: hidden; }
.hero::before {
  content:""; position:absolute; inset:0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.hero .wrap { position: relative; display:grid; grid-template-columns: 1.05fr 1fr; gap: 56px; padding-top: 88px; padding-bottom: 72px; align-items: center; }
.hero h1 {
  font-family: var(--serif); font-weight: 400; font-size: 54px; line-height: 1.06;
  letter-spacing: -.025em; margin: 20px 0 24px;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p.lede { font-size: 18px; color: var(--ink-2); max-width: 520px; margin: 0 0 32px; }
.hero .ctas { display:flex; gap:12px; }
.hero-stats { display:flex; gap: 40px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--rule); }
.hero-stats div b { display:block; font-family: var(--serif); font-size: 30px; font-weight: 400; }
.hero-stats div span { font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }

.plot-card {
  background: var(--bg-elev); border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: 0 1px 0 var(--rule), 0 24px 48px -24px #0000001f;
}
.plot-head { display:flex; justify-content:space-between; align-items:center; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.plot-head .dots { display:flex; gap:6px; }
.plot-head .dots i { width:8px; height:8px; border-radius:50%; background: var(--rule-strong); }
.zplot { display:block; width:100%; height: 340px; }
.plot-foot { display:flex; justify-content:space-between; padding: 10px 16px; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ---------- Ticker ---------- */
.ticker { border-bottom: 1px solid var(--rule); background: var(--bg-sunk); }
.ticker .wrap { display:flex; gap: 32px; height: 44px; align-items:center; font-family: var(--mono); font-size: 12px; color: var(--ink-2); overflow:hidden; white-space: nowrap; }
.ticker b { color: var(--accent); font-weight: 500; }

/* ---------- Sections ---------- */
section.block { padding: 88px 0; border-bottom: 1px solid var(--rule); }
.sec-head { display:flex; justify-content:space-between; align-items:end; margin-bottom: 40px; gap: 24px; }
.sec-head h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; letter-spacing: -.02em; margin: 10px 0 0; line-height: 1.1; }
.sec-head a.more { font-family: var(--mono); font-size: 12px; color: var(--ink-2); border-bottom: 1px solid var(--rule-strong); padding-bottom: 2px; }

/* Featured */
.featured { display:grid; grid-template-columns: 1.3fr 1fr; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--bg-elev); }
.featured .photo { min-height: 420px; border-right: 1px solid var(--rule); }
.featured .body { padding: 40px; display:flex; flex-direction:column; }
.featured h3 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.15; letter-spacing: -.015em; margin: 16px 0; }
.featured p { color: var(--ink-2); margin: 0 0 24px; }
.meta { display:flex; flex-wrap: wrap; gap: 8px 16px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.tag { display:inline-block; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border: 1px solid var(--rule-strong); border-radius: 3px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.tag.ai { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.tag.math { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tag.quant { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.authors { margin-top: auto; padding-top: 24px; border-top: 1px solid var(--rule); display:flex; align-items:center; gap:12px; font-size: 14px; }
.avatar { width:30px; height:30px; border-radius:50%; background: var(--bg-sunk); border:1px solid var(--rule-strong); display:grid; place-items:center; font-family: var(--serif); font-size: 13px; margin-right: -10px; }
.avatars { display:flex; margin-right: 10px; }

/* Paper list */
.papers { border-top: 1px solid var(--ink); }
.paper { display:grid; grid-template-columns: 120px 1fr 220px; gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--rule); align-items: start; }
.paper:hover h4 { color: var(--accent); }
.paper .id { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-top: 6px; }
.paper .id b { display:block; color: var(--ink); font-weight: 500; }
.paper h4 { font-family: var(--serif); font-weight: 400; font-size: 23px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.01em; transition: color .15s; }
.paper p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; max-width: 720px; }
.paper .photo { height: 132px; border-radius: 4px; border: 1px solid var(--rule); }

/* Areas */
.areas { display:grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); border-radius: 6px; overflow:hidden; }
.area { border-right: 1px solid var(--rule); background: var(--bg-elev); }
.area:last-child { border-right: none; }
.area .photo { height: 170px; border-bottom: 1px solid var(--rule); }
.area .inner { padding: 28px 32px 32px; }
.area .glyph { font-family: var(--serif); font-style: italic; font-size: 30px; line-height: 1; color: var(--accent); }
.area h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 14px 0 8px; }
.area p { color: var(--ink-2); font-size: 15px; margin: 0 0 20px; }
.area .count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* Projects */
.project { display:grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-elev); overflow: hidden; }
.project .body { padding: 44px; }
.project h3 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 14px 0 12px; letter-spacing: -.015em; }
.project p { color: var(--ink-2); margin: 0 0 24px; }
.project .photo { min-height: 360px; border-left: 1px solid var(--rule); }
.project .formula { position:absolute; left: 24px; right: 24px; bottom: 24px; background: color-mix(in srgb, var(--bg-elev) 92%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--rule); border-radius: 4px; padding: 18px; font-size: 17px; text-align:center; color: var(--ink); }

/* Newsletter */
.subscribe { display:grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items:center; }
.subscribe h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; margin: 10px 0; letter-spacing: -.02em; line-height: 1.1; }
.subscribe form { display:flex; gap: 8px; }
.input {
  flex:1; height: 44px; padding: 0 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--ink); font: inherit; font-size: 15px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Footer */
footer { padding: 56px 0 40px; font-size: 14px; color: var(--ink-2); }
footer .cols { display:grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
footer h5 { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 400; margin: 0 0 14px; }
footer ul { list-style:none; padding:0; margin:0; display:grid; gap:8px; }
footer .base { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--rule); display:flex; justify-content:space-between; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ---------- Article page ---------- */
.article-head { border-bottom: 1px solid var(--rule); padding: 56px 0 48px; }
.article-head .crumbs { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-bottom: 28px; }
.article-head h1 { font-family: var(--serif); font-weight: 400; font-size: 54px; line-height: 1.08; letter-spacing: -.025em; margin: 16px 0 24px; max-width: 920px; }
.article-head .sub { font-size: 21px; color: var(--ink-2); max-width: 760px; font-family: var(--serif); margin: 0 0 32px; }
.byline { display:flex; gap: 40px; padding-top: 24px; border-top: 1px solid var(--rule); font-size: 14px; flex-wrap: wrap; }
.byline .k { display:block; font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.cover { margin-top: 40px; height: 380px; border-radius: 6px; border: 1px solid var(--rule); }

.article-grid { display:grid; grid-template-columns: 200px minmax(0, 680px) 1fr; gap: 56px; padding: 56px 0 96px; }
.toc { position: sticky; top: 96px; align-self: start; font-size: 13px; }
.toc ol { list-style: none; padding: 0; margin: 14px 0 0; border-left: 1px solid var(--rule); }
.toc li a { display:block; padding: 6px 0 6px 16px; color: var(--ink-3); margin-left: -1px; border-left: 1px solid transparent; }
.toc li a.on { color: var(--ink); border-left-color: var(--accent); }
.toc .actions { margin-top: 32px; display:grid; gap: 8px; }
.toc .actions .btn { justify-content: center; }

.prose { font-family: var(--serif); font-size: 20px; line-height: 1.7; }
.prose h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; letter-spacing: -.01em; margin: 56px 0 16px; }
.prose h2 .n { font-family: var(--mono); font-size: 14px; color: var(--accent); margin-right: 14px; font-weight: 400; vertical-align: 4px; }
.prose p { margin: 0 0 22px; }
.prose a { color: var(--blue); border-bottom: 1px solid color-mix(in srgb, var(--blue) 30%, transparent); }
.prose sup a { border: none; font-family: var(--mono); font-size: 12px; }
.abstract { font-family: var(--sans); font-size: 15.5px; line-height: 1.65; background: var(--bg-elev); border: 1px solid var(--rule); border-left: 3px solid var(--accent); padding: 24px 28px; border-radius: 0 4px 4px 0; margin-bottom: 40px; color: var(--ink-2); }
.abstract .label { display:block; margin-bottom: 10px; }
.eqblock { position: relative; margin: 28px 0; padding: 4px 48px 4px 0; overflow-x: auto; }
.eqblock .eqn { position:absolute; right:0; top:50%; transform: translateY(-50%); font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.theorem { background: var(--bg-sunk); border: 1px solid var(--rule); padding: 20px 24px; border-radius: 4px; margin: 28px 0; }
.theorem b { font-family: var(--sans); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-right: 6px; }
figure { margin: 36px 0; }
figure .fig { border: 1px solid var(--rule); background: var(--bg-elev); border-radius: 4px; padding: 12px; }
figcaption { font-family: var(--sans); font-size: 13.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.5; }
figcaption b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
pre.code { font-family: var(--mono); font-size: 13.5px; line-height: 1.6; background: var(--bg-sunk); border: 1px solid var(--rule); border-radius: 4px; padding: 18px 20px; overflow-x: auto; color: var(--ink); }
pre.code .c { color: var(--ink-3); } pre.code .k { color: var(--accent); } pre.code .s { color: var(--green); } pre.code .f { color: var(--blue); }
table.data { width:100%; border-collapse: collapse; font-family: var(--sans); font-size: 14px; margin: 28px 0 8px; }
table.data th { text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 400; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); border-bottom: 1px solid var(--ink); padding: 8px 10px; }
table.data td { border-bottom: 1px solid var(--rule); padding: 10px; }
table.data td.num { font-family: var(--mono); text-align: right; font-size: 13px; }
table.data tr.best td { font-weight: 600; }
.refs { font-family: var(--sans); font-size: 14px; color: var(--ink-2); padding-left: 0; list-style: none; counter-reset: r; }
.refs li { counter-increment: r; padding-left: 40px; position: relative; margin-bottom: 10px; }
.refs li::before { content: "[" counter(r) "]"; position:absolute; left:0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); top: 2px; }
.margin-notes { font-size: 13px; color: var(--ink-2); position: sticky; top: 96px; align-self: start; }
.prose .katex { font-size: 1.04em; }
.margin-notes .note { border-top: 1px solid var(--rule); padding-top: 12px; margin-bottom: 28px; }
.cite-box { font-family: var(--mono); font-size: 11.5px; background: var(--bg-sunk); border: 1px solid var(--rule); border-radius: 4px; padding: 14px; white-space: pre-wrap; color: var(--ink-2); margin-top: 10px; }

/* ---------- Admin ---------- */
.admin { display:grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin aside { border-right: 1px solid var(--rule); background: var(--bg-elev); padding: 20px 16px; display:flex; flex-direction:column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.admin aside nav a { display:flex; align-items:center; gap: 10px; padding: 8px 10px; border-radius: 4px; font-size: 14px; color: var(--ink-2); }
.admin aside nav a:hover { background: var(--bg-sunk); color: var(--ink); }
.admin aside nav a.on { background: var(--bg-sunk); color: var(--ink); font-weight: 500; box-shadow: inset 2px 0 0 var(--accent); }
.admin aside nav a .ic { font-family: var(--mono); width: 18px; color: var(--ink-3); font-size: 13px; text-align:center; }
.admin aside nav a .ct { margin-left:auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.admin aside .grp { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 0 10px 8px; }
.storage { margin-top:auto; border: 1px solid var(--rule); border-radius: 4px; padding: 12px; font-size: 12px; }
.storage .bar { height: 4px; background: var(--bg-sunk); border-radius: 2px; margin: 8px 0 6px; overflow:hidden; }
.storage .bar i { display:block; height:100%; width: 7%; background: var(--green); }
.admin main { min-width: 0; }
.topbar { height: 60px; border-bottom: 1px solid var(--rule); display:flex; align-items:center; padding: 0 28px; gap: 16px; background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar .crumbs { font-size: 14px; color: var(--ink-3); }
.topbar .crumbs b { color: var(--ink); font-weight: 500; }
.topbar .right { margin-left:auto; display:flex; gap: 10px; align-items:center; }
.status { display:inline-flex; align-items:center; gap:6px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.status i { width:6px; height:6px; border-radius:50%; background: var(--green); }
.admin .content { padding: 28px; }
.kpis { display:grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.kpi { border: 1px solid var(--rule); border-radius: 6px; padding: 16px 18px; background: var(--bg-elev); }
.kpi b { display:block; font-family: var(--serif); font-size: 32px; font-weight: 400; margin-top: 6px; }
.kpi small { font-family: var(--mono); font-size: 11px; color: var(--green); }
.panel { border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-elev); overflow: hidden; }
.panel-head { display:flex; align-items:center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-head .right { margin-left:auto; display:flex; gap: 8px; align-items: center; }
.seg { display:flex; border: 1px solid var(--rule); border-radius: 4px; overflow:hidden; font-size: 12.5px; }
.seg a { padding: 5px 12px; color: var(--ink-2); border-right: 1px solid var(--rule); }
.seg a:last-child { border-right: none; }
.seg a.on { background: var(--bg-sunk); color: var(--ink); font-weight: 500; }
table.list { width:100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align:left; font-family: var(--mono); font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 18px; border-bottom: 1px solid var(--rule); background: var(--bg-sunk); }
table.list td { padding: 12px 18px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list .t { font-family: var(--serif); font-size: 16.5px; display:flex; align-items:center; gap: 14px; }
table.list .t .photo { width: 56px; height: 38px; border-radius: 3px; flex: none; border: 1px solid var(--rule); }
table.list .id { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.pill { display:inline-flex; align-items:center; gap:6px; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--bg-sunk); color: var(--ink-2); }
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }
.pill.pub { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.pill.draft { color: var(--ink-3); }
.pill.review { color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); }
.pill.progress { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); }

.editor { display:grid; grid-template-columns: 1fr 1fr 280px; border: 1px solid var(--rule); border-radius: 6px; overflow:hidden; background: var(--bg-elev); margin-top: 28px; }
.editor .pane { min-width: 0; border-right: 1px solid var(--rule); }
.editor .pane-h { display:flex; justify-content:space-between; align-items:center; padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--bg-sunk); min-height: 42px; }
.editor textarea { width:100%; height: 480px; border: none; resize: none; padding: 18px; font-family: var(--mono); font-size: 12.5px; line-height: 1.75; background: transparent; color: var(--ink); outline: none; }
.editor .preview { padding: 18px 24px; height: 480px; overflow:auto; }
.editor .preview .prose { font-size: 16.5px; }
.editor .preview .prose h2 { font-size: 21px; margin: 20px 0 8px; }
.editor .side { padding: 18px; display:grid; gap: 16px; align-content: start; font-size: 13px; }
.field label { display:block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; }
.field .input { height: 36px; font-size: 13.5px; width: 100%; }
.cover-pick { height: 110px; border-radius: 4px; border: 1px solid var(--rule); }
.drop { border: 1px dashed var(--rule-strong); border-radius: 4px; padding: 14px; text-align:center; color: var(--ink-3); font-size: 12.5px; }
.drop code { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }

@media (max-width: 960px) {
  .hero .wrap, .featured, .project, .subscribe, .areas, footer .cols, .article-grid, .editor, .kpis { grid-template-columns: 1fr; }
  .hero h1 { font-size: 44px; }
  .paper { grid-template-columns: 1fr; gap: 8px; }
  .toc, .margin-notes { display:none; }
  .admin { grid-template-columns: 1fr; }
}

/* ---------- App additions ---------- */
.prose .theorem > p:first-of-type { display: inline; }
.prose .theorem > p:last-child { margin-bottom: 0; }
.prose .theorem.proof b, .prose .theorem.remark b, .prose .theorem.note b { font-style: italic; text-transform: none; letter-spacing: 0; font-family: var(--serif); font-size: inherit; font-weight: 500; }
.prose .math.block { overflow-x: auto; overflow-y: hidden; }
.prose img { border-radius: 4px; margin: 0 auto; }
.prose figure .fig p { margin: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 22px; }
.prose blockquote { margin: 28px 0; padding-left: 20px; border-left: 2px solid var(--rule-strong); color: var(--ink-2); font-style: italic; }
.prose h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 36px 0 12px; }
.prose code:not(pre code) { font-family: var(--mono); font-size: .78em; background: var(--bg-sunk); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; }
.prose h2#references + ol { font-family: var(--sans); font-size: 14px; color: var(--ink-2); padding-left: 0; list-style: none; counter-reset: r; }
.prose h2#references + ol li { counter-increment: r; padding-left: 40px; position: relative; margin-bottom: 10px; }
.prose h2#references + ol li::before { content: "[" counter(r) "]"; position: absolute; left: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); top: 2px; }
.prose .footnotes { font-family: var(--sans); font-size: 14px; color: var(--ink-2); }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 40px 0; }
pre.code .k, pre.code .kn, pre.code .kd, pre.code .kc, pre.code .ow { color: var(--accent); }
pre.code .c, pre.code .c1, pre.code .cm, pre.code .sd { color: var(--ink-3); font-style: italic; }
pre.code .s, pre.code .s1, pre.code .s2, pre.code .mi, pre.code .mf { color: var(--green); }
pre.code .nf, pre.code .nc, pre.code .nb, pre.code .fm { color: var(--blue); }

.empty { padding: 56px 24px; text-align: center; color: var(--ink-3); border: 1px dashed var(--rule-strong); border-radius: 6px; }
.filters a { padding-bottom: 2px; border-bottom: 1px solid transparent; }
.filters a.on { color: var(--ink); border-bottom-color: var(--accent); }
.page-head { padding: 64px 0 40px; border-bottom: 1px solid var(--rule); }
.page-head h1 { font-family: var(--serif); font-weight: 400; font-size: 52px; letter-spacing: -.025em; margin: 12px 0 12px; line-height: 1.08; }
.page-head p { color: var(--ink-2); font-size: 18px; max-width: 640px; margin: 0; }
.notice { font-family: var(--mono); font-size: 12px; margin-top: 12px; color: var(--green); }
.notice.err { color: var(--accent); }
.project + .project { margin-top: 24px; }
.project .photo.plain { background: var(--bg-sunk); }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; padding: 64px 0 96px; }

/* admin forms */
.flash { margin-bottom: 20px; padding: 10px 14px; border-radius: 4px; font-size: 13.5px; border: 1px solid; }
.flash.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); background: color-mix(in srgb, var(--green) 8%, transparent); }
.flash.err { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }
.meta-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.field textarea.input { height: auto; padding: 10px 14px; resize: vertical; font-size: 14px; line-height: 1.5; width: 100%; }
.field .input.title-input { height: 48px; font-family: var(--serif); font-size: 22px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.editor .preview .prose { font-size: 16.5px; }
.editor textarea.src { height: 620px; }
.editor .preview { height: 620px; }
.cover-pick { display: grid; place-items: center; color: var(--ink-3); font-size: 12px; }
.drop.over { border-color: var(--accent); color: var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; padding: 18px; }
.media-item { border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--bg-elev); font-size: 12px; }
.media-item .photo { height: 130px; }
.media-item .file { height: 130px; display: grid; place-items: center; background: var(--bg-sunk); font-family: var(--mono); color: var(--ink-3); font-size: 20px; }
.media-item .info { padding: 10px; display: grid; gap: 6px; }
.media-item code { font-family: var(--mono); font-size: 11px; color: var(--ink-2); word-break: break-all; }
.media-item .row { display: flex; gap: 6px; }
.linkbtn { background: none; border: none; padding: 0; color: var(--ink-3); cursor: pointer; font: inherit; font-family: var(--mono); font-size: 12px; }
.linkbtn:hover { color: var(--accent); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; border: 1px solid var(--rule); background: var(--bg-elev); border-radius: 6px; padding: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 960px) { .meta-grid, .about-grid, .form-grid { grid-template-columns: 1fr; } }
.ticker .tk { max-width: 400px; overflow: hidden; text-overflow: ellipsis; flex: none; }
.ticker .tk:hover { color: var(--ink); }
.prose .theorem .eqblock { margin: 8px 0; } .prose .theorem .katex-display { margin: .5em 0; }

/* ---------- Research in progress ---------- */
.tag.wip { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.label .dot.wip, .dot.wip { background: var(--amber); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.dot.wip.live { animation: pulse 2.4s ease-in-out infinite; }
.wip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.wip-card { display: flex; flex-direction: column; gap: 12px; padding: 24px; border: 1px solid var(--rule); border-top: 2px solid var(--amber); border-radius: 6px; background: var(--bg-elev); transition: border-color .15s, transform .15s; }
.wip-card:hover { border-color: color-mix(in srgb, var(--amber) 50%, var(--rule)); transform: translateY(-2px); }
.wip-card h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
.wip-card .note { font-size: 14px; color: var(--ink-2); margin: 0; }
.wip-card .note::before { content: "→ "; color: var(--amber); }
.wip-card .foot { margin-top: auto; padding-top: 14px; border-top: 1px dashed var(--rule-strong); }
.wip-banner { font-family: var(--sans); line-height: 1.6; display: flex; gap: 16px; align-items: flex-start; margin: 0 0 28px; padding: 16px 20px; border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 7%, var(--bg)); border-radius: 6px; font-size: 14.5px; color: var(--ink-2); }
.wip-banner b { color: var(--ink); font-weight: 600; }
.wip-banner .dot { margin-top: 7px; flex: none; }
.wip-banner a { color: var(--blue); }
.prose .questions { font-family: var(--sans); font-size: 15px; background: var(--bg-elev); border: 1px dashed color-mix(in srgb, var(--amber) 55%, transparent); border-radius: 6px; padding: 20px 24px; margin: 48px 0 24px; color: var(--ink-2); }
.prose .questions .label { display: block; margin-bottom: 10px; color: var(--amber); }
.prose .questions ul, .prose .questions ol { margin-bottom: 0; }
.prose .questions p:last-child { margin-bottom: 0; }
.prose .changelog { font-family: var(--sans); font-size: 14px; color: var(--ink-2); margin: 24px 0; }
.prose .changelog .label { display: block; margin-bottom: 8px; }
.prose .changelog ul { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--rule-strong); }
.prose .changelog li { padding: 4px 0 4px 16px; position: relative; }
.prose .changelog li::before { content: ""; position: absolute; left: -4px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--amber); }
.prose .changelog li:first-child::before { background: var(--amber); }
.feedback-cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg-sunk); font-family: var(--sans); font-size: 14.5px; margin: 24px 0; }
@media (max-width: 960px) { .wip-grid { grid-template-columns: 1fr; } .feedback-cta { flex-direction: column; align-items: flex-start; } }
.wip-fields { border: 1px dashed color-mix(in srgb, var(--amber) 50%, transparent); border-radius: 4px; padding: 12px; margin: 0; display: grid; gap: 12px; }
.wip-fields legend { padding: 0 6px; color: var(--amber); }
.wip-grid:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.wip-grid > .wip-card:only-child h3 { font-size: 28px; max-width: 820px; }
.wip-grid > .wip-card:only-child .note { font-size: 15.5px; }
.prose a.btn { color: var(--bg); border-bottom: 1px solid var(--ink); font-family: var(--sans); }

/* ---------- Commentary ---------- */
.tag.opinion { color: var(--ink-2); border-color: var(--rule-strong); background: var(--bg-sunk); }
.comments { border-top: 1px solid var(--ink); }
.comment-row { display: grid; grid-template-columns: 160px 1fr; gap: 32px; padding: 24px 0; border-bottom: 1px solid var(--rule); }
.comment-row:hover h4 { color: var(--accent); }
.comment-row .when { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-top: 4px; }
.comment-row .when span { display: block; color: var(--ink-2); margin-top: 4px; }
.comment-row h4 { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.25; margin: 0 0 6px; transition: color .15s; }
.comment-row .take { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.comment-row .on { font-size: 13px; color: var(--ink-3); }
.comment-row .on i { color: var(--ink-2); }
.prose .source-card { font-family: var(--sans); font-size: 15px; border: 1px solid var(--rule); border-left: 3px solid var(--ink-3); background: var(--bg-elev); border-radius: 0 6px 6px 0; padding: 18px 22px; margin: 0 0 32px; }
.prose .source-card .label { display: block; margin-bottom: 6px; }
.prose .source-card .src-title { font-family: var(--serif); font-size: 20px; line-height: 1.3; color: var(--ink); }
.prose .source-card .src-title a { color: var(--ink); border-bottom-color: var(--rule-strong); }
.prose .source-card .src-by { color: var(--ink-3); font-size: 13.5px; margin-top: 4px; }
.prose .source-card .src-take { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--rule-strong); color: var(--ink-2); }
.prose .disclaimer { font-family: var(--sans); font-size: 13px; color: var(--ink-3); font-style: italic; border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 40px; }
.commentary-fields { border: 1px dashed var(--rule-strong); border-radius: 4px; padding: 12px; margin: 0; display: grid; gap: 12px; }
.commentary-fields legend { padding: 0 6px; }
@media (max-width: 960px) { .comment-row { grid-template-columns: 1fr; gap: 8px; } }

/* admin: type pills + filter bar */
.kind { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 9px 0 0; border: 1px solid var(--rule-strong); border-radius: 3px; font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: var(--bg-elev); overflow: hidden; }
.kind .kind-ic { display: grid; place-items: center; width: 24px; height: 100%; font-size: 13px; text-transform: none; border-right: 1px solid currentColor; }
.kind:hover { filter: brightness(.95); }
.kind-paper { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.kind-paper .kind-ic { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kind-note { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.kind-note .kind-ic { background: color-mix(in srgb, var(--blue) 12%, transparent); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.kind-commentary { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.kind-commentary .kind-ic { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 18px; border-bottom: 1px solid var(--rule); }
.filterbar .fb { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; height: 32px; font-size: 13px; }
.filterbar .fb span { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 0 8px; background: var(--bg-sunk); height: 100%; display: grid; place-items: center; border-right: 1px solid var(--rule); }
.filterbar .fb select { border: none; background: var(--bg-elev); color: var(--ink); font: inherit; font-size: 13px; height: 100%; padding: 0 8px; cursor: pointer; outline: none; }
.filterbar .fb-search { height: 32px; width: 220px; font-size: 13px; flex: 0 1 220px; margin-left: auto; }
.filterbar .fb-count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.th-sort { color: inherit; }
.th-sort:hover, .th-sort.on { color: var(--ink); }
table.list td.id, table.list .pill { white-space: nowrap; }

/* ---------- Mobile menu ---------- */
.menu-btn { display: none; position: relative; }
.menu-btn span, .menu-btn span::before, .menu-btn span::after { display: block; width: 16px; height: 1.5px; background: currentColor; border-radius: 1px; transition: transform .2s, opacity .2s; }
.menu-btn span { position: relative; }
.menu-btn span::before, .menu-btn span::after { content: ""; position: absolute; left: 0; }
.menu-btn span::before { top: -5px; }
.menu-btn span::after { top: 5px; }
.menu-btn[aria-expanded="true"] span { background: transparent; }
.menu-btn[aria-expanded="true"] span::before { transform: translateY(5px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span::after { transform: translateY(-5px) rotate(-45deg); }
@media (max-width: 960px) {
  .menu-btn { display: grid; }
  .nav .wrap { gap: 16px; }
  .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; gap: 0; padding: 8px 20px 16px; background: var(--bg); border-bottom: 1px solid var(--rule); box-shadow: 0 16px 32px -16px #0003; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 13px 4px; font-size: 16px; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a.active { color: var(--ink); font-weight: 500; box-shadow: inset 2px 0 0 var(--accent); padding-left: 12px; }
  .admin aside { display: none; position: fixed; inset: 60px 0 0 0; z-index: 20; height: auto; overflow-y: auto; border-right: none; box-shadow: 0 16px 32px -16px #0003; }
  .admin aside.open { display: flex; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .right .status { display: none; }
  .admin .content { padding: 16px; }
  .filterbar .fb-search { margin-left: 0; flex: 1 1 100%; width: auto; }
  table.list { display: block; overflow-x: auto; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 18px; }
  .brand { font-size: 18px; }
  .nav-right .subscribe-btn { display: none; }
  .hero h1 { font-size: 36px; }
  .article-head h1, .page-head h1 { font-size: 34px; }
  .sec-head { flex-direction: column; align-items: flex-start; }
  .sec-head h2 { font-size: 32px; }
}
@media (max-width: 600px) {
  .topbar .crumbs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .right { gap: 6px; }
  .topbar .right .btn.ghost[href*="kind=commentary"] { display: none; }
  .topbar .right [data-toggle-theme] { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 26px; }
  .admin main { min-width: 0; overflow-x: hidden; }
  .filterbar .fb { flex: 1 1 calc(50% - 7px); }
  .filterbar .fb select { flex: 1; min-width: 0; }
  .editor .side { border-top: 1px solid var(--rule); }
}

/* Mobile: keep content inside the viewport and the brand on one line */
.brand { white-space: nowrap; flex: none; }
.article-grid > *, .hero .wrap > *, .featured > *, .project > * { min-width: 0; }
.prose { overflow-wrap: break-word; }
.prose pre.code, .prose table.data, .prose .eqblock { max-width: 100%; }
.ticker { overflow: hidden; }
@media (max-width: 960px) {
  .article-grid { grid-template-columns: minmax(0, 1fr); }
  .prose table.data { display: block; overflow-x: auto; }
}
@media (max-width: 480px) {
  .nav .wrap { gap: 10px; }
  .brand { font-size: 17px; gap: 9px; }
  .brand-mark { width: 26px; height: 26px; font-size: 15px; }
  .nav-right { gap: 8px; }
  .nav-right .icon-btn { width: 32px; height: 32px; }
}
@media (max-width: 360px) {
  .nav-right [data-toggle-theme] { display: none; }
}
.plot-foot { flex-wrap: wrap; gap: 4px 16px; }
.plot-foot > span { min-width: 0; overflow-wrap: anywhere; }
.project .formula { overflow-x: auto; }

/* Top menu shadow for contrast against page content */
.nav, .topbar { box-shadow: 0 1px 0 var(--rule), 0 6px 18px -8px rgb(18 20 26 / .18); }
[data-theme="dark"] .nav, [data-theme="dark"] .topbar { box-shadow: 0 1px 0 var(--rule), 0 8px 22px -8px rgb(0 0 0 / .6); }
.nav.scrolled { box-shadow: 0 1px 0 var(--rule), 0 10px 28px -10px rgb(18 20 26 / .28); }
[data-theme="dark"] .nav.scrolled { box-shadow: 0 1px 0 var(--rule), 0 12px 30px -10px rgb(0 0 0 / .75); }
.nav { transition: box-shadow .2s; }

/* Top nav: prominent hover / active state */
@media (min-width: 961px) {
  .nav-links { gap: 4px; align-self: stretch; align-items: center; }
  .nav-links a { position: relative; padding: 7px 12px; border-radius: 4px; transition: color .15s, background-color .15s; }
  .nav-links a::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -13px; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .2s ease; }
  .nav-links a:hover { color: var(--ink); background: var(--bg-sunk); }
  .nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
  .nav-links a.active { color: var(--ink); font-weight: 500; }
}
@media (max-width: 960px) {
  .nav-links a { transition: background-color .15s, color .15s; }
  .nav-links a:hover, .nav-links a:active { background: var(--bg-sunk); color: var(--ink); }
}
@media (min-width: 961px) {
  .nav-links { gap: 0; height: 100%; }
  .nav-links a { height: 100%; display: flex; align-items: center; padding: 0 14px; border-radius: 0; }
  .nav-links a::after { left: 0; right: 0; bottom: 0; height: 2px; }
}
/* Pressed-in look: darker at the top, fading down, with an inner top shadow */
@media (min-width: 961px) {
  .nav-links a:hover {
    background: linear-gradient(to bottom, rgb(18 20 26 / .09), rgb(18 20 26 / .025) 70%, transparent);
    box-shadow: inset 0 3px 6px -3px rgb(18 20 26 / .22), inset 1px 0 0 rgb(18 20 26 / .05), inset -1px 0 0 rgb(18 20 26 / .05);
  }
  .nav-links a:active {
    background: linear-gradient(to bottom, rgb(18 20 26 / .14), rgb(18 20 26 / .04) 70%, transparent);
    box-shadow: inset 0 4px 8px -3px rgb(18 20 26 / .3), inset 1px 0 0 rgb(18 20 26 / .07), inset -1px 0 0 rgb(18 20 26 / .07);
  }
  [data-theme="dark"] .nav-links a:hover {
    background: linear-gradient(to bottom, rgb(0 0 0 / .45), rgb(0 0 0 / .15) 70%, transparent);
    box-shadow: inset 0 3px 6px -3px rgb(0 0 0 / .8), inset 1px 0 0 rgb(255 255 255 / .04), inset -1px 0 0 rgb(255 255 255 / .04);
  }
}

/* Mobile header: taller bar, larger brand, thumb-sized buttons */
@media (max-width: 960px) {
  .nav .wrap { height: 72px; }
  .nav-links { top: 72px; }
  .brand { font-size: 22px; gap: 11px; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; border-width: 1.75px; }
  .nav-right { gap: 8px; }
  .nav-right .icon-btn { width: 44px; height: 44px; font-size: 15px; }
  .menu-btn span, .menu-btn span::before, .menu-btn span::after { width: 20px; height: 2px; }
  .menu-btn span::before { top: -6px; } .menu-btn span::after { top: 6px; }
  .menu-btn[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }
  .nav-links a { padding: 15px 4px; font-size: 17px; }
  .topbar { height: 64px; }
  .topbar .menu-btn { width: 44px; height: 44px; }
  .admin aside { inset: 64px 0 0 0; }
}
@media (max-width: 480px) {
  .brand { font-size: 21px; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; }
  .nav-right .icon-btn { width: 44px; height: 44px; }
}
@media (max-width: 374px) {
  .brand { font-size: 19px; }
  .brand-mark { width: 30px; height: 30px; font-size: 17px; }
  .nav-right [data-toggle-theme] { display: none; }
}

/* Keep KaTeX's hidden MathML (position:absolute) inside its formula so it can't widen the page */
.katex { position: relative; }
.ticker .wrap { position: relative; }
/* Safety net: nothing may create horizontal page overflow (clip keeps sticky nav working) */
html, body { overflow-x: clip; }

/* Header icon buttons: real SVG icons, sized to the button */
.icon-btn .ico { width: 18px; height: 18px; display: block; }
@media (max-width: 960px) { .icon-btn .ico { width: 21px; height: 21px; } }
.icon-btn { color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); }

/* Header: Subscribe matches the icon buttons' height at every width */
.nav-right .subscribe-btn { height: 34px; padding: 0 14px; }
@media (max-width: 960px) { .nav-right .subscribe-btn { height: 44px; padding: 0 18px; font-size: 15px; } }

/* admin share preview mock-ups */
.sp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
.sp-h { display: block; margin-bottom: 10px; }
.sp-img { position: relative; aspect-ratio: 1200 / 630; background: var(--bg-sunk); overflow: hidden; }
.sp-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-x .sp-img { border: 1px solid #cfd9de; border-radius: 16px; }
.sp-domain-x { position: absolute; left: 12px; bottom: 12px; background: rgb(0 0 0 / .77); color: #fff; font: 13px system-ui; padding: 2px 6px; border-radius: 4px; }
.sp-x-under { font: 13px system-ui; color: #536471; margin-top: 4px; }
.sp-li { border: 1px solid #e0dfdc; border-radius: 8px; overflow: hidden; background: #fff; }
.sp-li-body { padding: 10px 12px; display: grid; gap: 4px; font: 14px system-ui; color: #000; }
.sp-li-body span, .sp-im-body span { font-size: 12px; color: #666; }
.sp-fb { border: 1px solid #dadde1; background: #f0f2f5; }
.sp-fb-body { padding: 10px 12px; display: grid; gap: 3px; font: 15px system-ui; color: #050505; border-top: 1px solid #dadde1; }
.sp-up { font-size: 12px; text-transform: uppercase; color: #65676b; }
.sp-desc { font-size: 14px; color: #65676b; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.sp-slack { border-left: 4px solid #dddddd; padding: 2px 0 2px 12px; font: 15px system-ui; display: grid; gap: 4px; background: #fff; }
.sp-slack .sp-site { display: flex; gap: 6px; align-items: center; font-weight: 700; font-size: 14px; color: #1d1c1d; }
.sp-slack .sp-site img { width: 16px; height: 16px; }
.sp-slack a { color: #1264a3; font-weight: 700; }
.sp-slack p { margin: 0; color: #1d1c1d; font-size: 15px; }
.sp-slack .sp-img { max-width: 360px; border-radius: 8px; }
.sp-im { max-width: 300px; border-radius: 18px; overflow: hidden; background: #e9e9eb; }
.sp-im-body { padding: 8px 12px 10px; display: grid; gap: 2px; font: 14px -apple-system, system-ui; color: #000; }
.sp-tags td { padding: 8px 10px; }
@media (max-width: 960px) { .sp-grid { grid-template-columns: 1fr; } }
.sp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sp-head > div { display: grid; line-height: 1.25; }
.sp-head b { font-size: 16px; font-weight: 600; color: var(--ink); }
.sp-head span:not(.sp-ic) { font-size: 12.5px; color: var(--ink-3); }
.sp-ic { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg-elev); }
.sp-ic + .sp-ic { margin-left: -6px; }
.sp-ic svg { width: 20px; height: 20px; display: block; }
[data-theme="dark"] .sp-ic[style*="#000000"] { color: #fff !important; }
.sp-intro { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; padding: 22px 24px; margin-bottom: 20px; border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; background: var(--bg-elev); font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.sp-intro h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; color: var(--ink); margin: 0 0 8px; }
.sp-intro p { margin: 0 0 10px; }
.sp-intro p:last-child { margin: 0; }
.sp-intro b { color: var(--ink); font-weight: 600; }
.sp-intro ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 960px) { .sp-intro { grid-template-columns: 1fr; gap: 14px; } }
.sp-intro-short { grid-template-columns: 1fr; }

/* Admin sidebar: SVG icons */
.admin aside nav a .ic, .admin aside .signout .ic { width: 20px; height: 20px; flex: none; display: grid; place-items: center; color: var(--ink-3); position: relative; }
.admin aside nav a .ic .ico, .admin aside .signout .ic .ico { width: 18px; height: 18px; display: block; }
.admin aside nav a:hover .ic, .admin aside nav a.on .ic, .admin aside .signout:hover .ic { color: var(--ink); }
.admin aside nav a.on .ic { color: var(--accent); }
.admin aside nav a .ic-new i { position: absolute; right: -4px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg-elev); }
.admin aside nav a .ic-new i .ico { width: 9px; height: 9px; stroke-width: 3.2; }
.admin aside .signout { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 4px; font-family: var(--sans); font-size: 14px; color: var(--ink-2); }
.admin aside .signout:hover { background: var(--bg-sunk); color: var(--ink); }

/* Admin ⇄ website navigation */
.admin-brand { display: grid; gap: 10px; }
.visit-site { display: inline-flex; align-items: center; gap: 7px; align-self: start; justify-self: start; padding: 5px 10px 5px 8px; border: 1px solid var(--rule); border-radius: 20px; font-size: 12.5px; color: var(--ink-2); background: var(--bg); }
.visit-site .ico { width: 14px; height: 14px; }
.visit-site:hover { color: var(--ink); border-color: var(--rule-strong); background: var(--bg-sunk); }
.back-to-site { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius); font-size: 13.5px; font-weight: 500; color: var(--ink); background: var(--bg-elev); white-space: nowrap; flex: none; }
.back-to-site .ico { width: 16px; height: 16px; transition: transform .15s; }
.back-to-site:hover { border-color: var(--ink); }
.back-to-site:hover .ico { transform: translateX(-2px); }
.back-to-site .bts-short { display: none; }
.topbar-sep { width: 1px; height: 22px; background: var(--rule); flex: none; }
@media (max-width: 600px) {
  .back-to-site { height: 44px; }
  .back-to-site .bts-full { display: none; }
  .back-to-site .bts-short { display: inline; }
  .topbar-sep { display: none; }
}
.admin-brand .back-to-site { justify-self: stretch; justify-content: center; height: 38px; }
@media (max-width: 600px) { .admin-brand .back-to-site { height: 44px; } }
.topbar .right .back-to-site { height: 30px; font-size: 13px; padding: 0 12px 0 9px; }
.topbar .right .topbar-sep { height: 20px; margin: 0 2px; }
@media (max-width: 600px) { .topbar .right .back-to-site { height: 44px; } }
.topbar .right .back-to-site { height: 30px !important; box-sizing: border-box; }
@media (max-width: 600px) { .topbar .right .back-to-site { height: 44px !important; } }
/* "Go to homepage": warm yellow */
.topbar .right .back-to-site { background: #fbe9a6; border-color: #e3c35a; color: #4a3a05; }
.topbar .right .back-to-site:hover { background: #f7dc7a; border-color: #c9a53a; color: #2e2402; }
[data-theme="dark"] .topbar .right .back-to-site { background: #3a3110; border-color: #7a6420; color: #f4d77a; }
[data-theme="dark"] .topbar .right .back-to-site:hover { background: #4a3e14; border-color: #a3862c; color: #ffe697; }

/* Topbar "new" buttons: whole-button tint in the type-badge colours */
.topbar .act { gap: 7px; }
.topbar .act .ico { width: 15px; height: 15px; flex: none; }
.topbar .act-note { color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--bg-elev)); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.topbar .act-commentary { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.topbar .act-paper { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.topbar .act-note:hover, .topbar .act-commentary:hover { filter: brightness(.96); }
.topbar .act-paper:hover { filter: brightness(1.25); }

/* Topbar buttons: flat at rest, inverted gradient (pressed-in look) on :active */
.topbar .act, .topbar .right .back-to-site { transition: filter .12s, box-shadow .12s, transform .06s; }
.topbar .act:active, .topbar .right .back-to-site:active { background-image: linear-gradient(to bottom, rgba(0,0,0,.10), transparent 60%, rgba(255,255,255,.35)); box-shadow: inset 0 2px 3px rgba(0,0,0,.14); transform: translateY(1px); }
.topbar .act-paper:active { background-image: linear-gradient(to bottom, rgba(0,0,0,.35), transparent 60%, rgba(255,255,255,.10)); box-shadow: inset 0 2px 4px rgba(0,0,0,.45); }
[data-theme="dark"] .topbar .act:active, [data-theme="dark"] .topbar .right .back-to-site:active { background-image: linear-gradient(to bottom, rgba(0,0,0,.28), transparent 60%, rgba(255,255,255,.06)); }

/* Mobile "New" menu: the three create buttons collapse into one expanding panel */
.act-group { display: contents; }
.new-menu { display: none; position: relative; }
.new-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.new-menu > summary::-webkit-details-marker { display: none; }
.new-menu .chev .ico { width: 14px; height: 14px; transition: transform .18s; }
.new-menu[open] .chev .ico { transform: rotate(180deg); }
.new-panel { position: absolute; top: calc(100% + 10px); right: 0; width: min(330px, calc(100vw - 24px)); background: var(--bg-elev); border: 1px solid var(--rule-strong); border-radius: 8px; box-shadow: 0 18px 40px -14px rgb(18 20 26 / .35); padding: 8px; display: grid; gap: 6px; z-index: 30; transform-origin: top right; animation: np-in .16s ease-out; }
@keyframes np-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.np-head { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 6px 8px 4px; }
.np-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 6px; border: 1px solid transparent; min-height: 56px; }
.np-ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 6px; }
.np-ic .ico { width: 19px; height: 19px; }
.np-txt { display: grid; gap: 2px; min-width: 0; }
.np-txt b { font-weight: 500; font-size: 15px; color: var(--ink); }
.np-txt small { font-size: 12.5px; color: var(--ink-3); }
.np-go { margin-left: auto; color: var(--ink-3); }
.np-go .ico { width: 16px; height: 16px; }
.np-paper .np-ic { background: var(--ink); color: var(--bg); }
.np-note .np-ic { background: color-mix(in srgb, var(--blue) 14%, var(--bg-elev)); color: var(--blue); border: 1px solid color-mix(in srgb, var(--blue) 40%, transparent); }
.np-commentary .np-ic { background: color-mix(in srgb, var(--accent) 14%, var(--bg-elev)); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.np-paper:hover, .np-paper:active { background: color-mix(in srgb, var(--ink) 6%, transparent); border-color: color-mix(in srgb, var(--ink) 18%, transparent); }
.np-note:hover, .np-note:active { background: color-mix(in srgb, var(--blue) 8%, transparent); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.np-commentary:hover, .np-commentary:active { background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
@media (max-width: 960px) {
  .act-group { display: none; }
  .new-menu { display: block; }
  .topbar .new-menu > summary { height: 44px; padding: 0 12px 0 11px; gap: 6px; font-size: 14px; }
  .topbar .menu-btn { width: 52px; flex: none; }
  .topbar .right .back-to-site { height: 44px !important; }
}
@media (max-width: 600px) {
  .new-panel { position: fixed; top: 72px; right: 12px; left: 12px; width: auto; }
}
/* Mobile: every top-bar button shares the 44px tap height (matches Home) */
@media (max-width: 960px) {
  .topbar .right .btn, .topbar .right .back-to-site { height: 44px !important; box-sizing: border-box; padding: 0 14px; font-size: 14px; display: inline-flex; align-items: center; }
  .topbar .right .back-to-site { padding: 0 14px 0 12px; }
}
@media (max-width: 960px) { .topbar .right .icon-btn { width: 44px; height: 44px; flex: none; } }
.topbar .cancel-btn { gap: 6px; }
.topbar .cancel-btn .ico { width: 15px; height: 15px; }
/* Content table scrolls sideways when narrower than its columns (laptops) instead of clipping */
.table-scroll { overflow-x: auto; }

/* Mobile: no double-tap zoom (pinch-zoom still works) */
html, body, a, button, input, select, textarea, summary, label { touch-action: manipulation; }
/* iOS zooms into any focused field under 16px; keep fields at 16px on touch screens */
@media (max-width: 960px) and (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }
