:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #007aff;
  --accent-soft: #e8f1ff;
  --danger: #ff3b30;
  --danger-soft: #ffece8;
  --success: #34c759;
  --success-soft: #e7f9ec;
  --warning: #ff9500;
  --warning-soft: #fff3e0;
  --border: rgba(60, 60, 67, 0.1);
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --accent: #0a84ff;
    --accent-soft: #10233d;
    --danger: #ff453a;
    --success: #30d158;
    --success-soft: #12281a;
    --warning: #ff9f0a;
    --warning-soft: #2e2410;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 32px);
  min-height: 100vh;
}

.top-bar {
  text-align: center;
  margin-bottom: 20px;
}

.top-bar h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.record-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
}

.record-visual {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.pulse {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}

.pulse.recording {
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.35; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.record-button {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.3);
}

.record-button:active {
  transform: scale(0.94);
}

.record-button.recording {
  background: var(--danger);
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.35);
}

.record-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  display: block;
  transition: border-radius 0.2s ease, width 0.2s ease, height 0.2s ease;
}

.record-button.recording .record-icon {
  border-radius: 6px;
  width: 28px;
  height: 28px;
}

.timer {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.status-text {
  color: var(--text-secondary);
  font-size: 15px;
}

.info-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-heading h2 { font-size: 16px; margin: 0 0 12px; }
.text-button { border: 0; background: none; color: var(--danger); font: inherit; font-size: 13px; cursor: pointer; }
.history-preview { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }
.history-row:last-child { border-bottom: 0; }
.history-row b { color: var(--accent); font-size: 16px; }
.history-row span:last-child { grid-column: 1 / -1; }

.notice-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--warning);
}

.hidden {
  display: none !important;
}

.center-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-bottom: 18px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.analyzing-text {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0;
}

.summary-card h2 {
  font-size: 19px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.score-card { border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border)); }
.score-layout { display: flex; align-items: center; gap: 18px; }
.score-ring { width: 94px; height: 94px; flex: 0 0 94px; border: 8px solid var(--accent); border-radius: 50%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; line-height: 1; color: var(--accent); }
.score-ring span { font-size: 32px; font-weight: 800; letter-spacing: -0.06em; }
.score-ring small { width: 100%; text-align: center; color: var(--text-secondary); font-size: 11px; margin-top: 4px; }
.score-layout h2 { font-size: 18px; margin: 0 0 5px; }
.score-message { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin: 0; }
.score-breakdown { margin-top: 18px; }
.score-row { display: grid; grid-template-columns: 92px 1fr 42px; gap: 8px; align-items: center; font-size: 12px; margin-top: 8px; }
.score-row b { text-align: right; font-size: 11px; }
.score-bar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.comparison-date { font-size: 12px; color: var(--text-secondary); margin: -4px 0 12px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare-grid > div { background: var(--bg); border-radius: 12px; padding: 11px; }
.compare-grid span { display: block; color: var(--text-secondary); font-size: 11px; margin-bottom: 5px; }
.compare-grid strong { display: block; font-size: 13px; }
.delta { display: inline-block; font-size: 11px; margin-left: 3px; }
.delta.up { color: var(--success); }.delta.down { color: var(--danger); }.delta.same { color: var(--text-secondary); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.summary-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.summary-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row .label {
  color: var(--text-secondary);
}

.metric-row .value {
  font-weight: 600;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

.pill.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.empty-state {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.comment-box {
  margin-top: 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-primary);
}

.comment-box.good {
  background: var(--success-soft);
}

.comment-box.tip {
  background: var(--warning-soft);
}

.coaching-card {
  border: 1px solid var(--border);
}

.coaching-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.coaching-list li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.coaching-list .num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transcript-card {
  background: var(--card-bg);
}

.transcript-text {
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

.transcript-text mark {
  background: var(--warning-soft);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 0 2px;
}

.transcript-text mark.numbering {
  background: var(--accent-soft);
}

.transcript-text mark.labeling {
  background: var(--success-soft);
}

.secondary-button {
  display: block;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--card-bg);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
  margin-top: 4px;
}

.secondary-button:active {
  transform: scale(0.98);
}
