:root {
  --bg: #f6efe4;
  --card: #ffffff;
  --ink: #121a2b;
  --muted: #5d6675;
  --line: #e3d9c9;
  --accent: #c87a3e;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #9a6b11;
  --err: #b3261e;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1420;
    --card: #182236;
    --ink: #f1ebe0;
    --muted: #9aa5b8;
    --line: #27334b;
    --accent: #d98b4c;
    --accent-ink: #121a2b;
    --ok: #6fcf97;
    --warn: #e2b659;
    --err: #ff7b72;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1420; --card: #182236; --ink: #f1ebe0; --muted: #9aa5b8; --line: #27334b;
  --accent: #d98b4c; --accent-ink: #121a2b; --ok: #6fcf97; --warn: #e2b659; --err: #ff7b72;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.top img { border-radius: 9px; }
.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: .2px; }
h2 { font-size: 15px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 0 0 12px;
}
.row { display: flex; gap: 8px; }
.rowbetween { display: flex; justify-content: space-between; align-items: baseline; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%; min-width: 0; flex: 1;
  font: inherit; color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px;
}
select, textarea { margin-top: 6px; }
textarea { resize: vertical; }
.label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }

button {
  font: inherit; font-weight: 600;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  padding: 10px 14px; cursor: pointer; white-space: nowrap;
}
button:disabled { opacity: .55; cursor: progress; }
button.primary, #goBtn { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; }
button.small, .small { font-size: 13px; }
.muted { color: var(--muted); }
p.small { margin: 10px 0 0; }

.status { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.error { color: var(--err); }

.meta { display: flex; gap: 12px; align-items: flex-start; }
.meta img { width: 64px; height: 86px; object-fit: cover; border-radius: 8px; flex: none; background: var(--line); }
.who a { color: var(--ink); font-weight: 700; text-decoration: none; }
.desc { margin: 4px 0 6px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.badge.muted { background: var(--line); color: var(--muted); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
@media (min-width: 520px) { .actions { grid-template-columns: repeat(4, 1fr); } }

details summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.transcript {
  white-space: pre-wrap; overflow-wrap: anywhere;
  font: 15px/1.55 inherit; margin: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  max-height: 50vh; overflow: auto;
}

.history { list-style: none; margin: 0; padding: 0; }
.history li + li { border-top: 1px solid var(--line); }
.hist {
  width: 100%; text-align: left; background: none; border: none; padding: 10px 2px;
  display: flex; flex-direction: column; gap: 2px; font-weight: 500; white-space: normal;
}
.hist-author { font-size: 12px; color: var(--accent); font-weight: 700; }
.hist-title { font-size: 14px; color: var(--ink); }

footer { margin-top: 18px; text-align: center; }
