:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #5f6772;
  --line: #dde1e6;
  --accent: #21a038;          /* зелёный, как у GigaAM */
  --accent-text: #ffffff;
  --rec: #d93025;
  --warn: #9a6700;
  --error: #c5221f;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1e2125;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #34383d;
    --accent: #2fb54a;
    --rec: #f28b82;
    --warn: #e3b341;
    --error: #f28b82;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.lead { margin: 0 0 24px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card.drop { border-color: var(--accent); border-style: dashed; }
.card p { margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 14px; }
a { color: var(--accent); }

.field-label { display: block; font-weight: 600; margin-bottom: 8px; }

textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.controls p { margin: 0; flex: 1 1 240px; min-height: 1.5em; color: var(--muted); }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

button, .button {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
button:hover, .button:hover { border-color: var(--muted); }
button:disabled, .disabled { opacity: 0.5; cursor: default; pointer-events: none; }

button.primary {
  min-width: 140px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.primary[data-state="recording"] { background: var(--rec); border-color: var(--rec); }

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 14px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}
.chips button:not(.link) { padding: 6px 12px; font-size: 14px; }

.brain-models { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.brain-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.brain-row:has(input:checked) { border-color: var(--accent); }
.brain-row input { accent-color: var(--accent); margin: 0; }
.brain-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.brain-text .hint { font-size: 14px; }
.brain-actions { display: flex; gap: 8px; }
.local-form { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.local-form input, .local-form select {
  flex: 1 1 140px; padding: 6px 8px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text);
}
.local-form button { padding: 6px 12px; font-size: 14px; }
.brain-row { flex-wrap: wrap; }
.brain-actions button { padding: 6px 12px; font-size: 14px; }

#status[data-kind="recording"] { color: var(--rec); }
#status[data-kind="ok"] { color: var(--accent); }
#status[data-kind="warn"] { color: var(--warn); }
#status[data-kind="error"] { color: var(--error); }

.downloads { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.downloads li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.downloads a { font-weight: 600; min-width: 120px; }
.downloads .hint { flex: 1 1 240px; }

footer {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

/* поле с оформлением (rich-field, giga/rich.js) */
rich-field {
  display: block;
  min-height: 180px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
}
rich-field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
rich-field.is-empty::before { content: attr(data-placeholder); position: absolute; left: 12px; top: 12px; right: 12px; color: var(--muted); font-style: italic; pointer-events: none; }
.rich p, .rich > div, .rich blockquote > div { margin: 0; min-height: 1.5em; }
.rich h1, .rich h2, .rich h3, .rich h4 { font-family: inherit; margin: .45em 0 .2em; line-height: 1.3; }
.rich h1 { font-size: 1.6em; } .rich h2 { font-size: 1.35em; } .rich h3 { font-size: 1.15em; } .rich h4 { font-size: 1em; }
.rich ul, .rich ol { margin: .1em 0; padding-left: 1.7em; }
.rich blockquote { margin: 0 0 0 2em; padding: 0; border: 0; }
.rich table { border-collapse: collapse; margin: .35em 0; }
.rich td, .rich th { border: 1px solid var(--line); padding: 3px 8px; vertical-align: top; min-width: 3em; }
.rich th { background: var(--card); font-weight: 600; text-align: left; }
.rich hr { border: 0; border-top: 1px solid var(--line); margin: .6em 0; }

.fmtbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0 0 6px; }
.fmtbar button { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.fmtbar button:hover { background: var(--bg); border-color: var(--line); }
.fmtbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.reasoning { margin: 12px 0 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 6px 6px 0; font-size: 14px; color: var(--muted); }
.reasoning summary { cursor: pointer; font-style: italic; }
.reasoning div { margin-top: 6px; white-space: pre-wrap; }

.toast { position: fixed; right: 16px; top: 16px; z-index: 20; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-text); box-shadow: 0 4px 14px rgba(0,0,0,.25); }

.check { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.debug-cols { display: flex; gap: 10px; margin-bottom: 10px; }
.debug-list { list-style: none; margin: 0; padding: 0; width: 240px; flex: none; max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.debug-list li { padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.debug-list li.sel { background: var(--bg); outline: 1px solid var(--accent); }
.debug-list li.bad .st { color: var(--error); }
.debug-list .u { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debug-list .m { color: var(--muted); }
.debug-detail { flex: 1; min-width: 0; max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.debug-detail h3 { font-size: 12px; margin: 10px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.debug-detail h3:first-child { margin-top: 0; }
.debug-detail pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.45 ui-monospace, Consolas, monospace; }
.debug-detail .think { border-left: 3px solid var(--accent); padding: 2px 8px; white-space: pre-wrap; }
@media (max-width: 640px) { .debug-cols { flex-direction: column; } .debug-list { width: auto; max-height: 160px; } }
