:root {
  --bg: #10100f;
  --sidebar: #171715;
  --panel: #191917;
  --panel-2: #20201e;
  --input: #11110f;
  --line: #34312d;
  --line-soft: #2a2824;
  --text: #eee8de;
  --muted: #8b857d;
  --faint: #66615b;
  --accent: #dd7d59;
  --accent-soft: #2b201c;
  --green: #79ba82;
  --green-soft: #18291b;
  --red: #df765f;
  --red-soft: #301c18;
  --yellow: #d9a45e;
  --yellow-soft: #2f2819;
  --blue: #7d9fc9;
  --radius: 12px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 27px 18px 22px; background: var(--sidebar); border-right: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark { color: var(--accent); font: 28px/1 Georgia, serif; }
.brand-copy strong { display: block; font: 500 21px/1 Georgia, "Noto Serif SC", serif; }
.brand-copy small { display: block; margin-top: 5px; color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .14em; }
.nav { margin-top: 42px; display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-size: 12px; }
.nav-item span { width: 18px; color: var(--faint); font-size: 17px; text-align: center; }
.nav-item b { font-weight: 600; }
.nav-item:hover { color: var(--text); background: #1f1e1b; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }
.nav-item.active span { color: var(--accent); }
.sidebar-note { display: flex; gap: 10px; margin-top: auto; padding: 15px 10px; border-top: 1px solid var(--line-soft); color: var(--muted); }
.privacy-dot { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(121,186,130,.08); }
.sidebar-note strong { display: block; color: #aaa39a; font-size: 10px; }
.sidebar-note p { margin: 6px 0 0; font-size: 10px; line-height: 1.6; }
.domain { padding: 4px 10px 0; color: #4e4a45; font-size: 8px; font-weight: 800; letter-spacing: .16em; }

.main { min-width: 0; padding: 0 28px 26px; }
.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line-soft); }
.eyebrow, .kicker { margin: 0 0 5px; color: var(--faint); font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.topbar h1 { margin: 0; font: 500 21px/1.1 Georgia, "Noto Serif SC", serif; }
.health { display: inline-flex; align-items: center; gap: 8px; min-height: 31px; padding: 0 11px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 10px; background: var(--panel); }
.health-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px rgba(217,164,94,.1); }
.health[data-state="online"] { border-color: #28412d; color: var(--green); background: #142017; }
.health[data-state="online"] .health-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(121,186,130,.1); }
.health[data-state="offline"] { border-color: #4a2922; color: var(--red); background: #231614; }
.health[data-state="offline"] .health-dot { background: var(--red); }

.workspace { display: grid; grid-template-columns: minmax(320px, 390px) minmax(0, 1fr); gap: 17px; padding-top: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-heading { min-height: 67px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 700; }
.panel-index { color: #4f4b46; font: 20px Georgia, serif; }
.panel-content { padding: 17px; }
.config-panel { position: sticky; top: 18px; }
.config-content { display: grid; gap: 14px; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.field, .protocol-field { display: grid; gap: 7px; }
.field > span, .field-label, .field legend { width: 100%; display: flex; align-items: center; justify-content: space-between; color: #aaa39a; font-size: 10px; }
.field b, .field legend { font-weight: 650; }
.field small { color: var(--faint); font-size: 8px; font-weight: 700; letter-spacing: .06em; }
input, select, textarea { width: 100%; min-width: 0; color: #d9d2c8; background: var(--input); border: 1px solid #403c37; border-radius: 7px; outline: none; }
input, select { height: 38px; padding: 0 11px; font-size: 11px; }
textarea { padding: 10px 11px; resize: vertical; font-size: 11px; line-height: 1.65; }
input:hover, select:hover, textarea:hover { border-color: #514c45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(221,125,89,.09); }
input::placeholder, textarea::placeholder { color: #504c46; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #77716a 50%), linear-gradient(135deg, #77716a 50%, transparent 50%); background-position: calc(100% - 14px) 16px, calc(100% - 10px) 16px; background-size: 4px 4px; background-repeat: no-repeat; padding-right: 28px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid #383530; border-radius: 8px; background: var(--input); }
.segment { min-height: 31px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; font-size: 10px; font-weight: 700; }
.segment.active { color: #f0a083; background: #30221d; box-shadow: inset 0 0 0 1px #553328; }
.model-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px; }
.proxy-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.icon-button { height: 38px; padding: 0 11px; color: #aaa39a; background: #262421; border: 1px solid #403c37; border-radius: 7px; font-size: 9px; font-weight: 700; }
.icon-button:hover { color: var(--text); border-color: #5b554e; }
.key-field textarea { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre; }
.actions { display: grid; grid-template-columns: auto auto minmax(140px, 1fr); gap: 7px; }
.button { min-height: 39px; padding: 0 13px; border-radius: 7px; font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.button.secondary { color: var(--muted); background: #24221f; border: 1px solid #403c37; }
.button.secondary:hover { color: var(--text); border-color: #5a544d; }
.button.primary { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #1b1512; background: var(--accent); border: 1px solid var(--accent); }
.button.primary:hover { background: #ea8b67; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.advanced { border-top: 1px solid var(--line-soft); margin-top: 2px; }
.advanced summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 2px 1px; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary b { display: block; font-size: 10px; }
.advanced summary small { display: block; margin-top: 4px; color: var(--faint); font-size: 9px; }
.chevron { color: var(--muted); transition: transform .2s; }
.advanced[open] .chevron { transform: rotate(180deg); }
.advanced-body { display: grid; gap: 13px; padding: 15px 0 2px; }
.field-grid { display: grid; gap: 8px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prompt { min-height: 70px; }
.toggle-line { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 9px; cursor: pointer; }
.toggle-line input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { grid-row: span 2; position: relative; width: 31px; height: 17px; margin-top: 1px; border-radius: 99px; background: #34312d; border: 1px solid #49443e; transition: .2s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #8d877f; transition: .2s; }
.toggle-line input:checked + .toggle { background: #563226; border-color: #8e4d37; }
.toggle-line input:checked + .toggle::after { left: 16px; background: var(--accent); }
.toggle-line b { display: block; color: #a9a198; font-size: 10px; }
.toggle-line small { display: block; margin-top: 4px; color: var(--faint); font-size: 9px; line-height: 1.45; }

.dashboard { min-width: 0; display: grid; gap: 13px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.metric { min-width: 0; min-height: 92px; padding: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.metric > span { display: block; overflow: hidden; color: var(--faint); font-size: 7px; font-weight: 800; letter-spacing: .11em; text-overflow: ellipsis; white-space: nowrap; }
.metric strong { display: block; margin: 8px 0 2px; font: 500 25px/1 Georgia, serif; }
.metric small { color: var(--faint); font-size: 9px; }
.metric.success strong { color: var(--green); }.metric.danger strong { color: var(--red); }.metric.warning strong { color: var(--yellow); }.metric.testing strong { color: var(--blue); }

.insight-panel { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(210px, .65fr); min-height: 148px; }
.response-chart, .tier-summary { min-width: 0; padding: 16px; }
.response-chart { border-right: 1px solid var(--line-soft); }
.mini-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.mini-heading h3 { margin: 0; font-size: 11px; }.mini-heading > span { color: var(--accent); font: 17px Georgia, serif; }
.bars { height: 80px; display: flex; align-items: end; gap: 7px; padding-top: 12px; border-bottom: 1px solid #393631; }
.bar { position: relative; flex: 1; min-width: 4px; max-width: 34px; height: 25%; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #e88966, #a75136); opacity: .88; transition: height .3s; }
.bar:hover { opacity: 1; }.bar::after { content: attr(data-label); position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); color: #8c857c; font-size: 7px; white-space: nowrap; opacity: 0; }.bar:hover::after { opacity: 1; }
.chart-empty { width: 100%; align-self: center; color: #504c46; font-size: 9px; text-align: center; }
.tier-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.tier-grid div { padding: 8px 9px; background: #151513; border: 1px solid var(--line-soft); border-radius: 7px; }
.tier-grid .wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.tier-grid span { color: var(--faint); font-size: 7px; font-weight: 800; }.tier-grid b { display: block; margin-top: 4px; font: 16px Georgia, serif; }.tier-grid .wide b { margin: 0; }

.results-panel { min-height: 372px; }
.results-heading { min-height: 67px; }
.copy-button { min-height: 31px; padding: 0 10px; color: #c5bdb3; background: #24221f; border: 1px solid #403c37; border-radius: 7px; font-size: 9px; }
.copy-button span { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 5px; color: var(--accent); background: var(--accent-soft); border-radius: 99px; }
.copy-button:hover { color: var(--text); border-color: #5a554e; }
.filter-scroll { overflow-x: auto; border-bottom: 1px solid var(--line-soft); scrollbar-width: thin; }
.filters { display: flex; width: max-content; min-width: 100%; padding: 0 13px; }
.filter { min-height: 42px; padding: 0 9px; color: var(--faint); background: none; border: 0; border-bottom: 2px solid transparent; font-size: 9px; white-space: nowrap; }
.filter span { margin-left: 3px; color: #554f49; }.filter:hover { color: #b1aaa0; }.filter.active { color: var(--accent); border-color: var(--accent); }.filter.active span { color: var(--accent); }
.result-container { min-height: 258px; }
.empty-state { min-height: 258px; display: grid; place-items: center; align-content: center; padding: 28px; color: var(--faint); text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 9px; color: var(--accent); background: var(--accent-soft); border: 1px solid #4c3026; border-radius: 50%; font: 21px Georgia, serif; }
.empty-state h3 { margin: 0; color: #9c958c; font: 500 14px Georgia, serif; }.empty-state p { max-width: 320px; margin: 7px 0 0; font-size: 9px; line-height: 1.55; }
.result-table { overflow-x: auto; }
.result-row { min-width: 760px; display: grid; grid-template-columns: minmax(130px,1.1fr) 78px 58px 68px 72px minmax(170px,1.4fr) 52px; align-items: center; min-height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line-soft); color: #a8a198; font-size: 9px; }
.result-row.head { min-height: 34px; color: #5d5852; font-size: 7px; font-weight: 800; letter-spacing: .07em; }
.result-key { overflow: hidden; color: #d7cfc4; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.badge { width: max-content; padding: 4px 7px; border-radius: 99px; color: var(--muted); background: #282622; }
.badge.valid, .badge.auth { color: var(--green); background: var(--green-soft); }.badge.invalid { color: var(--red); background: var(--red-soft); }.badge.rate { color: var(--yellow); background: var(--yellow-soft); }.badge.billing { color: #d49179; background: #30201b; }.badge.testing { color: var(--blue); background: #182331; }
.tier-value { color: var(--accent); }.detail-button { padding: 5px; color: var(--accent); background: none; border: 0; font-size: 9px; }.detail-button:hover { color: #f2a487; }
.result-details { grid-column: 1 / -1; display: none; padding: 4px 0 14px; }.result-row.open { background: #1c1c1a; }.result-row.open .result-details { display: block; }
.detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; padding: 12px; background: #141412; border: 1px solid var(--line-soft); border-radius: 8px; }
.detail-item { min-width: 0; padding: 7px; color: #aaa39a; background: #191917; border-radius: 5px; line-height: 1.5; overflow-wrap: anywhere; }.detail-item span { display: block; margin-bottom: 4px; color: #625d57; font-size: 7px; font-weight: 800; letter-spacing: .06em; }.detail-item.output { grid-column: 1 / -1; }

footer { display: flex; justify-content: space-between; gap: 16px; padding: 20px 2px 0; color: #4f4b46; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100vw - 44px)); padding: 11px 14px; color: #d9d2c8; background: #26231f; border: 1px solid #4d473f; border-radius: 8px; box-shadow: 0 12px 34px rgba(0,0,0,.35); font-size: 10px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #ef9a85; border-color: #713d31; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding-inline: 11px; align-items: center; }
  .brand-copy, .nav-item b, .sidebar-note, .domain { display: none; }
  .brand { padding: 0; }.brand-mark { font-size: 30px; }
  .nav { width: 100%; }.nav-item { justify-content: center; padding: 0; }.nav-item span { width: auto; }
  .workspace { grid-template-columns: minmax(300px, 360px) minmax(0,1fr); }
  .metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .main { padding-inline: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .config-panel { position: static; }
  .insight-panel { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }.sidebar { position: static; width: 100%; height: 58px; padding: 0 15px; flex-direction: row; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line-soft); }.brand { display: flex; }.brand-copy { display: block; }.brand-copy small { display: none; }.nav { width: auto; margin: 0; display: flex; }.nav-item { min-width: 40px; }.nav-item:not(.active) { display: none; }
  .main { padding: 0 12px 22px; }.topbar { min-height: 68px; }.topbar .eyebrow { display: none; }.topbar h1 { font-size: 18px; }.health { padding-inline: 9px; }
  .workspace { padding-top: 12px; gap: 11px; }.panel-heading { min-height: 61px; }.panel-content { padding: 14px; }.config-content { gap: 13px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }.metric { min-height: 82px; }.metric:last-child { grid-column: 1 / -1; min-height: 68px; }.metric strong { font-size: 22px; }
  .insight-panel { grid-template-columns: 1fr; }.response-chart { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .field-grid.three { grid-template-columns: 1fr; }.actions { grid-template-columns: 1fr 1fr; }.button.primary { grid-column: 1 / -1; }
  .result-row { min-width: 700px; }.detail-grid { grid-template-columns: 1fr 1fr; }.detail-item.output { grid-column: 1 / -1; }
  footer { flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
