:root {
  color-scheme: dark;
  --black: #070707;
  --ink: #111111;
  --panel: #161616;
  --line: #303030;
  --soft-line: #dadada;
  --paper: #f7f7f4;
  --white: #ffffff;
  --quiet: #999999;
  --muted: #676767;
  --display: "Arial Narrow", "Helvetica Neue Condensed", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--black); }
body { min-width: 320px; margin: 0; color: var(--paper); background: var(--black); font-family: var(--body); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr) 340px; background: var(--black); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 17px 18px; border-right: 1px solid var(--line); background: #080808; }
.brand-lockup { display: inline-flex; align-items: center; gap: 11px; width: max-content; color: var(--white); text-decoration: none; }
.brand-mark { width: 43px; height: 43px; object-fit: cover; border: 1px solid #4b4b4b; background: var(--white); }
.brand-name { display: grid; gap: 3px; }
.brand-name strong { font-size: 18px; font-weight: 700; letter-spacing: .12em; }
.brand-name small { color: #9e9e9e; font: 10px/1 var(--mono); letter-spacing: .14em; }
.side-label, .eyebrow { margin: 0; color: var(--quiet); font: 10px/1.1 var(--mono); letter-spacing: .14em; }
.workspace-control { position: relative; margin: 58px 7px 0; }
.workspace-switcher { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 11px; padding: 10px 0 12px; color: var(--white); border: 0; border-bottom: 1px solid #3a3a3a; background: transparent; text-align: left; }
.workspace-switcher strong, .workspace-switcher small { display: block; }
.workspace-switcher strong { font-size: 12px; font-weight: 600; }
.workspace-switcher small { margin-top: 4px; color: #777; font: 9px var(--mono); letter-spacing: .08em; }
.workspace-menu { position: absolute; z-index: 5; top: calc(100% + 8px); left: -8px; width: calc(100% + 16px); padding: 7px; border: 1px solid #555; background: var(--white); box-shadow: 5px 5px 0 #292929; }
.workspace-menu[hidden] { display: none; }
.workspace-menu ul { display: grid; gap: 2px; padding: 0; margin: 0 0 5px; list-style: none; }
.workspace-menu li button { width: 100%; padding: 9px; color: var(--ink); border: 0; background: transparent; text-align: left; font-size: 12px; }
.workspace-menu li button:hover, .workspace-menu li button[aria-current="true"] { color: var(--white); background: var(--ink); }
.quiet-button { width: 100%; padding: 9px; color: #444; border: 1px solid #d0d0d0; background: #f5f5f5; text-align: left; font-size: 11px; }
.quiet-button:hover { color: var(--white); border-color: var(--ink); background: var(--ink); }
.nav-list { display: grid; gap: 2px; margin-top: 35px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; color: #787878; border-left: 1px solid transparent; text-decoration: none; font-size: 13px; transition: color .16s ease, background .16s ease; }
.nav-item span { color: #505050; font: 10px var(--mono); }
.nav-item:hover, .nav-item.active { color: var(--white); border-left-color: var(--white); background: #151515; }
.sidebar-bottom { margin-top: auto; }
.policy-mini { display: grid; grid-template-columns: 8px 1fr; gap: 9px; padding: 12px 7px; border-top: 1px solid #303030; border-bottom: 1px solid #303030; }
.live-mark { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--white); box-shadow: 0 0 0 3px #292929; }
.policy-mini strong { display: block; color: var(--white); font: 10px var(--mono); letter-spacing: .1em; }
.policy-mini p { margin: 5px 0 0; color: #858585; font-size: 10px; line-height: 1.45; }
.build-mark { margin: 17px 7px 0; color: #555; font: 9px var(--mono); letter-spacing: .1em; }

.main-content { min-width: 0; padding: 24px clamp(24px, 5vw, 82px) 80px; background: var(--black); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 31px; border-bottom: 1px solid var(--line); }
.context-line { margin: 0; color: #858585; font: 10px var(--mono); letter-spacing: .08em; }
.context-line span { color: var(--white); margin: 0 8px; }
.topbar-state { display: flex; align-items: center; gap: 8px; padding-bottom: 1px; color: var(--quiet); font: 10px var(--mono); }
.state-dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.topbar-state.working { color: var(--paper); }
.topbar-state.working .state-dot { background: currentColor; animation: pulse 1s ease-in-out infinite; }
.topbar-state.complete { color: var(--white); }
.topbar-state.complete .state-dot { background: currentColor; }
.topbar-state.error { color: #a0a0a0; }
@keyframes pulse { 50% { opacity: .2; } }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 44px; padding: clamp(76px, 12vw, 150px) 0 clamp(42px, 7vw, 75px); }
.hero h1 { margin: 16px 0 0; color: var(--white); font: 700 clamp(53px, 6vw, 92px)/.87 var(--display); letter-spacing: -.075em; }
.hero h1 em { color: #969696; font-style: normal; }
.hero-copy { max-width: 370px; margin: 0 0 6px; color: #a4a4a4; font-size: 13px; line-height: 1.75; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1.04fr); align-items: stretch; }
.intake-card, .task-card { min-width: 0; padding: 24px; background: var(--paper); color: var(--ink); border: 1px solid var(--paper); }
.task-card { background: var(--white); border-color: var(--white); }
.card-head, .section-title, .audit-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.card-head h2, .section-title h2, .audit-header h2 { margin: 9px 0 0; font: 700 21px/1 var(--display); letter-spacing: -.035em; }
.mode-chip { padding: 6px 7px; color: var(--white); background: var(--ink); font: 9px var(--mono); letter-spacing: .09em; white-space: nowrap; }
.mode-chip.inverted { color: var(--ink); border: 1px solid var(--ink); background: transparent; }
.repository-form, .task-card form { margin-top: 35px; }
.repository-form label, .task-card label { display: block; font: 10px var(--mono); letter-spacing: .08em; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 0; margin-top: 11px; border-bottom: 1px solid var(--ink); }
.input-row input { min-width: 0; padding: 8px 0 11px; color: var(--ink); outline: 0; border: 0; background: transparent; font: 13px var(--mono); }
.input-row input::placeholder { color: #8a8a8a; }
.arrow-button { width: 36px; height: 36px; justify-self: end; color: var(--white); border: 0; background: var(--ink); font: 17px/1 var(--mono); transition: transform .16s ease; }
.arrow-button:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 #787878; }
.arrow-button:disabled { opacity: .65; cursor: wait; }
.field-note { margin: 12px 0 0; color: #646464; font-size: 10px; line-height: 1.55; }
.repository-summary { position: relative; display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: start; min-height: 88px; margin-top: 43px; padding: 15px 0 0; border-top: 1px solid #bebebb; }
.repository-summary.empty { grid-template-columns: 16px 1fr; color: #666; }
.repository-summary.empty p, .repository-summary.connected p { margin: 0; font-size: 11px; line-height: 1.55; }
.summary-index { font: 16px/1 var(--mono); }
.repository-summary.connected strong { grid-column: 1 / -1; font: 600 13px var(--mono); }
.repository-summary.connected p { grid-column: 1 / 3; color: #606060; }
.disconnect-button { align-self: end; padding: 0; color: #555; border: 0; background: transparent; font: 10px var(--mono); text-decoration: underline; }
.disconnect-button:hover { color: var(--ink); }

.evidence-spine { position: relative; display: grid; align-content: center; justify-items: center; gap: 12px; min-height: 100%; color: #888; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--black); font: 9px var(--mono); letter-spacing: .05em; overflow: hidden; }
.evidence-spine::before { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; content: ""; background: #555; }
.evidence-spine span { position: relative; z-index: 1; padding: 3px 1px; background: var(--black); writing-mode: vertical-rl; transform: rotate(180deg); }
.evidence-spine i { position: relative; z-index: 1; width: 7px; height: 7px; border: 1px solid #aaa; border-radius: 50%; background: var(--black); }
.task-card textarea { display: block; width: 100%; min-height: 153px; margin-top: 11px; padding: 0; resize: vertical; color: var(--ink); outline: 0; border: 0; background: transparent; font: 14px/1.65 var(--body); }
.task-card textarea:focus { background: linear-gradient(90deg, #f7f7f7, transparent); }
.task-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; border-top: 1px solid var(--soft-line); }
.task-footer > span { max-width: 230px; color: #686868; font-size: 10px; line-height: 1.45; }
.primary-button { display: inline-flex; align-items: center; gap: 26px; padding: 12px 12px 12px 15px; color: var(--white); border: 1px solid var(--ink); background: var(--ink); font-size: 12px; transition: transform .16s ease, box-shadow .16s ease; white-space: nowrap; }
.primary-button b { font: 17px/1 var(--mono); font-weight: 400; }
.primary-button:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 #919191; }
.primary-button:disabled { cursor: wait; opacity: .67; }

.evidence-section, .plan-section { margin-top: 63px; }
.section-title { align-items: end; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.section-title h2 { color: var(--white); }
.section-title > p { margin: 0; color: #838383; font: 10px var(--mono); text-align: right; }
.section-actions { display: flex; gap: 14px; align-items: center; }
.repository-map { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.map-cell { min-height: 132px; padding: 17px 15px; border-right: 1px solid var(--line); }
.map-cell:first-child { padding-left: 0; }
.map-cell:last-child { border-right: 0; }
.map-cell span, .evidence-caption { color: #858585; font: 9px var(--mono); letter-spacing: .1em; }
.map-cell strong { display: block; margin-top: 12px; color: var(--white); font: 600 clamp(29px, 3.3vw, 47px)/.9 var(--display); letter-spacing: -.06em; }
.map-cell p { min-height: 28px; margin: 9px 0 0; color: #969696; font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.evidence-list-wrap { margin-top: 25px; }
.evidence-caption { display: flex; justify-content: space-between; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.evidence-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
.evidence-list li { border-bottom: 1px solid var(--line); }
.evidence-list li:last-child { border-bottom: 0; }
.evidence-list a { display: grid; grid-template-columns: minmax(135px, .8fr) minmax(0, 1.7fr) 20px; gap: 16px; align-items: center; padding: 12px 4px 12px 0; color: var(--paper); text-decoration: none; }
.evidence-list a:hover { color: var(--white); background: #101010; }
.source-path { font: 11px var(--mono); overflow-wrap: anywhere; }
.source-reason { color: #969696; font-size: 11px; line-height: 1.45; }
.evidence-list a b { justify-self: end; color: #7c7c7c; font: 13px var(--mono); }
.evidence-empty { padding: 18px 0; color: #828282; font-size: 11px; }

.plan-section { margin-top: 68px; }
.text-button, .icon-button { color: var(--paper); border: 0; background: transparent; font: 10px var(--mono); letter-spacing: .06em; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.text-button:disabled { color: #555; cursor: not-allowed; }
.plan-output { min-height: 240px; padding: 25px 0; }
.empty-plan { display: grid; grid-template-columns: 38px 1fr; gap: 14px; max-width: 470px; color: #929292; }
.empty-plan span { color: var(--white); font: 10px var(--mono); }
.empty-plan p { margin: 0; font-size: 13px; line-height: 1.7; }
.plan-copy { max-width: 800px; margin: 0; white-space: pre-wrap; color: #e4e4e1; font: 12px/1.82 var(--mono); }

.control-section, .acceptance-section { margin-top: 68px; }
.control-grid { display: grid; grid-template-columns: minmax(0, 1.03fr) minmax(0, .97fr); border-bottom: 1px solid var(--line); }
.control-card { display: grid; gap: 14px; padding: 24px 24px 26px 0; border-right: 1px solid var(--line); }
.control-card label, .control-card legend { color: #a7a7a7; font: 10px var(--mono); letter-spacing: .08em; }
.control-card input, .control-card select, .control-card textarea { width: 100%; color: var(--paper); outline: 0; border: 1px solid #3d3d3d; border-radius: 0; background: #101010; font-size: 12px; }
.control-card input, .control-card select { min-height: 39px; padding: 9px 10px; }
.control-card textarea { padding: 10px; resize: vertical; line-height: 1.55; }
.control-card input:focus, .control-card select:focus, .control-card textarea:focus { border-color: #c9c9c9; background: #151515; }
.control-card select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #bbb 50%), linear-gradient(135deg, #bbb 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.control-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding-bottom: 12px; border-bottom: 1px solid #3d3d3d; }
.control-card-head span { color: var(--white); font: 10px var(--mono); letter-spacing: .12em; }
.control-card-head p { max-width: 330px; margin: 0; color: #777; font-size: 10px; line-height: 1.45; text-align: right; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-pair > div { display: grid; gap: 7px; }
.tool-scope { display: flex; flex-wrap: wrap; gap: 9px 14px; margin: 0; padding: 11px 12px; border: 1px solid #3d3d3d; }
.tool-scope legend { padding: 0 5px; }
.tool-scope label { display: inline-flex; align-items: center; gap: 6px; color: #d5d5d2; font-size: 11px; letter-spacing: 0; }
.tool-scope input { width: 13px; height: 13px; min-height: 0; margin: 0; accent-color: #f3f3ef; }
.control-output { min-height: 392px; padding: 25px 0 25px 25px; }
.control-output .plan-copy { max-height: 465px; overflow: auto; padding-right: 12px; }
.grant-record { display: grid; gap: 16px; max-width: 580px; }
.grant-status { display: flex; align-items: center; gap: 9px; color: #e5e5e1; font: 11px var(--mono); }
.grant-status::before { width: 8px; height: 8px; content: ""; border-radius: 50%; background: var(--white); box-shadow: 0 0 0 3px #353535; }
.grant-record dl { display: grid; grid-template-columns: 115px 1fr; gap: 9px 15px; margin: 0; padding: 16px 0; border-top: 1px solid #3d3d3d; border-bottom: 1px solid #3d3d3d; }
.grant-record dt { color: #7e7e7e; font: 10px var(--mono); }
.grant-record dd { margin: 0; color: #dededb; font: 11px/1.5 var(--mono); overflow-wrap: anywhere; }
.token-box { display: grid; gap: 8px; }
.token-box label { color: #929292; font: 9px var(--mono); letter-spacing: .09em; }
.token-box textarea { min-height: 90px; width: 100%; padding: 10px; resize: vertical; color: #e3e3df; border: 1px solid #4a4a4a; background: #101010; font: 10px/1.55 var(--mono); }
.token-actions { display: flex; gap: 10px; }
.token-actions button { padding: 8px 10px; color: #dadad7; border: 1px solid #555; background: transparent; font: 10px var(--mono); }
.token-actions button:hover { color: var(--black); background: var(--white); }
.receipt-record { display: grid; gap: 11px; max-width: 590px; }
.receipt-record .receipt-decision { padding: 10px 12px; color: #e0e0dc; border-left: 2px solid var(--white); background: #181818; font: 11px/1.55 var(--mono); }
.acceptance-ledger { display: grid; grid-template-columns: 112px 1fr; gap: 9px 15px; padding: 14px 0; border-top: 1px solid #3d3d3d; border-bottom: 1px solid #3d3d3d; }
.acceptance-ledger span { color: #7d7d7d; font: 10px var(--mono); }
.acceptance-ledger strong { color: #dfdfdc; font: 10px/1.45 var(--mono); overflow-wrap: anywhere; }

.review-section { margin-top: 68px; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.03fr) minmax(0, .97fr); border-bottom: 1px solid var(--line); }
.diff-card { padding: 24px 24px 24px 0; border-right: 1px solid var(--line); }
.diff-card label { color: #a0a0a0; font: 10px var(--mono); letter-spacing: .08em; }
.diff-card textarea { display: block; width: 100%; min-height: 238px; margin-top: 12px; padding: 13px; resize: vertical; color: #dfdfdb; outline: 0; border: 1px solid #3c3c3c; background: #101010; font: 11px/1.65 var(--mono); }
.diff-card textarea:focus { border-color: #aaa; background: #141414; }
.diff-card textarea::placeholder { color: #656565; }
.review-output { min-height: 323px; padding: 24px 0 24px 25px; }

.audit-rail { position: sticky; top: 0; height: 100vh; padding: 24px 19px; overflow-y: auto; border-left: 1px solid var(--line); background: #0c0c0c; }
.audit-header { align-items: center; padding-bottom: 15px; border-bottom: 1px solid #4b4b4b; }
.audit-header h2 { color: var(--white); font-size: 20px; }
.icon-button { width: 29px; height: 29px; border: 1px solid #bdbdbd; font-size: 15px; }
.icon-button:hover { color: var(--black); background: var(--white); }
.audit-meta { display: flex; align-items: baseline; gap: 7px; margin: 15px 0 23px; color: #818181; font: 10px var(--mono); }
.audit-meta span:first-child { color: var(--white); font: 23px/.9 var(--display); letter-spacing: -.08em; }
.audit-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid #353535; }
.audit-entry { display: grid; grid-template-columns: 59px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid #353535; }
.audit-entry time { padding-top: 2px; color: #777; font: 9px var(--mono); }
.audit-entry strong { color: #e1e1df; font: 10px var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.audit-entry p { margin: 5px 0 0; color: #929292; font-size: 10px; line-height: 1.48; overflow-wrap: anywhere; }
.audit-entry.error strong { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
.audit-entry.initial strong { color: #aaa; }
.audit-footnote { margin-top: 34px; padding-top: 13px; border-top: 1px solid #444; }
.audit-footnote span { color: #818181; font: 9px var(--mono); letter-spacing: .1em; }
.audit-footnote p { margin: 7px 0 0; color: #777; font-size: 10px; line-height: 1.55; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 222px minmax(0, 1fr); }
  .audit-rail { position: static; grid-column: 2; height: auto; min-height: 330px; border-top: 1px solid var(--line); border-left: 0; }
  .audit-list { max-width: 680px; }
}

@media (max-width: 810px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 15px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-mark { width: 36px; height: 36px; }
  .workspace-control, .nav-list, .sidebar-bottom { display: none; }
  .main-content { padding: 17px 18px 55px; }
  .context-line { max-width: 52%; font-size: 9px; line-height: 1.5; }
  .topbar-state { text-align: right; line-height: 1.4; }
  .hero { display: grid; gap: 27px; padding: 72px 0 42px; }
  .hero h1 { font-size: clamp(54px, 16vw, 78px); }
  .hero-copy { max-width: 500px; }
  .workbench { grid-template-columns: 1fr; gap: 0; }
  .evidence-spine { grid-template-columns: repeat(3, auto); grid-template-rows: 1fr; min-height: 44px; gap: 14px; border-top: 0; border-bottom: 0; }
  .evidence-spine::before { top: 50%; right: 0; bottom: auto; left: 0; width: auto; height: 1px; }
  .evidence-spine span { writing-mode: initial; transform: none; }
  .evidence-spine i { display: none; }
  .task-card, .intake-card { padding: 20px; }
  .evidence-section, .plan-section { margin-top: 53px; }
  .repository-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-cell { min-height: 118px; padding-left: 13px; border-bottom: 1px solid var(--line); }
  .map-cell:nth-child(2) { border-right: 0; }
  .map-cell:nth-child(3) { padding-left: 0; }
  .map-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .evidence-list a { grid-template-columns: 1fr 18px; gap: 5px; }
  .source-reason { grid-column: 1; }
  .evidence-list a b { grid-column: 2; grid-row: 1 / 3; }
  .audit-rail { padding: 22px 18px; }
  .section-actions { gap: 10px; }
  .review-grid, .control-grid { grid-template-columns: 1fr; }
  .diff-card { padding: 20px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .review-output { min-height: 230px; padding: 22px 0; }
  .control-section, .acceptance-section { margin-top: 53px; }
  .control-card { padding: 20px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .control-output { min-height: 230px; padding: 22px 0; }
  .field-pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
