/* Feature Generator – site and server console */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #1b2230;
  --muted: #5c6878;
  --line: #dde2ea;
  --accent: #2457d6;
  --accent-2: #1c47b3;
  --accent-text: #ffffff;
  --accent-soft: #e8eefc;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --ok: #1d7f47;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --rec: #d93025;
  --code: #f1f3f7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .06);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #12151a; --panel: #1b1f26; --panel-2: #20252d; --text: #e5e9ef; --muted: #98a2b1;
    --line: #2d333d; --accent: #7aa2ff; --accent-2: #9ab8ff; --accent-text: #0b1226; --accent-soft: #1f2a44;
    --danger: #ff7a72; --danger-soft: #3a1f1f; --ok: #5cd394; --ok-soft: #173126; --warn: #f2bc5b;
    --warn-soft: #33290f; --rec: #ff5a4f; --code: #161a20; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #12151a; --panel: #1b1f26; --panel-2: #20252d; --text: #e5e9ef; --muted: #98a2b1;
  --line: #2d333d; --accent: #7aa2ff; --accent-2: #9ab8ff; --accent-text: #0b1226; --accent-soft: #1f2a44;
  --danger: #ff7a72; --danger-soft: #3a1f1f; --ok: #5cd394; --ok-soft: #173126; --warn: #f2bc5b;
  --warn-soft: #33290f; --rec: #ff5a4f; --code: #161a20; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1 { font-size: 1.45rem; margin: 0 0 .35rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
p { margin: .4rem 0 .8rem; }
a { color: var(--accent); }
code { background: var(--code); padding: .05rem .35rem; border-radius: 5px; font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.error { color: var(--danger); }

/* ---------- layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.02rem; }
.brand img { display: block; }
.top-actions { display: flex; align-items: center; gap: .6rem; }
main { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
main.wide { max-width: 1240px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1rem;
}
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; margin-top: 2rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols > .card { margin-bottom: 1rem; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

.banner {
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line);
  padding: .5rem 1.25rem; text-align: center; font-size: .9rem;
}

/* ---------- controls */
button, .button, select, input, textarea { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 36px; padding: .35rem .95rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  text-decoration: none; white-space: nowrap; user-select: none;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); }
button:focus-visible, .button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .w:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .5; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
button.ghost { background: transparent; border-color: transparent; min-height: 30px; padding: .2rem .5rem; }
button.ghost:hover:not(:disabled) { border-color: var(--line); }
button.danger, .danger { color: var(--danger); }
button.danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
button.danger-ghost:hover:not(:disabled) { border-color: var(--danger); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ok.solid { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
button.small, .button.small { min-height: 28px; padding: .15rem .6rem; font-size: .86rem; }
button.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; width: 100%;
}
textarea { resize: vertical; }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
.form label { display: block; font-weight: 600; margin: .85rem 0 .3rem; font-size: .93rem; }
.form label:first-of-type { margin-top: .3rem; }
.form .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.25rem; }
.form.grid2 .span2 { grid-column: 1 / -1; }
.form.grid2 label { margin-top: .7rem; }
@media (max-width: 760px) { .form.grid2 { grid-template-columns: 1fr; } }

.pill {
  display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); vertical-align: middle;
}
.pill:empty { display: none; }
.pill.pending, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.approved, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.denied, .pill.revoked, .pill.bad { background: var(--danger-soft); color: var(--danger); }

.note { border-radius: 8px; padding: .65rem .85rem; margin: .6rem 0; font-size: .92rem; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.error { background: var(--danger-soft); color: var(--danger); white-space: pre-wrap; }
.note p { margin: .2rem 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: .5rem 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite;
  vertical-align: -3px;
}
.spinner-row { display: flex; align-items: center; gap: .6rem; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- record view */
.rec-head, .result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.recorder { display: flex; align-items: center; gap: 1.4rem; margin: 1rem 0 1.1rem; }
.rec-btn {
  width: 116px; height: 116px; border-radius: 50%; flex: none; flex-direction: column; gap: .35rem;
  background: var(--panel-2); border: 2px solid var(--line); font-weight: 600;
}
.rec-btn .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--rec); transition: border-radius .15s; }
.rec-btn.on { border-color: var(--rec); background: var(--danger-soft); }
.rec-btn.on .dot { border-radius: 5px; width: 26px; height: 26px; }
.rec-btn.on { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--rec) 18%, transparent); } }
.rec-side { flex: 1; min-width: 0; }
.rec-time { font-size: 1.6rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.wave { width: 100%; height: 64px; display: block; background: var(--panel-2); border-radius: 8px; margin: .3rem 0; }
@media (max-width: 560px) { .recorder { flex-direction: column; align-items: stretch; } .rec-btn { align-self: center; } }

.takes { list-style: none; padding: 0; margin: 0; }
.take { border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; margin-bottom: .5rem; background: var(--panel-2); }
.take-head { display: flex; align-items: center; gap: .4rem; }
.take-head .grow { flex: 1; min-width: 0; }
.take-text { margin: .35rem 0 0; font-size: .92rem; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.take.failed .take-status, .take.error .take-status { color: var(--danger); }
.take.nospeech .take-status { color: var(--warn); }
.take progress { width: 100%; height: 6px; margin-top: .4rem; accent-color: var(--accent); }

/* ---------- work view */
.steps { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.step { display: flex; gap: .75rem; padding: .5rem 0; }
.step-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); margin-top: 1px; position: relative; }
.step.done .step-icon { background: var(--ok); border-color: var(--ok); }
.step.done .step-icon::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.step.active .step-icon { border-color: var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.step.failed .step-icon { background: var(--danger); border-color: var(--danger); }
.step.failed .step-icon::after { content: "!"; position: absolute; inset: 0; color: #fff; font-weight: 700; font-size: 13px; line-height: 18px; text-align: center; }
.step.waiting { color: var(--muted); }
.step-title { font-weight: 600; }
.stream-head { display: flex; justify-content: space-between; margin-top: .5rem; }
.stream, .log {
  background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem;
  max-height: 46vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 13px/1.5 Consolas, "Cascadia Mono", ui-monospace, monospace; margin: .3rem 0 0;
}
.log { max-height: 340px; white-space: pre; }
.warnings { margin: .4rem 0; padding-left: 1.2rem; color: var(--warn); font-size: .9rem; }
.warnings:empty { display: none; }

/* ---------- result view */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .9rem; }
.toolbar .row { flex-wrap: wrap; }
.develop { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.develop input[type=range] { width: 150px; }
.level-name { font-weight: 600; min-width: 6.5rem; }
.editor {
  width: 100%; min-height: 52vh; margin-top: .4rem; padding: .9rem 1rem;
  font: 13.5px/1.55 Consolas, "Cascadia Mono", ui-monospace, monospace; background: var(--panel-2);
}
details.card > summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; list-style-position: inside; }
details.card[open] > summary { margin-bottom: .4rem; }
.transcript { line-height: 1.9; }
.tr-take { margin: .2rem 0 1rem; }
.tr-head { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
.w { cursor: pointer; border-radius: 4px; padding: 1px 1px; }
.w:hover { background: var(--accent-soft); }
.w.fixed { background: var(--ok-soft); color: var(--ok); font-weight: 600; }

/* ---------- dialogs */
dialog.dlg {
  border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.4rem; background: var(--panel); color: var(--text);
  width: min(460px, calc(100vw - 2rem)); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog.dlg.wide { width: min(760px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.dlg-head h2 { margin: 0; }
.prompt-list { list-style: none; padding: 0; margin: .8rem 0 0; max-height: 60vh; overflow: auto; }
.prompt-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); }
.prompt-row .row { flex-wrap: wrap; justify-content: flex-end; }

/* ---------- toasts */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 20; max-width: min(440px, calc(100vw - 2rem)); }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); padding: .65rem .8rem; display: flex; gap: .6rem; align-items: flex-start;
}
.toast.error { border-left-color: var(--danger); }
.toast .msg { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }

.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; }

/* ---------- server console */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: .4rem .5rem; white-space: nowrap; }
table.grid td { border-bottom: 1px solid var(--line); padding: .45rem .5rem; vertical-align: top; }
table.grid td.actions { white-space: nowrap; text-align: right; }
table.grid td.actions button { margin-left: .25rem; }
table.grid .sub { color: var(--muted); font-size: .82rem; }
.request {
  border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .6rem;
  display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; background: var(--panel-2);
}
.request .who { font-weight: 600; font-size: 1.05rem; }
.request .note-text { margin: .3rem 0 0; white-space: pre-wrap; }
.model-list { list-style: none; padding: 0; margin: 0; }
.model-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.model-list progress { width: 120px; accent-color: var(--accent); }
.inline-edit { display: flex; gap: .3rem; }
.inline-edit input { padding: .2rem .4rem; min-width: 10rem; }
