:root {
  --bg: #0f1117;
  --card: #181b24;
  --card-edge: #262b38;
  --text: #e8eaf0;
  --muted: #9aa3b5;
  --accent: #f59e0b;
  --rec: #ef4444;
  --good: #34d399;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1c2030 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  align-self: flex-start;
}

header { text-align: center; margin-bottom: 20px; }
h1 { font-size: 1.5rem; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { margin: 0; }
.tagline { color: var(--muted); margin: 0; font-size: 0.95rem; }

section { display: grid; gap: 14px; }
.center { text-align: center; justify-items: center; }
.stats { margin: 0; font-size: 1.1rem; }

button {
  font: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--text);
  background: #232836;
  transition: filter 0.15s, transform 0.05s;
}
button:hover:not(:disabled) { filter: brightness(1.15); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.big { padding: 16px 20px; font-size: 1.05rem; font-weight: 600; width: 100%; }
.small { padding: 8px 14px; font-size: 0.9rem; }
.primary { background: linear-gradient(135deg, #f59e0b, #d97706); color: #1a1304; }
.record { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; }
.ghost { background: #232836; }
.danger { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.45); color: #f87171; }
.danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.22); filter: none; }

.field { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.field .opt { opacity: 0.7; }
select, input[type="text"] {
  font: inherit;
  color: var(--text);
  background: #11141c;
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}

.check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; color: var(--muted); }
.check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

.meter {
  height: 14px;
  border-radius: 7px;
  background: #11141c;
  border: 1px solid var(--card-edge);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #34d399 0%, #a3e635 55%, #fbbf24 78%, #ef4444 92%);
  clip-path: inset(0 100% 0 0);
}
.meter-fill.hot { filter: brightness(1.35); }

#status-pill {
  margin: 0;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 10px;
  background: #11141c;
  border: 1px solid var(--card-edge);
  color: var(--muted);
}
#status-pill[data-level="good"] { color: var(--good); border-color: rgba(52, 211, 153, 0.4); }
#status-pill[data-level="quiet"] { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); }
#status-pill[data-level="clipping"] { color: var(--rec); border-color: rgba(239, 68, 68, 0.5); }

.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.error { color: var(--rec); font-size: 0.9rem; margin: 0; }

.row { display: flex; gap: 12px; width: 100%; }
.row > * { flex: 1; }

.recovery {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.recovery p { margin: 0; font-size: 0.95rem; }

.rec-head { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rec);
  animation: pulse 1.4s ease-in-out infinite;
}
.dot.paused { animation: none; background: var(--warn); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
}

.timer {
  text-align: center;
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.rec-size {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  margin: -10px 0 0;
}

.storage {
  border-top: 1px solid var(--card-edge);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}
.stored-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #11141c;
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  padding: 10px 12px;
}
.stored-row button { flex: none; }
.stored-info { display: grid; min-width: 0; }
#stored-title { font-size: 0.9rem; }
.stored-detail { color: var(--muted); font-size: 0.82rem; }
#storage-usage.low { color: var(--warn); }

.banner {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--warn);
  width: 100%;
}
.banner.ok {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--good);
}

.save-confirm { display: grid; gap: 8px; width: 100%; }

@media (max-width: 420px) {
  .card { padding: 22px 16px; }
  .timer { font-size: 2.4rem; }
}
