:root {
  --ink: #17231f;
  --ink-2: #30423b;
  --muted: #718079;
  --line: #d9dfd9;
  --line-strong: #c5cec7;
  --paper: #f4f3ee;
  --surface: #fbfaf6;
  --surface-2: #ebece6;
  --green: #1d6553;
  --green-pale: #dceae4;
  --amber: #a66022;
  --amber-pale: #f4e8d7;
  --red: #a33d32;
  --red-pale: #f3ded9;
  --blue: #315f78;
  --blue-pale: #dce8ee;
  --shadow: 0 16px 45px rgba(23, 35, 31, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.skip-link { position: fixed; left: 16px; top: 12px; z-index: 100; transform: translateY(-180%); padding: 9px 13px; background: var(--ink); color: white; text-decoration: none; }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid #d39144; outline-offset: 3px; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 31px 24px 24px;
  background: #1b2824;
  color: #edf1ec;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; margin-bottom: 44px; }
.brand b { display: block; font-size: 17px; letter-spacing: -0.02em; }
.brand small { display: block; color: #93a39b; font-size: 9px; letter-spacing: 0.13em; margin-top: 3px; }
.brand-mark { width: 34px; height: 34px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding-bottom: 7px; border: 1px solid #50615a; border-radius: 50%; }
.brand-mark i { width: 3px; display: block; border-radius: 3px; background: #d9b076; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 12px; }
.primary-nav { display: grid; gap: 4px; }
.primary-nav a { display: flex; align-items: center; gap: 13px; padding: 10px 12px; border-radius: 5px; color: #aebbb5; text-decoration: none; font-size: 13px; font-weight: 600; transition: background .15s, color .15s; }
.primary-nav a b { font-size: inherit; font-weight: inherit; }
.primary-nav a span { color: #66776f; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.primary-nav a:hover { background: #24342f; color: #fff; }
.primary-nav a.active { background: #30443d; color: #fff; }
.primary-nav a.active span { color: #d9b076; }
.rail-foot { margin-top: auto; border-top: 1px solid #33423d; padding: 18px 4px 0; display: grid; gap: 16px; }
.transport-state { display: flex; gap: 10px; align-items: flex-start; color: #bec8c3; font-size: 11px; line-height: 1.4; }
.transport-state small { color: #73847c; }
.transport-state i { font-style: normal; }
.pulse { width: 7px; height: 7px; border-radius: 50%; margin-top: 4px; background: var(--green); box-shadow: 0 0 0 4px rgba(29, 101, 83, .12); }
.pulse.amber { background: #d79a56; box-shadow: 0 0 0 4px rgba(215, 154, 86, .12); }
.identity { color: #788980; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

main { min-width: 0; }
.topbar { height: 112px; padding: 27px clamp(24px, 4vw, 64px) 21px; display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--line); background: rgba(244, 243, 238, .94); position: sticky; top: 0; z-index: 8; backdrop-filter: blur(10px); }
.eyebrow { margin: 0 0 6px; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; color: var(--amber); }
h1 { margin: 0; font: 600 clamp(25px, 3vw, 34px)/1.05 Georgia, "Noto Serif TC", serif; letter-spacing: -.025em; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.locale-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.locale-control select { width: auto; min-width: 105px; padding: 7px 25px 7px 8px; background: transparent; }
.updated-at { color: var(--muted); font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font-size: 18px; }
.icon-button:hover { background: var(--surface); }
.nav-toggle, .nav-backdrop { display: none; }
.readiness-shell { padding: 16px clamp(24px, 4vw, 64px) 0; max-width: 1500px; margin: 0 auto; }
.readiness { display: grid; grid-template-columns: minmax(190px, 1.2fr) minmax(0, 2.1fr); border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 7px 24px rgba(23,35,31,.04); }
.readiness-details-grid { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.readiness:not([open]) .readiness-details-grid { display: none; }
.readiness-summary, .readiness-item { min-width: 0; padding: 12px 15px; border-right: 1px solid var(--line); }
.readiness-item:last-child { border-right: 0; }
.readiness-summary { display: flex; align-items: center; gap: 11px; }
.readiness-summary { cursor: pointer; list-style: none; }
.readiness-summary::-webkit-details-marker { display: none; }
.readiness-disclosure { display: none; margin-left: auto; color: var(--green); font: 9px/1 ui-monospace, monospace; text-transform: uppercase; }
.readiness-summary strong, .readiness-item strong { display: block; font-size: 11px; }
.readiness-summary small, .readiness-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.45; overflow-wrap: anywhere; }
.state-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-pale); }
.state-dot.available, .state-dot.ready, .state-dot.authenticated { background: var(--green); box-shadow: 0 0 0 4px var(--green-pale); }
.state-dot.development, .state-dot.unverified { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-pale); }
.view { padding: 34px clamp(24px, 4vw, 64px) 72px; max-width: 1500px; margin: 0 auto; }
.notice { position: fixed; top: 125px; right: 28px; z-index: 30; max-width: 420px; padding: 12px 16px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }
.notice.error { border-color: #d7a39e; color: var(--red); background: #fff8f6; }
.notice.actionable { display: flex; align-items: center; gap: 12px; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.intent-hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(270px, .7fr); gap: 0; margin-bottom: 24px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow); }
.intent-copy { padding: clamp(24px, 4vw, 46px); }
.intent-copy .eyebrow { margin-bottom: 12px; }
.intent-copy h2 { max-width: 680px; margin: 0; font: 500 clamp(25px, 3vw, 39px)/1.13 Georgia, "Noto Serif TC", serif; letter-spacing: -.028em; }
.intent-copy p { max-width: 620px; margin: 15px 0 22px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.intent-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.journey { padding: 25px; border-left: 1px solid var(--line); background: #eef0e9; display: grid; align-content: center; gap: 14px; }
.journey-step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.journey-step span { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--amber); font: 9px/1 ui-monospace, monospace; }
.journey-step b { display: block; font-size: 11px; }
.journey-step small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.metric { padding: 22px; border-right: 1px solid var(--line); min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; }
.metric:last-child { border-right: 0; }
.metric small { color: var(--muted); font-size: 11px; }
.metric strong { font: 500 30px/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.metric em { color: var(--muted); font: 9px/1 ui-monospace, monospace; font-style: normal; text-transform: uppercase; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 24px; margin-top: 24px; align-items: start; }
.stack { display: grid; gap: 16px; }
.panel { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 8px 28px rgba(23,35,31,.035); }
.panel-head { min-height: 58px; padding: 15px 19px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 13px; letter-spacing: -.01em; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }
.section-label { margin: 0 0 12px; color: var(--muted); font: 10px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.intro { max-width: 720px; margin-bottom: 28px; color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.empty { padding: 42px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink-2); font: 500 18px/1.3 Georgia, serif; margin-bottom: 7px; }
.empty p { margin: 0; font-size: 12px; line-height: 1.6; }

.list { display: grid; }
.list-row { padding: 15px 19px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.list-row:last-child { border-bottom: 0; }
.list-row h3 { margin: 0 0 5px; font-size: 13px; }
.list-row p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 3px; background: var(--surface-2); color: var(--ink-2); font: 9px/1 ui-monospace, monospace; text-transform: uppercase; white-space: nowrap; }
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.succeeded, .status.online, .status.active, .status.admitted { background: var(--green-pale); color: var(--green); }
.status.failed, .status.offline, .status.expired { background: var(--red-pale); color: var(--red); }
.status.awaiting_approval, .status.pending, .status.pending_admission, .status.blocked, .status.stale, .status.cancel_requested { background: var(--amber-pale); color: var(--amber); }
.status.running, .status.verifying, .status.queued, .status.received, .status.preparing { background: var(--blue-pale); color: var(--blue); }
.status.unknown, .status.partially_succeeded { background: #e9e1ef; color: #74548a; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field > span { font-size: 11px; font-weight: 650; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 10px; line-height: 1.5; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 2px; background: #fffefb; color: var(--ink); padding: 10px 11px; outline: none; font-size: 13px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(29,101,83,.08); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 8px; }
.check-card { display: flex; gap: 9px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); background: #fffefb; cursor: pointer; }
.check-card input { width: auto; margin: 2px 0 0; }
.check-card b { display: block; font-size: 11px; }
.check-card small { display: block; margin-top: 3px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; padding-top: 5px; }
.button { min-height: 34px; border: 1px solid var(--line-strong); background: #fffefb; color: var(--ink); padding: 8px 13px; border-radius: 3px; font-size: 11px; font-weight: 700; }
.button:hover { border-color: #89988f; }
.button.primary { border-color: var(--ink); background: var(--ink); color: white; }
.button.danger { border-color: #d5a6a0; color: var(--red); background: #fff8f6; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button[aria-busy="true"] { cursor: progress; }
.disabled-reason { display: block; width: 100%; margin-top: 7px; color: var(--amber); font-size: 10px; line-height: 1.45; text-align: right; }

.plan-step { position: relative; margin-top: 12px; padding: 17px; border: 1px solid var(--line); background: #f7f7f2; }
.plan-step:first-child { margin-top: 0; }
.step-number { margin-bottom: 15px; color: var(--amber); font: 10px/1 ui-monospace, monospace; }
.step-remove { position: absolute; top: 11px; right: 11px; border: 0; background: transparent; color: var(--muted); font-size: 17px; }
.code, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-block { overflow: auto; margin: 0; padding: 15px; background: #1d2925; color: #d9e1dc; font: 10px/1.6 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.hash { color: var(--muted); font: 9px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.channel-key { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); }
.channel-key div { min-width: 0; padding: 12px 10px; border-right: 1px solid var(--line); }
.channel-key div:last-child { border: 0; }
.channel-key b { display: block; font: 600 16px/1 Georgia, serif; margin-bottom: 5px; }
.channel-key small { display: block; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.channel-state { display: block; margin-top: 8px; color: var(--red); font: 8px/1 ui-monospace, monospace; text-transform: uppercase; }
.channel-state.available { color: var(--green); }
.task-detail { display: grid; gap: 12px; }
.uchat-layout { display: grid; grid-template-columns: minmax(230px, .55fr) minmax(0, 1.45fr); gap: 24px; align-items: start; }
.conversation-list { display: grid; }
.conversation-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; color: var(--ink); }
.conversation-row:last-child { border-bottom: 0; }
.conversation-row:hover, .conversation-row.active { background: #f0f1eb; }
.conversation-row b { display: block; font-size: 11px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.chat-workspace { display: grid; gap: 16px; }
.chat-draft { border-left: 3px solid var(--amber); background: var(--amber-pale); padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.chat-draft strong { font-size: 12px; }
.chat-draft p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 10px; }
.chat-thread { display: grid; gap: 10px; max-height: 520px; overflow: auto; padding: 2px; }
.chat-message { max-width: 84%; padding: 12px 14px; border: 1px solid var(--line); background: #fffefb; }
.chat-message.assistant { justify-self: start; border-left: 3px solid var(--green); }
.chat-message.person { justify-self: end; background: #eef0eb; }
.chat-message-head { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 9px; }
.chat-message-head strong { color: var(--ink-2); }
.chat-message p { margin: 9px 0; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.chat-message footer { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 8px; }
.chat-message footer code { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.chat-compose { border-top: 1px solid var(--line); padding-top: 17px; display: grid; gap: 12px; }
.chat-compose textarea[name="body"] { min-height: 78px; }
.chat-context { border: 1px solid var(--line); background: #f7f7f2; }
.chat-context summary { cursor: pointer; padding: 10px 12px; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.chat-context .form-grid { padding: 12px; border-top: 1px solid var(--line); }
.run { padding: 13px; background: #f4f4ef; border-left: 3px solid var(--line-strong); }
.run-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.run h4 { margin: 0; font-size: 11px; }
.run p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.evidence-chain { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.evidence-chain div { padding: 11px; background: var(--surface); }
.evidence-chain b { display: block; font-size: 10px; }
.evidence-chain small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.flow { display: flex; flex-wrap: wrap; gap: 0; padding: 14px 0 2px; }
.flow span { color: var(--muted); font: 9px/1 ui-monospace, monospace; }
.flow span:not(:last-child)::after { content: '→'; margin: 0 7px; color: var(--line-strong); }
.loading { min-height: 55vh; display: flex; justify-content: center; align-items: center; gap: 5px; color: var(--muted); }
.loading span { display: block; width: 5px; height: 16px; background: var(--green); animation: listen 1s ease-in-out infinite; }
.loading span:nth-child(2) { animation-delay: .12s; height: 25px; }
.loading span:nth-child(3) { animation-delay: .24s; height: 11px; }
.loading p { margin-left: 10px; font-size: 11px; }
@keyframes listen { 0%, 100% { transform: scaleY(.55); opacity: .45; } 50% { transform: scaleY(1); opacity: 1; } }

@media (max-width: 920px) {
  .shell { grid-template-columns: 78px minmax(0, 1fr); }
  .rail { padding: 24px 12px; align-items: center; }
  .brand span:last-child, .primary-nav a b { display: none; }
  .brand { margin-bottom: 36px; }
  .primary-nav a { width: 44px; height: 40px; justify-content: center; padding: 0; }
  .primary-nav a span { font-size: 10px; }
  .rail-foot { padding-left: 0; padding-right: 0; }
  .transport-state span:last-child, .identity { display: none; }
  .transport-state { justify-content: center; }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .section-grid { grid-template-columns: 1fr; }
  .uchat-layout { grid-template-columns: 1fr; }
  .readiness { grid-template-columns: 1fr; }
  .readiness-summary { border-bottom: 1px solid var(--line); }
  .readiness-details-grid { grid-template-columns: repeat(3, 1fr); }
  .intent-hero { grid-template-columns: 1fr; }
  .journey { border-left: 0; border-top: 1px solid var(--line); grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .shell { display: block; }
  .rail { position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); height: 100vh; padding: 25px 20px; align-items: stretch; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 14px 0 34px rgba(0,0,0,.18); }
  body.nav-open { overflow: hidden; }
  body.nav-open .rail { transform: translateX(0); }
  .brand { display: flex; margin-bottom: 25px; }
  .primary-nav { display: grid; overflow: visible; }
  .primary-nav a { width: auto; height: auto; justify-content: flex-start; padding: 11px 12px; }
  .primary-nav a b { display: block; }
  .rail-foot { display: grid; }
  .transport-state span:last-child, .identity { display: block; }
  .nav-toggle { display: grid; place-items: center; flex: 0 0 auto; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 9; width: 100%; border: 0; background: rgba(13, 24, 20, .48); }
  body.nav-open .nav-backdrop { display: block; }
  .topbar { height: 90px; padding: 19px 18px 16px; }
  .topbar { min-height: 90px; height: auto; justify-content: flex-start; gap: 9px; }
  .topbar-title { min-width: 0; flex: 1; }
  .topbar-title h1 { font-size: 21px; line-height: 1.08; }
  .topbar-actions { gap: 7px; }
  .updated-at { display: none; }
  .locale-control span { display: none; }
  .locale-control select { min-width: 94px; max-width: 96px; }
  .readiness-shell { padding: 12px 16px 0; }
  .readiness { grid-template-columns: 1fr; }
  .readiness-summary, .readiness-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .readiness-details-grid { grid-template-columns: 1fr; }
  .readiness-disclosure { display: block; }
  .readiness-item:last-child { border-bottom: 0; }
  .view { padding: 22px 16px 56px; }
  .intent-copy { padding: 24px 20px; }
  .journey { grid-template-columns: 1fr; padding: 20px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 96px; padding: 16px; }
  .metric:nth-child(2n) { border-right: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full, .form-actions { grid-column: 1; }
  .channel-key { grid-template-columns: repeat(2, 1fr); }
  .channel-key div { border-bottom: 1px solid var(--line); }
  .list-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .disabled-reason { text-align: left; }
  .evidence-chain { grid-template-columns: 1fr 1fr; }
}

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