*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f0f0f;
  color: #e8e8e8;
  min-height: 100vh;
  padding: 2rem 1rem;
  font-size: 15px;
  line-height: 1.6;
}

.container { max-width: 660px; margin: 0 auto; }

header { margin-bottom: 1.5rem; }
h1 { font-size: 1.6rem; font-weight: 600; color: #fff; margin-bottom: 0.25rem; }
.subtitle { color: #666; font-size: 0.85rem; }

h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #555;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 20px;
  background: #1e3a5f;
  color: #60a5fa;
  text-transform: none;
  letter-spacing: 0;
  animation: blink 2s ease-in-out infinite;
}

.card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.result-card { border-color: #1e3a5f; }

/* Fields */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; color: #ccc; margin-bottom: 0.4rem; }
.optional { color: #555; font-weight: 400; }

.field input[type=text],
.field select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e8e8e8;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input[type=text]:focus,
.field select:focus { border-color: #555; }
.field select option { background: #1a1a1a; }
.field input[type=range] { width: 100%; accent-color: #3b82f6; margin: 0.3rem 0 0.2rem; cursor: pointer; }
.range-hints { display: flex; justify-content: space-between; font-size: 0.72rem; color: #555; }

/* Session box */
.session-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0d1f35;
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}
.session-box__label { color: #60a5fa; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; white-space: nowrap; }
.session-box code { color: #93c5fd; font-family: "SF Mono", "Fira Code", monospace; font-size: 0.78rem; word-break: break-all; flex: 1; }
.copy-btn { background: none; border: 1px solid #1e3a5f; color: #60a5fa; border-radius: 5px; padding: 3px 8px; cursor: pointer; font-size: 0.85rem; flex-shrink: 0; }
.copy-btn:hover { background: #1e3a5f; }

/* Controls */
.controls { display: flex; gap: 8px; margin-bottom: 0.75rem; }
.btn {
  flex: 1;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.1s;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.btn-primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.btn-primary:hover:not(:disabled) { background: #2563eb; }
.btn-danger { background: transparent; color: #ef4444; border-color: #ef4444; }
.btn-danger:hover:not(:disabled) { background: #1a0a0a; }
.btn-secondary { background: transparent; color: #888; border-color: #333; }
.btn-secondary:hover:not(:disabled) { background: #1e1e1e; color: #aaa; }

/* Status */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 7px;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #444; flex-shrink: 0; }
.status-dot.recording { background: #ef4444; animation: blink 1s ease-in-out infinite; }
.status-dot.idle { background: #22c55e; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.timer { margin-left: auto; font-family: "SF Mono", "Fira Code", monospace; font-size: 0.85rem; color: #aaa; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 1rem; }
.stat { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 7px; padding: 0.6rem; text-align: center; }
.stat-value { display: block; font-size: 1.1rem; font-weight: 600; color: #fff; }
.stat-label { display: block; font-size: 0.7rem; color: #555; margin-top: 2px; }

/* Transcript */
.transcript-box {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #ccc;
  min-height: 60px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Result */
.result-block { margin-bottom: 1.2rem; }
.result-block:last-child { margin-bottom: 0; }
.result-block__label { font-size: 0.78rem; font-weight: 600; color: #60a5fa; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.5rem; }

audio { border-radius: 6px; }

/* Chunk breakdown */
.chunk-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #222;
  font-size: 0.82rem;
}
.chunk-item:last-child { border-bottom: none; }
.chunk-num { color: #555; font-family: monospace; padding-top: 2px; }
.chunk-text { color: #bbb; }

/* Log */
#log { display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.log-empty { color: #555; font-size: 0.85rem; padding: 0.25rem 0; }
.log-entry {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  border: 1px solid #2a2a2a;
  background: #111;
}
.log-entry.sending { border-color: #1e3a5f; background: #0d1f35; }
.log-entry.ok      { border-color: #1a3d2b; background: #0b2018; }
.log-entry.err     { border-color: #3d1a1a; background: #200b0b; }
.log-time { color: #555; font-family: monospace; }
.log-msg  { color: #aaa; }
.log-entry.sending .log-msg { color: #60a5fa; }
.log-entry.ok .log-msg      { color: #4ade80; }
.log-entry.err .log-msg     { color: #f87171; }
.log-badge { font-size: 0.68rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.log-entry.sending .log-badge { background: #1e3a5f; color: #60a5fa; }
.log-entry.ok .log-badge      { background: #1a3d2b; color: #4ade80; }
.log-entry.err .log-badge     { background: #3d1a1a; color: #f87171; }

@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .controls { flex-wrap: wrap; }
}
