@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* Yokkei — paper & ink, with a vermilion seal. */
:root {
  --paper: #f8f6f2;
  --paper2: #efece6;
  --card: #ffffff;
  --ink: #171a18;
  --ink2: #454341;
  --gray: #73706c;
  --line: #e4e0d9;
  --line2: #d6d1c8;
  --seal: #e0452b;
  --seal-soft: #fbe6e1;

  /* legacy names used across the app */
  --bg: var(--paper);
  --bg2: var(--paper2);
  --panel: var(--card);
  --panel2: var(--paper);
  --text: var(--ink);
  --muted: var(--gray);
  --dim: #8d8a85;
  --violet: var(--seal);
  --violet2: var(--seal);
  --amber: #b97a12;
  --green: #1f8a5b;
  --red: #c93636;
  --blue: #2f6aa8;

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(23, 26, 24, 0.04), 0 8px 30px rgba(23, 26, 24, 0.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 0.5em; font-family: var(--display); font-weight: 300; line-height: 1.08; letter-spacing: -0.02em; }
h3 { font-size: 21px; font-weight: 400; }
h4 { font-size: 17px; font-weight: 400; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--paper2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--gray); }
.dim { color: var(--dim); font-size: 13px; }
.tone { color: var(--gray); }                     /* second half of a two-tone headline */
.grad { color: var(--seal); }

/* mono eyebrow with a seal dot */
.eyebrow { font: 500 11.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); display: inline-flex; align-items: center; gap: 9px; }
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--seal); }
.eyebrow.plain::before { display: none; }

.logo { display: inline-flex; align-items: center; gap: 10px; font: 500 21px/1 var(--display); letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.logo svg { width: 28px; height: 28px; }

/* grain: a stippled ink texture, our take on printed paper */
.grain { position: relative; isolation: isolate; }
.grain::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.55;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.09  0 0 0 0 0.1  0 0 0 0 0.09  0 0 0 9 -6.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  -webkit-mask-image: radial-gradient(ellipse at center, #000 10%, transparent 72%);
  mask-image: radial-gradient(ellipse at center, #000 10%, transparent 72%);
}
.grain.full::before { -webkit-mask-image: none; mask-image: none; opacity: 0.35; }

/* buttons */
button, .btn {
  appearance: none; border: 1px solid var(--line2); background: var(--card); color: var(--ink);
  padding: 9px 15px; border-radius: 5px; font: 500 14px/1.2 var(--sans); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; transition: 0.15s; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--ink); }
button:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.primary:hover { background: #000; }
.gold { background: var(--seal); color: #fff; border-color: var(--seal); }
.gold:hover { filter: brightness(0.95); border-color: var(--seal); }
.ghost { background: transparent; border-color: transparent; }
.ghost:hover { border-color: var(--line2); }
.danger { color: var(--red); }
.small { padding: 6px 10px; font-size: 13px; }
.primary .dim, .gold .dim { color: inherit; opacity: 0.6; }
.link-arrow { font-weight: 500; text-decoration: underline; text-decoration-color: var(--ink); }

/* forms */
input, textarea, select {
  width: 100%; background: var(--card); color: var(--ink); border: 1px solid var(--line2); border-radius: 5px;
  padding: 10px 12px; font: 15px/1.4 var(--sans);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: transparent; }
label { display: block; font: 500 11px/1.3 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink2); margin: 14px 0 6px; }
label.check { display: flex; gap: 9px; align-items: center; color: var(--ink); font: 400 15px/1.4 var(--sans); text-transform: none; letter-spacing: 0; }
label.check input { width: auto; accent-color: var(--seal); }
progress { accent-color: var(--seal); height: 8px; }
details summary { font-size: 13px; }

/* surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.band { background: var(--paper2); border-radius: 8px; padding: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* list rows with arrows */
.rows a, .rows .r { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); color: var(--ink2); text-decoration: none; font-size: 16px; }
.rows a::after, .rows .r::after { content: "→"; color: var(--gray); transition: 0.15s; }
.rows a:hover { color: var(--ink); }
.rows a:hover::after { transform: translateX(3px); color: var(--seal); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; font: 500 11px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; background: var(--paper2); color: var(--ink2); border: 1px solid transparent; }
.pill.posted, .pill.done, .pill.live, .pill.low { background: #e5f3ec; color: var(--green); }
.pill.scheduled, .pill.planned, .pill.medium { background: #e6eef7; color: var(--blue); }
.pill.awaiting_approval, .pill.suggested, .pill.now { background: var(--seal-soft); color: var(--seal); }
.pill.failed, .pill.high, .pill.deleted { background: #f8e3e3; color: var(--red); }

.stat { font: 300 38px/1.05 var(--display); letter-spacing: -0.03em; margin: 4px 0; }
.empty { text-align: center; padding: 44px 20px; color: var(--gray); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 500 11px/1.3 var(--mono); color: var(--gray); text-transform: uppercase; letter-spacing: 0.06em; }
.tablewrap { overflow-x: auto; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast div { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 6px; box-shadow: var(--shadow); max-width: 90vw; font-size: 14px; }
#toast div.err { background: var(--seal); }
.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }
.working { display: flex; align-items: center; gap: 12px; padding: 18px; border: 1px dashed var(--line2); border-radius: var(--radius); color: var(--ink2); background: var(--card); font: 500 13px/1.4 var(--mono); }
.working .spinner { color: var(--seal); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--paper2); border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.side select { background: var(--card); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-radius: 5px; color: var(--ink2); text-decoration: none; font-weight: 500; font-size: 14.5px; }
.nav a:hover { background: rgba(23, 26, 24, 0.05); color: var(--ink); }
.nav a.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 2px 0 0 var(--seal); }
.nav .ic { width: 18px; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--gray); }
.nav a.on .ic { color: var(--seal); }
.nav .badge { margin-left: auto; background: var(--seal); color: #fff; border-radius: 4px; font: 500 11px/1 var(--mono); padding: 3px 6px; }
.main { padding: 30px clamp(16px, 3.5vw, 48px) 90px; max-width: 1240px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 34px !important; }
.credits { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 5px; background: var(--card); border: 1px solid var(--line); font: 500 13px/1 var(--mono); text-decoration: none; color: var(--ink); }
.credits b { color: var(--seal); font-weight: 500; }
.thumb { aspect-ratio: 1; background: var(--paper2); border-radius: 5px; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line); font-size: 12px; color: var(--gray); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.post { display: grid; grid-template-columns: 74px 1fr auto; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); align-items: start; }
.post:last-child { border-bottom: 0; }
.post .thumb { width: 74px; }
.post .text { white-space: pre-wrap; word-break: break-word; color: var(--ink2); }
.plat { font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: transparent; border-color: transparent; color: var(--gray); }
.tabs button:hover { color: var(--ink); border-color: var(--line2); }
.tabs button.on { background: var(--card); color: var(--ink); border-color: var(--line2); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
dialog { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 26px; width: min(640px, 94vw); box-shadow: 0 30px 80px rgba(23,26,24,0.25); }
dialog::backdrop { background: rgba(23, 26, 24, 0.35); backdrop-filter: blur(2px); }
.menu-btn { display: none; }

@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; width: 268px; transform: translateX(-100%); transition: 0.2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
}
@media (max-width: 600px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { font-size: 32px; }
  .post { grid-template-columns: 56px 1fr; }
  .post .thumb { width: 56px; }
  .post .acts { grid-column: 1 / -1; justify-content: flex-start !important; }
  .top h1 { font-size: 28px !important; }
}
