/**
 * [INPUT]: なし（独立スタイルモジュール）
 * [OUTPUT]: アプリ全体のビジュアルスタイル
 * [POS]: プレゼンテーション層、index.html が参照
 * [PROTOCOL]: 変更時このヘッダーを更新し、CLAUDE.md を確認
 */

/* ============================================================
   リセット & ベース
   ============================================================ */

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

:root {
  /* ── 色彩: 温暖で落ち着いたトーン ── */
  --bg:        #1a1815;
  --bg-card:   #23201b;
  --bg-hover:  #2d2924;
  --bg-input:  #1e1b17;
  --border:    #3a352e;
  --border-lt: #4a443c;

  --text:      #e8e0d4;
  --text-dim:  #9e9588;
  --text-mute: #6b6359;

  --accent:    #d4845a;
  --accent-bg: rgba(212, 132, 90, 0.12);
  --accent-hover: #e09468;

  --green:     #7dba6a;
  --green-bg:  rgba(125, 186, 106, 0.12);
  --red:       #d46a6a;
  --red-bg:    rgba(212, 106, 106, 0.12);
  --yellow:    #d4b85a;
  --yellow-bg: rgba(212, 184, 90, 0.12);

  /* ── タイポグラフィ ── */
  --font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  --mono: "SF Mono", "Fira Code", "Consolas", monospace;

  /* ── スペーシング ── */
  --gap:  16px;
  --gap2: 24px;
  --radius: 10px;
  --radius-sm: 6px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  padding-top: 56px;
  overflow-x: hidden;
}

/* ============================================================
   ヘッダー
   ============================================================ */

#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(26, 24, 21, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--gap);
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.header-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ============================================================
   ビュー切替
   ============================================================ */

.view {
  display: none;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gap2) var(--gap);
  padding-bottom: 80px;
}

.view.active {
  display: block;
}

/* ============================================================
   ホーム画面
   ============================================================ */

.home-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap2);
}

.home-brand {
  text-align: center;
  padding: 32px 0 8px;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 16px;
  border: 1px solid rgba(212, 132, 90, 0.2);
}

.home-brand h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
}

.home-modes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: var(--gap);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

.mode-card:hover {
  border-color: var(--border-lt);
  background: var(--bg-hover);
}

.mode-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg);
  border-radius: 12px;
  color: var(--accent);
}

.mode-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.mode-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.home-stats {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: none;
}

.home-stats.has-data {
  display: block;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.stats-value {
  color: var(--text);
  font-weight: 500;
}

/* ============================================================
   質問一覧
   ============================================================ */

.list-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn:hover:not(.active) {
  border-color: var(--border-lt);
  color: var(--text);
}

.list-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.list-item:hover {
  border-color: var(--border-lt);
  background: var(--bg-hover);
}

.list-item.starred {
  border-left: 3px solid var(--yellow);
}

.list-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.list-item-cat {
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 10px;
}

.list-item-star {
  color: var(--yellow);
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.list-item.starred .list-item-star {
  opacity: 1;
}

.list-item-q {
  font-size: 0.92rem;
  line-height: 1.5;
}

.list-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tag {
  font-size: 0.68rem;
  color: var(--text-mute);
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 展開された回答 */
.list-item-answer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: none;
}

.list-item.expanded .list-item-answer {
  display: block;
}

.list-answer-label {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 6px;
  font-weight: 500;
}

.list-answer-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 8px;
}

.list-hint-text {
  font-size: 0.8rem;
  color: var(--text-mute);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

/* ============================================================
   模擬練習
   ============================================================ */

.sim-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* 進捗バー */
.sim-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0;
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* 質問カード */
.sim-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  min-height: 120px;
}

/* 音声状態インジケーター */
.audio-status {
  font-size: 0.72rem;
  text-align: center;
  padding: 4px 12px;
  border-radius: 12px;
  line-height: 1.4;
}

.audio-status.status-loading {
  color: var(--text-dim);
}

.audio-status.status-rec {
  color: var(--green);
  background: var(--green-bg);
}

.audio-status.status-warn,
.audio-status.status-tts {
  color: var(--yellow);
  background: var(--yellow-bg);
}

.audio-status.status-error {
  color: var(--red);
  background: var(--red-bg);
}

.sim-category {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-bg);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.sim-question {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 12px;
}

.sim-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* タイマー */
.sim-timer-display {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  display: none;
}

.sim-timer-display.active {
  display: flex;
}

.timer-ring {
  position: relative;
  width: 100px;
  height: 100px;
}

.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.timer-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s;
}

.timer-fg.warning {
  stroke: var(--red);
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.4rem;
  font-weight: 600;
  font-family: var(--mono);
}

.timer-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* 模範回答 */
.sim-answer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.answer-header {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 10px;
}

.answer-body {
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.answer-hint {
  font-size: 0.82rem;
  color: var(--text-mute);
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* 操作ボタン */
.sim-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.sim-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.sim-btn:hover {
  border-color: var(--border-lt);
  color: var(--text);
  background: var(--bg-hover);
}

.sim-btn.active {
  border-color: var(--yellow);
  color: var(--yellow);
  background: var(--yellow-bg);
}

/* ナビゲーション */
.sim-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.nav-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all 0.15s;
}

.nav-btn:hover {
  border-color: var(--border-lt);
  color: var(--text);
  background: var(--bg-hover);
}

/* ============================================================
   設定
   ============================================================ */

.settings-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap2);
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 0.88rem;
  font-weight: 500;
}

.setting-hint {
  font-size: 0.78rem;
  color: var(--text-mute);
  line-height: 1.5;
}

.setting-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.opt-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.opt-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.opt-btn:hover:not(.active) {
  border-color: var(--border-lt);
  color: var(--text);
}

.reset-btn {
  background: var(--red-bg);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--red);
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  align-self: flex-start;
}

.reset-btn:hover {
  opacity: 0.8;
}

/* ============================================================
   レスポンシブ
   ============================================================ */

@media (max-width: 480px) {
  .sim-actions {
    flex-wrap: wrap;
  }

  .sim-btn {
    flex: 1;
    min-width: calc(50% - 4px);
    justify-content: center;
  }

  .sim-btn span {
    font-size: 0.78rem;
  }
}

/* ============================================================
   アニメーション
   ============================================================ */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view.active {
  animation: fade-in 0.2s ease;
}

@media (max-width: 520px) {
  .intro-builder-form {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   30秒 自己紹介ジェネレーター
   ============================================================ */

.intro-builder-group {
  gap: 14px;
}

.intro-builder-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.builder-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.builder-field-full {
  grid-column: 1 / -1;
}

.builder-field span {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.builder-field input,
.builder-field select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
}

.builder-field input::placeholder {
  color: var(--text-mute);
}

.builder-field input:focus,
.builder-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 132, 90, 0.12);
}

.intro-output-card {
  margin-top: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.intro-output-card-sub {
  margin-top: 10px;
}

.intro-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.intro-output-label {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

.intro-output-text {
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text);
}

.intro-output-text-sub {
  color: var(--text-dim);
}

.copy-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
}

.copy-btn:hover {
  border-color: var(--border-lt);
  color: var(--text);
}
