:root {
  color-scheme: light;
  --ink: #18201d;
  --ink-soft: #3f4b46;
  --muted: #69756f;
  --line: #dce2df;
  --line-strong: #c7d0cc;
  --canvas: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --nav: #12201b;
  --nav-line: #263a33;
  --green: #08775d;
  --green-hover: #075f4c;
  --green-soft: #e9f5f0;
  --blue: #1d64a6;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning: #8e5707;
  --warning-soft: #fff5df;
  --shadow: 0 1px 2px rgba(21, 34, 29, .05), 0 8px 24px rgba(21, 34, 29, .04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: var(--blue); }
.top-link { color: #d1ddd8; text-decoration: none; font-size: 12px; font-weight: 650; }
.top-link:hover { color: white; }

.app { min-height: 100vh; display: grid; grid-template-rows: 60px 1fr; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 24px; background: var(--nav); color: white; border-bottom: 1px solid var(--nav-line);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 720; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; background: #2ab38b; color: #071510; border-radius: 5px; font-size: 13px; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy small { color: #91a69e; font-weight: 500; font-size: 10px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-meta { color: #b7c7c1; font-size: 12px; }
.env-pill { border: 1px solid #3b5048; color: #bdd0c8; border-radius: 999px; padding: 4px 9px; font-size: 10px; font-weight: 700; text-transform: uppercase; }

.workspace { display: grid; grid-template-columns: 316px minmax(0, 1fr); min-height: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); min-height: 0; }
.sidebar-section { padding: 18px; border-bottom: 1px solid #e8ecea; }
.sidebar-list { padding: 12px; overflow: auto; }
.main { min-width: 0; padding: 28px 30px 44px; overflow: auto; }
.main-inner { min-width: 0; width: min(1220px, 100%); margin: 0 auto; display: grid; gap: 18px; }

h1 { font-size: 23px; line-height: 1.25; margin: 0; letter-spacing: 0; }
h2 { font-size: 14px; line-height: 1.3; margin: 0; letter-spacing: 0; }
h3 { font-size: 13px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.micro { font-size: 10px; }
.stack { display: grid; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 2px 0 4px; }
.page-copy { display: grid; gap: 7px; }
.summary-row { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 4px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; color: var(--ink-soft); font-size: 12px; }
.summary-chip strong { color: var(--ink); }
.summary-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); min-height: 48px; }
.panel-body { padding: 16px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#run-meta { min-width: 0; overflow-wrap: anywhere; }
.button { border: 1px solid var(--line-strong); background: white; color: var(--ink); min-height: 36px; padding: 7px 12px; border-radius: 5px; font-weight: 650; }
.button:hover { border-color: #9eaca6; background: #fafcfb; }
.button.primary { background: var(--green); color: white; border-color: var(--green); }
.button.primary:hover { background: var(--green-hover); }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; }
.field { display: grid; gap: 6px; }
.field label { font-size: 11px; font-weight: 750; color: #4d5954; text-transform: uppercase; }
input, textarea, select { width: 100%; border: 1px solid #bdc8c3; border-radius: 5px; background: white; color: var(--ink); padding: 9px 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 119, 93, .11); }
textarea { min-height: 108px; resize: vertical; line-height: 1.55; }

.dropzone { position: relative; display: flex; align-items: center; gap: 11px; border: 1px dashed #a7b4ae; padding: 12px; border-radius: 5px; background: var(--surface-soft); }
.dropzone:hover { border-color: var(--green); background: #f5faf8; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); border-radius: 4px; font-size: 18px; }
.upload-copy { display: grid; gap: 2px; }
.doc-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-stat { padding: 9px 10px; background: var(--surface-soft); border: 1px solid #e6ebe8; border-radius: 4px; }
.doc-stat strong { display: block; font-size: 17px; }
.doc-list { display: grid; gap: 7px; }
.doc { border: 1px solid var(--line); border-radius: 5px; padding: 10px; display: grid; gap: 8px; background: white; }
.doc:hover { border-color: #bac5c0; }
.doc-title { overflow-wrap: anywhere; font-size: 12px; font-weight: 680; line-height: 1.4; }
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 7px; border-radius: 999px; background: var(--green-soft); color: #08664f; font-size: 10px; font-weight: 750; }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.working { background: var(--warning-soft); color: var(--warning); }
.progress { height: 3px; background: #e8ecea; overflow: hidden; border-radius: 2px; }
.progress > span { display: block; height: 100%; background: var(--green); }

.composer { overflow: hidden; }
.composer-meta { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.composer-meta select { width: auto; min-width: 190px; padding: 6px 9px; font-size: 12px; }
.composer textarea { border: 0; border-radius: 0; box-shadow: none; min-height: 116px; padding: 15px 16px; }
.composer textarea:focus { box-shadow: none; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; }
.suggestion { border: 0; background: #eef3f1; color: #56625d; border-radius: 4px; padding: 5px 8px; font-size: 11px; }
.suggestion:hover { color: var(--green); background: var(--green-soft); }

.result-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .75fr); gap: 14px; align-items: start; }
.answer { min-height: 330px; }
.answer-text { font-size: 15px; line-height: 1.78; white-space: pre-wrap; padding: 4px 1px; }
.answer-text a { color: var(--blue); text-decoration: none; font-weight: 750; }
.answer-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.citation-list { display: grid; gap: 8px; }
.citation { border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); overflow: hidden; }
.citation[open] { border-color: #b9c9c2; background: white; }
.citation summary { cursor: pointer; font-weight: 650; padding: 10px 11px; font-size: 12px; }
.citation pre { margin: 0; padding: 0 11px 11px; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.55; color: #4d5c56; max-height: 220px; overflow: auto; }
.citation a { display: block; padding: 8px 11px; border-top: 1px solid var(--line); text-decoration: none; }
.empty { min-height: 250px; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }
.empty-mark { width: 42px; height: 42px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid var(--line); color: #91a09a; border-radius: 5px; font-size: 20px; }
.status { min-height: 20px; color: var(--muted); }
.status.error { color: var(--danger); }

.control-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: 14px; align-items: end; }
.file-control { position: relative; min-height: 74px; border: 1px dashed #a7b4ae; border-radius: 5px; background: var(--surface-soft); display: flex; align-items: center; padding: 12px 14px; gap: 12px; }
.file-control input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 8px; }
.metric { border-right: 1px solid var(--line); padding: 4px 14px; }
.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 22px; margin-top: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; background: var(--surface-soft); }
tbody tr:hover { background: #fafcfb; }
.report-grid { min-width: 0; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 14px; align-items: stretch; }
.conclusion-list { display: grid; gap: 12px; }
.conclusion { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.conclusion > span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 800; }
.conclusion p { line-height: 1.6; color: var(--ink-soft); }
.failure-row { display: grid; grid-template-columns: 90px 1fr 28px; gap: 9px; align-items: center; margin: 10px 0; font-size: 12px; }
.failure-track { height: 7px; background: #edf1ef; border-radius: 4px; overflow: hidden; }
.failure-track i { display: block; height: 100%; background: var(--green); }
.empty.compact { min-height: 110px; }
.guide-layout { max-width: 1120px; }
.doc-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 0; }
.doc-steps > div { padding: 20px; border-right: 1px solid var(--line); display: grid; gap: 8px; }
.doc-steps > div:last-child { border-right: 0; }
.doc-steps > div > strong { color: var(--green); font-size: 11px; }
.code-block { margin: 0; padding: 14px; border: 1px solid #263b34; border-radius: 5px; background: #12201b; color: #dce9e4; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.service-origin { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border: 1px solid #b7cbc3; border-left: 4px solid var(--green); background: var(--green-soft); border-radius: 5px; }
.service-origin span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.service-origin strong { overflow-wrap: anywhere; font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.endpoint-table code, td code { overflow-wrap: anywhere; color: #245064; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.method { display: inline-flex; min-width: 40px; justify-content: center; padding: 3px 5px; border-radius: 3px; font: 800 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.method.get { color: #175f91; background: #e7f2fa; }
.method.post { color: #08664f; background: var(--green-soft); }
.inline-note { margin-top: 14px; padding: 12px 14px; border-left: 4px solid #d59a24; background: var(--warning-soft); color: var(--ink-soft); line-height: 1.6; }
.flow-list { display: grid; gap: 0; }
.flow-list > div { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); line-height: 1.6; color: var(--ink-soft); }
.flow-list > div:last-child { border-bottom: 0; }
.flow-list > div > strong { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 11px; }
.flow-list.compact > div { padding: 9px 0; }
.route-flow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: stretch; gap: 20px; }
.route-flow span { position: relative; display: grid; place-items: center; min-height: 66px; padding: 10px; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 5px; background: var(--surface-soft); text-align: center; font-size: 12px; font-weight: 700; }
.route-flow i { display: none; }
.route-flow span:not(:last-child)::after { content: "›"; position: absolute; right: -16px; color: var(--blue); font-size: 20px; }
.guide-skill-grid > div { display: grid; align-content: start; gap: 12px; padding: 4px 14px 4px 0; }
.guide-skill-grid > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.guide-skill-grid .button { justify-self: start; text-decoration: none; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .main { order: 1; padding: 20px 18px 34px; }
  .sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); display: block; }
  .sidebar-list { max-height: 260px; }
  .result-grid, .control-grid, .report-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .route-flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-flow span:nth-of-type(3)::after { display: none; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  .top-meta, .env-pill { display: none; }
  .page-head { display: grid; }
  .panel-head { align-items: flex-start; flex-wrap: wrap; }
  .panel-head > .toolbar { min-width: 0; max-width: 100%; }
  .composer-meta, .composer-foot { align-items: stretch; flex-direction: column; }
  .composer-meta select { width: 100%; }
  .suggestions { display: none; }
  .result-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-steps { grid-template-columns: 1fr; }
  .doc-steps > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .service-origin { align-items: flex-start; flex-direction: column; }
  .route-flow { grid-template-columns: 1fr; gap: 8px; }
  .route-flow span:not(:last-child)::after { display: none; }
  .guide-skill-grid > div + div { padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}
