:root {
  --bg: #0e0e10;
  --card: #18181c;
  --line: #2a2a31;
  --text: #f2f2f4;
  --muted: #9a9aa6;
  --accent: #ffd60a;
  --rec: #ff453a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  max-width: 720px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
h1::after { content: "."; color: var(--accent); }
h2 { margin: 0 0 12px; font-size: 20px; }
.head-btns { display: flex; gap: 6px; }
button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 20px; border-radius: 50%; }

.modes { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.modes::-webkit-scrollbar { display: none; }
.modes button { flex: none; border-radius: 999px; padding: 8px 14px; font-size: 15px; }
.modes button[aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }

main { flex: 1; display: flex; flex-direction: column; padding: 4px 16px; min-height: 0; }
.card { flex: 1; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-height: 160px; }
#output {
  flex: 1; width: 100%; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 17px; padding: 14px;
}
#output::placeholder { color: var(--muted); }
#rawBox { border-top: 1px solid var(--line); padding: 8px 14px; color: var(--muted); font-size: 14px; }
#rawBox summary { cursor: pointer; }
#rawBox p { margin: 6px 0 2px; white-space: pre-wrap; }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 10px 0; }
.actions button { padding: 10px 4px; font-size: 15px; white-space: nowrap; }
h3 { font-size: 16px; margin: 14px 0 4px; }
.steps { padding-left: 20px; margin: 6px 0; font-size: 14px; line-height: 1.5; }
.steps li { margin-bottom: 6px; }
code { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; font-size: 13px; overflow-wrap: anywhere; }
#help a { color: var(--accent); }

footer { display: flex; flex-direction: column; align-items: center; padding: 4px 16px 18px; }
#status { margin: 0 0 10px; color: var(--muted); font-size: 14px; min-height: 20px; text-align: center; }
#status.error { color: var(--rec); }
.mic {
  width: 84px; height: 84px; border-radius: 50%; padding: 0;
  background: var(--accent); border: 0; display: grid; place-items: center;
  box-shadow: 0 6px 24px rgba(255, 214, 10, 0.25);
  touch-action: manipulation;
}
.mic svg { width: 38px; height: 38px; fill: #111; }
.mic.recording { background: var(--rec); box-shadow: 0 0 0 0 rgba(255, 69, 58, 0.6); animation: pulse 1.4s infinite; }
.mic.recording svg { fill: #fff; }
.mic.busy { background: var(--card); border: 1px solid var(--line); animation: none; }
.mic.busy svg { fill: var(--muted); animation: spin 1s linear infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 22px rgba(255, 69, 58, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 69, 58, 0); } }
@keyframes spin { 50% { opacity: 0.3; } }

dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 40px);
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
input:not([type=checkbox]), select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.hint a { color: var(--accent); }
.note { background: #2b2610; color: var(--accent); padding: 10px; border-radius: 10px; }
details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; }
.mode-row { border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin: 8px 0; }
.mode-row .top { display: flex; gap: 8px; }
.mode-row .top input { margin: 0; }
.mode-row .top button { flex: none; padding: 6px 10px; }
.mode-row textarea { font-size: 14px; }
.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
#historyList { list-style: none; padding: 0; margin: 0; }
#historyList li { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
#historyList li small { color: var(--muted); display: block; margin-bottom: 4px; }
#historyList li p { margin: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
