/* =========================================================
   資格勉強アプリ  スタイル
   方針: アニメーション無し / 角ばり(border-radius <= 4px) /
         3色構成(背景・テキスト・アクセント) / モノスペース主体
   ========================================================= */

:root {
  --radius: 3px;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas,
          "DejaVu Sans Mono", "Noto Sans Mono CJK JP", "MS Gothic", monospace;
  --gap: 12px;
}

/* ---- ライトテーマ(既定) ---- */
:root,
:root[data-theme="light"] {
  --bg: #eeeee8;
  --fg: #1b1b1b;
  --accent: #1f6f5c;
  --line: rgba(27, 27, 27, 0.22);
  --line-soft: rgba(27, 27, 27, 0.10);
  --fg-dim: rgba(27, 27, 27, 0.55);
  --accent-fg: #ffffff;
  --ok: #1f6f5c;
  --bad: #9d2929;
  --panel: rgba(27, 27, 27, 0.035);
}

/* ---- ダークテーマ ---- */
:root[data-theme="dark"] {
  --bg: #15171b;
  --fg: #d7d7cd;
  --accent: #4cc2a5;
  --line: rgba(215, 215, 205, 0.20);
  --line-soft: rgba(215, 215, 205, 0.09);
  --fg-dim: rgba(215, 215, 205, 0.55);
  --accent-fg: #15171b;
  --ok: #4cc2a5;
  --bad: #e06c6c;
  --panel: rgba(215, 215, 205, 0.045);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* どこでもアニメ無効を徹底 */
*, *::before, *::after {
  transition: none !important;
  animation: none !important;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 700; line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small { color: var(--fg-dim); }

/* ---- レイアウト ---- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: 0.5px; white-space: nowrap; }
.brand b { color: var(--accent); }

nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
}
nav.tabs a:hover { border-color: var(--accent); text-decoration: none; }
nav.tabs a.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
.view-title { margin-bottom: 14px; }

/* ---- 共通部品 ---- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  margin-bottom: var(--gap);
}
.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--fg-dim); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

button, .btn {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 700;
}
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button.small { padding: 2px 8px; font-size: 12px; }

input, select, textarea {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { width: 100%; resize: vertical; }
label { color: var(--fg-dim); font-size: 12px; }

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 6px;
  font-size: 11px;
  color: var(--fg-dim);
}
.badge.accent { color: var(--accent); border-color: var(--accent); }

.tag-pill {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
  color: var(--fg-dim);
}
.tag-pill.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

hr { border: none; border-top: 1px solid var(--line-soft); margin: 10px 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; }
.kv > div:nth-child(odd) { color: var(--fg-dim); }

/* ---- ダッシュボード KPI ---- */
.kpi { text-align: left; }
.kpi .num { font-size: 30px; font-weight: 700; line-height: 1; }
.kpi .num.accent { color: var(--accent); }
.kpi .unit { font-size: 12px; color: var(--fg-dim); }

.bar {
  height: 8px; background: var(--line-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-top: 6px;
}
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---- タスク ---- */
.task {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft);
}
.task:last-child { border-bottom: none; }
.task.done .task-title { text-decoration: line-through; color: var(--fg-dim); }
.task input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; }
.task-meta { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }
.task-note { margin-top: 6px; }
.phase-head { margin: 14px 0 4px; font-size: 13px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 2px; }

/* ---- 演習 ---- */
.prob-list-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 6px; cursor: pointer;
}
.prob-list-item:hover { border-color: var(--accent); }
.prob-list-item.solved { border-left: 3px solid var(--ok); }
.diff { color: var(--accent); letter-spacing: 1px; }

.code-area {
  width: 100%; min-height: 220px;
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  tab-size: 4; white-space: pre;
}
.console {
  font-family: var(--mono); font-size: 13px;
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; min-height: 80px;
  max-height: 320px; overflow: auto;
}
.console .err { color: var(--bad); }
.result-pass { color: var(--ok); font-weight: 700; }
.result-fail { color: var(--bad); font-weight: 700; }
.score-line { font-size: 20px; font-weight: 700; }
.testcase { padding: 4px 0; border-bottom: 1px dashed var(--line-soft); }
.testcase .ok { color: var(--ok); }
.testcase .ng { color: var(--bad); }

details.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-top: 8px; }
details.box > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.box pre { margin: 8px 0 0; white-space: pre-wrap; }

/* ---- タイマー ---- */
.timer-display {
  font-size: 72px; font-weight: 700; text-align: center;
  letter-spacing: 2px; line-height: 1.1; margin: 10px 0;
}
.timer-display.break { color: var(--accent); }
.timer-state { text-align: center; color: var(--fg-dim); letter-spacing: 3px; }

/* ---- カレンダー ---- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .cell {
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  min-height: 40px; padding: 3px; font-size: 11px;
}
.cal .cell.head { text-align: center; color: var(--fg-dim); border: none; min-height: 0; }
.cal .cell.empty { border: none; }
.cal .cell .d { color: var(--fg-dim); }
.cal .cell.studied { background: var(--accent); color: var(--accent-fg); }
.cal .cell.studied .d { color: var(--accent-fg); }
.cal .cell.today { outline: 2px solid var(--accent); }

/* ---- フラッシュカード ---- */
.flashcard {
  border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 220px; padding: 20px; display: flex;
  flex-direction: column; justify-content: center; align-items: center;
  text-align: center; cursor: pointer; background: var(--panel);
}
.flashcard .face-label { position: absolute; top: 8px; left: 12px; font-size: 11px; color: var(--fg-dim); }
.flashcard .front { font-size: 22px; font-weight: 700; }
.flashcard .back { font-size: 14px; white-space: pre-wrap; text-align: left; max-width: 640px; }
.fc-wrap { position: relative; }

/* ---- グラフ ---- */
.chart-wrap { width: 100%; overflow-x: auto; }
canvas { display: block; max-width: 100%; }

/* ---- scrollbar 控えめ ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--radius); }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 8px 16px;
  border-radius: var(--radius); font-size: 13px; z-index: 100;
}
.hidden { display: none !important; }
.center { text-align: center; }
.loader { color: var(--fg-dim); padding: 20px; text-align: center; }
