:root {
  --bg: #0b1220;
  --panel: #16213a;
  --panel-2: #1e2b47;
  --text: #eef2f9;
  --muted: #94a3b8;
  --accent: #f97316;
  --ok: #22c55e;
  --warn: #fbbf24;
  --err: #ef4444;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性を CSS の display 指定より優先させる */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---------------- スタート画面 ---------------- */
#start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
}

#start-button {
  width: min(74vw, 300px);
  height: min(74vw, 300px);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 14px 40px rgba(249, 115, 22, 0.4);
  transition: transform 0.12s ease;
}

#start-button:active { transform: scale(0.95); }
#start-button:disabled { background: #64748b; box-shadow: none; }

#start-note { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------------- メイン画面 ---------------- */
#main-screen {
  max-width: 640px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#status-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 6px 0;
  z-index: 2;
}

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.on { background: rgba(34, 197, 94, 0.18); color: var(--ok); }
.badge.busy { background: rgba(251, 191, 36, 0.18); color: var(--warn); }
.badge.bad { background: rgba(239, 68, 68, 0.18); color: var(--err); }

#level-section { display: flex; align-items: center; gap: 10px; }
#level-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
#level-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.08s linear; }
#level-note { margin: 0; font-size: 11px; color: var(--muted); }

#info-grid {
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.info-key { color: var(--muted); }
.info-val { font-weight: 700; text-align: right; }

.panel { background: var(--panel); border-radius: 12px; padding: 10px 12px; }
.panel-label { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); }
.panel-body { margin: 0; font-size: 15px; line-height: 1.6; word-break: break-word; min-height: 1.6em; }
.panel-error .panel-body { color: var(--err); }

#settings, #audio-diagnostic { background: var(--panel); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
#settings summary, #audio-diagnostic summary { color: var(--accent); font-weight: 700; cursor: pointer; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.setting-row label { color: var(--muted); font-size: 13px; flex: 1; }
.setting-row input {
  width: 110px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  text-align: right;
}
#noise-floor-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

#audio-stats, .diagnostic-note { margin: 10px 0; font-size: 12px; color: var(--muted); }
#last-audio { display: block; width: 100%; margin: 8px 0; }
#download-audio { display: inline-block; color: var(--accent); font-weight: 700; padding: 8px 0; }
#download-audio[hidden] { display: none; }

#debug-log {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  max-height: 190px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#debug-log div { border-bottom: 1px solid rgba(148, 163, 184, 0.14); padding: 3px 0; word-break: break-all; }
#debug-log div.err { color: var(--err); }
