:root {
  --bg: #f5f4ef; --surface: #fff; --surface-2: #faf9f5; --line: #e4e2d9; --line-strong: #cfccbf;
  --ink: #152321; --soft: #55625f; --mute: #84908c;
  --brand: #0d6b63; --brand-strong: #0a524c; --brand-tint: #e0f0ed;
  --good: #1a7f4b; --good-tint: #e2f4e9; --warn: #a8660a; --warn-tint: #fbf0da;
  --bad: #b83227; --bad-tint: #fbe7e4; --info: #1f62a8; --info-tint: #e3eefa;
  --radius: 10px; --side: 224px;
  --font: "Figtree", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.015em; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 4px; font-weight: 650; }
h3 { font-size: 15px; margin: 0 0 4px; font-weight: 650; }
p { margin: 0 0 10px; }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); word-break: break-all; }

.layout { display: flex; min-height: 100vh; }
.side { width: var(--side); flex-shrink: 0; background: #12211f; color: #c5d1ce; padding: 20px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-size: 19px; font-weight: 750; letter-spacing: -.02em; padding: 2px 10px 18px; display: block; }
.brand:hover { text-decoration: none; }
.brand span { color: #6fd6c6; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: inherit; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.on { background: rgba(111,214,198,.16); color: #fff; }
.side-foot { margin-top: auto; font-size: 13px; padding: 0 10px; }
.side-foot strong { color: #fff; display: block; font-weight: 600; overflow-wrap: anywhere; }
.side-foot a { color: #9fb2ae; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1160px; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.sub { color: var(--soft); margin-top: 3px; }
.crumb { color: var(--mute); font-size: 13px; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card > .hint:first-of-type { margin-top: 0; }
.step { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.step-no { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.hint { color: var(--soft); font-size: 13.5px; }
.mute { color: var(--mute); }
.small { font-size: 13px; }
.mt { margin-top: 12px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }

.field { display: block; font-weight: 550; font-size: 13.5px; }
.field input, .field select, .field textarea, .input { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: 400 14.5px var(--font); color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.field .hint { font-weight: 400; display: block; margin-top: 3px; font-size: 12.5px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 4px; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font: 600 14px var(--font); cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--bad); border-color: #e4b6b1; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { display: block; width: 100%; text-align: center; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #ecebe4; color: var(--soft); white-space: nowrap; }
.badge.good { background: var(--good-tint); color: var(--good); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }
.badge.info { background: var(--info-tint); color: var(--info); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14.5px; }
.alert.info { background: var(--brand-tint); color: var(--brand-strong); }
.alert.error { background: var(--bad-tint); color: var(--bad); }
.alert.warn { background: var(--warn-tint); color: var(--warn); }

.stat b { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.stat span { color: var(--soft); font-size: 13px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--soft); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.empty { color: var(--mute); padding: 14px 0; text-align: center; }

.presets { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.preset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.preset p { color: var(--soft); font-size: 13.5px; flex: 1; }

.q-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.q-row .input { margin-top: 0; }
details.more { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 20px; margin-bottom: 16px; }
details.more summary { cursor: pointer; font-weight: 650; }
details.more[open] summary { margin-bottom: 12px; }
.sticky-bar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 5; }

.chat { display: flex; flex-direction: column; gap: 8px; min-height: 300px; max-height: 520px; overflow-y: auto; }
.bubble { padding: 7px 12px; border-radius: 12px; max-width: 86%; font-size: 14.5px; }
.bubble.user { align-self: flex-end; background: var(--brand-tint); }
.bubble.assistant { align-self: flex-start; background: #efeee7; }
.bubble small { display: block; font-size: 11.5px; color: var(--mute); font-weight: 600; }
.toolcall { align-self: center; font-size: 12.5px; color: var(--soft); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 3px 9px; overflow-wrap: anywhere; }
.mic { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font: 700 14px var(--font); cursor: pointer; }
.mic.on { background: var(--bad); }
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 12px; font-size: 14px; }
.dl dt { color: var(--soft); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; margin: 0; }
.auth .brand { color: var(--ink); padding: 0 0 10px; }
.auth .brand span { color: var(--brand); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; padding: 12px 16px; }
  .brand { padding: 0 0 8px; }
  .nav { display: flex; gap: 2px; flex-wrap: wrap; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 48px; }
  .g2, .g3, .presets { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .q-row { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dd { margin-bottom: 6px; }
}
