:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #6ea8fe;
  --accent-dim: #2a3654;
  --danger: #ff6b6b;
  --border: #262b35;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; }
.fineprint { color: var(--muted); font-size: 12.5px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
header h1 { font-size: 18px; margin: 0; letter-spacing: 0.2px; }
.tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  background: var(--accent-dim); color: var(--accent);
  padding: 2px 6px; border-radius: 6px; vertical-align: middle;
}

main { max-width: 760px; margin: 0 auto; padding: 24px 20px 48px; }
section { margin-bottom: 28px; }

.targets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.target {
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 13px;
}
.target.active { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

.record {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; font-size: 15px;
}
.record.recording { border-color: var(--danger); }
.record .dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--muted);
}
.record.recording .dot { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.result { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chip { font-size: 12px; color: var(--accent); background: var(--accent-dim); padding: 3px 9px; border-radius: 6px; }
#formatted {
  width: 100%; min-height: 160px; resize: vertical;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font: 14px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
}
#raw-wrap { margin-top: 10px; }
#raw-wrap summary { cursor: pointer; color: var(--muted); font-size: 13px; }
#raw { white-space: pre-wrap; color: var(--muted); font-size: 13px; background: var(--panel-2); padding: 10px; border-radius: 8px; }

.history h3 { font-size: 14px; font-weight: 600; }
#history-list { list-style: none; padding: 0; margin: 0; }
#history-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
#history-list .h-meta { font-size: 12px; color: var(--muted); }
#history-list .h-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#history-list .h-del { color: var(--muted); background: none; border: none; cursor: pointer; font-size: 16px; }
#history-list .h-del:hover { color: var(--danger); }

.ghost { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.ghost:hover { color: var(--text); border-color: var(--accent); }

.overlay {
  position: fixed; inset: 0; background: rgba(6, 8, 12, 0.85);
  display: flex; align-items: center; justify-content: center; z-index: 10; padding: 20px;
}
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px;
}
.card h2 { margin: 0; font-size: 18px; }
.card input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 12px; font-size: 15px;
}
.linkbtn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12.5px; text-decoration: underline; padding: 2px; align-self: center;
}
.linkbtn:hover { color: var(--danger); }
.card button[type="submit"] {
  background: var(--accent); color: #0b1220; border: none; border-radius: 8px;
  padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
}

footer { max-width: 760px; margin: 0 auto; padding: 0 20px 40px; }
