:root {
  --ground: #f4f2ee;
  --surface: #fbfaf8;
  --surface-2: #efece6;
  --ink: #20232a;
  --muted: #6b7078;
  --faint: #9aa0a8;
  --border: #e4e0d8;
  --border-strong: #d5d0c6;
  --accent: #2f56c7;
  --accent-ink: #ffffff;
  --accent-soft: #e7ecfb;
  --queued: #5b6472;   --queued-bg: #eceef1;
  --drafting: #9a6414; --drafting-bg: #f6ecda;
  --ready: #1f7a4d;    --ready-bg: #e0f0e6;
  --rejected: #a23b4e; --rejected-bg: #f4e2e5;
  --shadow: 0 1px 2px rgba(40,36,28,.05), 0 6px 20px -12px rgba(40,36,28,.22);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #131417; --surface: #1a1c20; --surface-2: #212429;
    --ink: #e9e7e2; --muted: #9aa0a8; --faint: #6a7078;
    --border: #2a2d33; --border-strong: #363a41;
    --accent: #6f8ff0; --accent-ink: #10131a; --accent-soft: #23283a;
    --queued: #aeb6c2; --queued-bg: #262a30;
    --drafting: #d8a24e; --drafting-bg: #322a1c;
    --ready: #5fc48c; --ready-bg: #17291f;
    --rejected: #e4899a; --rejected-bg: #2e1e22;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --ground: #131417; --surface: #1a1c20; --surface-2: #212429;
  --ink: #e9e7e2; --muted: #9aa0a8; --faint: #6a7078;
  --border: #2a2d33; --border-strong: #363a41;
  --accent: #6f8ff0; --accent-ink: #10131a; --accent-soft: #23283a;
  --queued: #aeb6c2; --queued-bg: #262a30;
  --drafting: #d8a24e; --drafting-bg: #322a1c;
  --ready: #5fc48c; --ready-bg: #17291f;
  --rejected: #e4899a; --rejected-bg: #2e1e22;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6);
}
:root[data-theme="light"] {
  --ground: #f4f2ee; --surface: #fbfaf8; --surface-2: #efece6;
  --ink: #20232a; --muted: #6b7078; --faint: #9aa0a8;
  --border: #e4e0d8; --border-strong: #d5d0c6;
  --accent: #2f56c7; --accent-ink: #ffffff; --accent-soft: #e7ecfb;
  --queued: #5b6472; --queued-bg: #eceef1;
  --drafting: #9a6414; --drafting-bg: #f6ecda;
  --ready: #1f7a4d; --ready-bg: #e0f0e6;
  --rejected: #a23b4e; --rejected-bg: #f4e2e5;
  --shadow: 0 1px 2px rgba(40,36,28,.05), 0 6px 20px -12px rgba(40,36,28,.22);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar { border-right: 1px solid var(--border); padding: 20px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand .glyph { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.brand .name { font-weight: 650; letter-spacing: -.01em; }
.brand .sub { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--muted); font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ico { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.themebtn { display: flex; align-items: center; gap: 9px; background: none; border: 1px solid var(--border); color: var(--muted); padding: 8px 11px; border-radius: var(--radius-sm); font-size: 12.5px; }
.themebtn:hover { border-color: var(--border-strong); color: var(--ink); }
.themebtn .ico { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* Main */
.main { padding: 26px 30px 60px; max-width: 1120px; }
.topline { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topline h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 680; }
.topline .when { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.crumb { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 14px; display: inline-flex; align-items: center; gap: 6px; }
.crumb:hover { color: var(--accent); }

/* Stat strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 30px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.stat .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-size: 27px; font-weight: 680; letter-spacing: -.02em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; color: var(--faint); margin-top: 3px; }
.stat .d b { color: var(--ready); font-weight: 600; }

/* Section headers */
.section { margin-bottom: 34px; }
h2 { font-size: 12px; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 13px; }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 0 0 13px; }
.sec-head h2 { margin: 0; }
.sec-head .n { font-family: var(--mono); font-size: 11px; color: var(--accent-ink); background: var(--accent); border-radius: 20px; padding: 1px 8px; font-weight: 600; }
.sec-head .rule { flex: 1; height: 1px; background: var(--border); }

/* Chips + legacy .badge */
.chip, .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550; padding: 2px 9px; border-radius: 20px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.pillar, .badge.pillar { background: transparent; border: 1px solid var(--border-strong); color: var(--ink); }
.chip.s-queued { background: var(--queued-bg); color: var(--queued); }
.chip.s-drafting { background: var(--drafting-bg); color: var(--drafting); }
.chip.s-ready { background: var(--ready-bg); color: var(--ready); }
.chip.s-rejected { background: var(--rejected-bg); color: var(--rejected); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.mono { font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; }
.chip.flag { background: var(--rejected-bg); color: var(--rejected); }

/* Rows (queue + pipeline) */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center; }
.row .title { font-weight: 560; font-size: 14.5px; letter-spacing: -.01em; }
.row .title a:hover { color: var(--accent); }
.meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 6px; }
.meta .t { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.rowacts { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn, button.approve, button.reject { border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 550; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; transition: transform .08s, border-color .12s, background .12s, color .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.approve { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.approve:hover { color: var(--accent-ink); filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 9px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger:hover, button.reject:hover { border-color: var(--rejected); color: var(--rejected); }
button.reject { color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn .ico { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }

/* Pipeline stepper */
.steps { display: flex; align-items: center; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 5px; }
.step .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.step.done .pip { background: var(--ready); }
.step.now .pip { background: var(--drafting); box-shadow: 0 0 0 3px var(--drafting-bg); }
.step .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.step.now .lbl { color: var(--drafting); font-weight: 600; }
.step .bar { width: 16px; height: 1.5px; background: var(--border-strong); }
.step.done .bar { background: var(--ready); }

/* Ready cards */
.ready-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ready-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.ready-card .thumb { height: 116px; position: relative; }
.ready-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ready-card .thumb .tag { position: absolute; left: 11px; bottom: 11px; }
.ready-card .card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 11px; flex: 1; }
.ready-card h3 { margin: 0; font-size: 16px; letter-spacing: -.015em; font-weight: 640; line-height: 1.28; text-wrap: balance; }
.ready-card h3 a:hover { color: var(--accent); }
.cmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cmeta .t { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.actionsbar { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; }
.actionrow { display: flex; gap: 8px; align-items: center; }
.actionrow .grow { flex: 1; }

/* Export dropdown */
.menu-wrap { position: relative; }
.caret { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 214px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 5px; display: none; }
.menu.open { display: block; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; color: var(--ink); font-size: 13px; padding: 8px 10px; border-radius: 6px; }
.menu button:hover, .menu a:hover { background: var(--surface-2); color: var(--ink); }
.menu .k { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.menu .div { height: 1px; background: var(--border); margin: 4px 2px; }

/* Toast */
#ch-toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px); background: var(--ink); color: var(--ground); font-size: 13px; font-weight: 550; padding: 9px 16px; border-radius: 20px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 100; }
#ch-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Forms */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.create { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 30px; overflow: hidden; }
details.create > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 580; font-size: 14px; }
details.create > summary::-webkit-details-marker { display: none; }
details.create > summary .plus { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
details.create > summary .plus svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }
details.create[open] > summary { border-bottom: 1px solid var(--border); }
.create-body { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.create-body h3 { margin: 0 0 12px; font-size: 12px; font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.quick-form { display: grid; gap: 10px; grid-template-columns: 1fr; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; font-weight: 500; }
textarea, input[type=text], input[type=email], input[type=date], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--ground); color: var(--ink); font-family: inherit; font-size: 14px;
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; align-items: center; }

.empty { color: var(--faint); font-style: italic; padding: 14px 15px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); font-size: 13.5px; }

/* Generic card (feeds/planner/vault list items, detail blocks) */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px; margin-bottom: 10px; }
.card-title { font-weight: 580; font-size: 14.5px; letter-spacing: -.01em; margin-bottom: 4px; }
.card-title a:hover { color: var(--accent); }
.card-meta { color: var(--faint); font-size: 12.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }

/* Detail page */
.detail-body { max-width: 720px; }
.prose { white-space: pre-wrap; font-size: 15px; line-height: 1.7; }
.hero-img { max-width: 100%; border-radius: var(--radius); margin-bottom: 14px; display: block; }
.field-block { margin-bottom: 16px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ready-grid, .create-body { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .main { padding: 22px 18px 50px; }
}

/* demo ribbon */
.demo-ribbon{position:sticky;top:0;z-index:200;background:#20232a;color:#f4f2ee;font-size:12.5px;padding:8px 16px;text-align:center;letter-spacing:.01em;border-bottom:1px solid rgba(0,0,0,.2)}
.demo-ribbon strong{background:#6f8ff0;color:#10131a;border-radius:5px;padding:1px 7px;margin-right:8px;font-size:11px;letter-spacing:.06em;text-transform:uppercase}
.demo-ribbon a{color:#9db4f5;font-weight:600}
.app{min-height:calc(100vh - 36px)}
.sidebar{top:36px;height:calc(100vh - 36px)}
