:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #121820;
  --line: #1f2a37;
  --text: #e8eef6;
  --muted: #8fa0b5;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px
    max(24px, env(safe-area-inset-bottom));
}

main {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header {
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3rem);
  letter-spacing: -0.03em;
}

.status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

.status[data-tone="listening"] {
  color: var(--green);
}

.status[data-tone="working"] {
  color: var(--amber);
}

.status[data-tone="speaking"] {
  color: var(--blue);
}

.status[data-tone="error"] {
  color: var(--red);
}

.toggle {
  width: 100%;
  min-height: 120px;
  border: 0;
  border-radius: 28px;
  background: var(--green);
  color: #04130a;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.25);
  touch-action: manipulation;
}

.toggle.stop {
  background: var(--red);
  color: #1a0505;
  box-shadow: 0 12px 30px rgba(239, 68, 68, 0.25);
}

.toggle:active {
  transform: translateY(1px) scale(0.995);
}

.play {
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
}

.log {
  display: grid;
  gap: 12px;
}

.log > div {
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.log h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.log p {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.task-link {
  display: block;
  text-align: center;
  color: var(--blue);
  font-weight: 600;
}

footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.8rem;
}

footer button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
}

dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid #263241;
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

dialog h2 {
  margin-top: 0;
}

dialog p {
  color: var(--muted);
}

dialog input {
  width: 100%;
  padding: 14px;
  border: 1px solid #2b3a4d;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

dialog button {
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
}

#token-save {
  background: var(--green);
  color: #04130a;
}

#token-cancel {
  background: #243040;
  color: var(--text);
}
