/* ペアプレゼンテーションタイマー — ミニマルデザイン（Constitution 原則 V）
   残り時間の視認性を最優先（FR-003, FR-025, SC-006），レスポンシブ（FR-024） */

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #8a8a8a;
  --accent-presentation: #2563eb;
  --accent-qa: #059669;
  --accent-buffer: #d97706;
  --accent-done: #7c3aed;
  --danger: #dc2626;
  --surface: #ffffff;
  --border: #e5e5e5;
}

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

/* display 指定を持つ要素でも hidden 属性を必ず優先する */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.4s ease;
}

/* フェーズごとの背景トーン（一瞥で状況が分かるように） */
body[data-phase="presentation"] { background: #eff6ff; }
body[data-phase="qa"]           { background: #ecfdf5; }
body[data-phase="buffer"]       { background: #fffbeb; }
body[data-phase="completed"]    { background: #f5f3ff; }

.view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem max(1.5rem, env(safe-area-inset-bottom));
  max-width: 60rem;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
}

.round-indicator {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.icon-button {
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem;
}
.icon-button:hover { color: var(--fg); }

/* タイマー画面: ヘッダーとボタンを上下端に固定し，
   時刻表示は画面全体に重ねたグリッドで厳密に中央へ置く */
#timer-view {
  position: relative;
  justify-content: space-between;
}

.bottom-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 中央: フェーズと残り時間（1fr / auto / 1fr で time-display が真の中央） */
.timer-center {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  row-gap: 0.5rem;
  padding: 0 1rem;
  text-align: center;
  pointer-events: none;
}

.timer-center .phase-label { align-self: end; }
.timer-center .phase-note { align-self: start; }

.phase-label {
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}
body[data-phase="presentation"] .phase-label { color: var(--accent-presentation); }
body[data-phase="qa"] .phase-label           { color: var(--accent-qa); }
body[data-phase="buffer"] .phase-label       { color: var(--accent-buffer); }
body[data-phase="completed"] .phase-label    { color: var(--accent-done); }

.time-display {
  font-size: clamp(6rem, 28vw, 18rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.time-display.urgent { color: var(--danger); }

.phase-note {
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: var(--muted);
  min-height: 1.5em;
}

/* 注意表示（音声・スリープ抑止） */
.notices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-buffer);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--fg);
}

/* 操作ボタン */
.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.control-button {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.9rem 2rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  min-width: 8rem;
  touch-action: manipulation;
}
.control-button:active { transform: scale(0.98); }
.control-button.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.control-button.danger { color: var(--danger); }

/* 設定画面 */
.settings-title { font-size: 1.25rem; font-weight: 700; }

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
  max-width: 24rem;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

.field select {
  font-size: 1.1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

/* 時間プリセットのチップ */
.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  touch-action: manipulation;
}
.chip.selected {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.voice-field {
  border: none;
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
  align-items: center;
}
.voice-field legend {
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.voice-field label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.settings-messages {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}
.settings-messages .error { color: var(--danger); }
.settings-messages .warning { color: var(--accent-buffer); }

/* 確認ダイアログ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.confirm-dialog {
  background: var(--surface);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 22rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  font-size: 1rem;
}
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.confirm-actions .control-button { min-width: 6rem; padding: 0.7rem 1.2rem; }

/* 横幅の狭い端末 */
@media (max-width: 480px) {
  .view { padding-left: 1rem; padding-right: 1rem; }
  .control-button { flex: 1 1 40%; min-width: 0; }
}
