/* CISSP苦手克服アプリ */
:root {
  --bg: #f5f2ec;
  --bg-2: #ebe6dc;
  --paper: #ffffff;
  --ink: #1f1d2c;
  --ink-2: #4a4659;
  --ink-3: #7c7791;
  --line: #e0dbcf;
  --line-strong: #c9c2b1;
  --primary: #3a3673;
  --primary-2: #524d9a;
  --primary-ink: #ffffff;
  --accent: #c98a3a;
  --accent-2: #e8b057;
  --success: #4a7a4f;
  --success-bg: #e3eddb;
  --danger: #b04545;
  --danger-bg: #f5e0dc;
  --warn: #8a6f1c;
  --warn-bg: #f5ecd0;
  --d1: #5B5FCF;
  --d2: #8B6FCF;
  --d3: #CF6F8B;
  --d4: #CF8B5B;
  --d5: #CFB05B;
  --d6: #7FA75B;
  --d7: #5B9F8B;
  --d8: #5B8BCF;
  --shadow-sm: 0 1px 2px rgba(31, 29, 44, 0.04), 0 1px 3px rgba(31, 29, 44, 0.06);
  --shadow: 0 1px 2px rgba(31, 29, 44, 0.04), 0 4px 12px rgba(31, 29, 44, 0.08);
  --shadow-lg: 0 4px 16px rgba(31, 29, 44, 0.08), 0 12px 32px rgba(31, 29, 44, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
}

/* ===== App shell ===== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.header {
  padding: 28px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px;
  background: var(--ink); color: white;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: 0.05em;
  align-self: center;
}
.brand-title {
  font-size: 17px; font-weight: 700; letter-spacing: 0.01em;
  color: var(--ink);
}
.brand-sub {
  font-size: 12px; color: var(--ink-3); font-weight: 500;
  letter-spacing: 0.06em;
}
.stats-pill {
  display: flex; gap: 14px; align-items: center;
  font-size: 12px; color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 999px;
}
.stats-pill strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-divider { width: 1px; height: 12px; background: var(--line); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  padding: 14px 0 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: none;
  background: transparent;
  padding: 12px 18px 14px;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
  letter-spacing: 0.02em;
}
.tab:hover { color: var(--ink-2); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 700;
}
.tab-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--ink-3);
  margin-left: 6px;
  background: var(--bg-2);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-badge { color: var(--ink-2); background: var(--paper); }

/* ===== Filter bar ===== */
.filter-bar {
  padding: 18px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar-label {
  font-size: 11px; color: var(--ink-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-right: 4px;
}
.chip {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-2);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c, var(--ink-3));
  display: inline-block;
}
.chip.active .chip-dot { background: rgba(255,255,255,0.7); }

/* ===== Main content ===== */
.main { padding: 8px 0 64px; }

/* ===== Quiz card ===== */
.q-shell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  position: relative;
}
.q-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--ink-3);
}
.q-progress {
  display: flex; align-items: center; gap: 10px;
  font-variant-numeric: tabular-nums;
}
.q-progress-bar {
  width: 110px; height: 4px;
  background: var(--bg-2); border-radius: 999px; overflow: hidden;
}
.q-progress-fill { height: 100%; background: var(--ink); border-radius: 999px; transition: width 0.3s; }
.q-domain-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  background: var(--bg-2); color: var(--ink-2);
  padding: 3px 10px; border-radius: 999px; font-weight: 600;
  letter-spacing: 0.02em;
}
.q-topic {
  font-size: 12px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 8px;
}
.q-text {
  font-size: 19px;
  line-height: 1.65;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 24px;
  text-wrap: pretty;
}
.q-choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.q-choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  transition: all 0.15s;
  line-height: 1.55;
}
.q-choice:not(:disabled):hover {
  border-color: var(--primary);
  background: #faf9ff;
}
.q-choice-letter {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}
.q-choice:not(:disabled):hover .q-choice-letter { background: var(--primary); color: white; }

.q-choice.correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.q-choice.correct .q-choice-letter { background: var(--success); color: white; }
.q-choice.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.q-choice.wrong .q-choice-letter { background: var(--danger); color: white; }
.q-choice:disabled { cursor: default; }
.q-choice.dim { opacity: 0.55; }

.q-result-block {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.q-result-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.q-result-head.ok { color: var(--success); }
.q-result-head.ng { color: var(--danger); }
.q-explain { margin-bottom: 14px; }
.q-explain-label {
  font-size: 10px; font-weight: 700; color: var(--ink-3);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 5px;
}
.q-explain-body {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.7;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.q-explain.key .q-explain-body {
  border-left-color: var(--primary);
  background: #f6f5fc;
}

.q-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: space-between;
  align-items: center;
}
.q-action-group { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--primary); border-color: var(--primary); }
.btn.subtle { border-color: transparent; color: var(--ink-3); }
.btn.subtle:hover { background: var(--bg-2); color: var(--ink); border-color: transparent; }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Flashcard ===== */
.fc-shell {
  margin: 0 auto;
}
.fc-card {
  position: relative;
  width: 100%;
  min-height: 320px;
  cursor: pointer;
}
.fc-face {
  position: absolute; inset: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.32s ease, transform 0.32s ease;
  pointer-events: auto;
}
.fc-face.back {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.fc-card.flipped .fc-face.front {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
.fc-card.flipped .fc-face.back {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.fc-cat {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  position: absolute;
  top: 24px;
  left: 32px;
}
.fc-flip-hint {
  font-size: 10px; color: var(--ink-3);
  position: absolute; top: 24px; right: 32px;
  letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.fc-front-content {
  text-align: center;
  padding: 30px 0 10px;
}
.fc-front-term {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
  line-height: 1.35;
}
.fc-back-content {
  padding: 24px 0 0;
}
.fc-back-term {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 14px;
}
.fc-back-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  text-wrap: pretty;
}
.fc-controls {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.fc-rate {
  display: flex; gap: 8px;
}
.fc-rate button {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--ink-2);
}
.fc-rate button.known { color: var(--success); border-color: var(--success); }
.fc-rate button.known:hover { background: var(--success-bg); }
.fc-rate button.review { color: var(--warn); border-color: var(--warn); }
.fc-rate button.review:hover { background: var(--warn-bg); }
.fc-rate button.unknown { color: var(--danger); border-color: var(--danger); }
.fc-rate button.unknown:hover { background: var(--danger-bg); }

.fc-marker {
  position: absolute; bottom: 24px; right: 32px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* ===== Browse mode ===== */
.browse-list {
  display: flex; flex-direction: column; gap: 12px;
}
.browse-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.browse-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px;
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.browse-q {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.12s;
}
.browse-q:last-child { border-bottom: none; }
.browse-q:hover { background: var(--bg); }
.browse-q-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
}
.browse-q-text {
  font-size: 14px; color: var(--ink);
  line-height: 1.55; font-weight: 500;
  flex: 1;
  text-wrap: pretty;
}
.browse-q-topic {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  white-space: nowrap;
}
.browse-q-detail {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-2);
  animation: slideDown 0.25s ease;
}
.browse-q-detail .ans {
  color: var(--success);
  font-weight: 700;
  margin-bottom: 6px;
}
.browse-q-detail .lbl {
  font-size: 10px; font-weight: 700; color: var(--ink-3);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: 12px; margin-bottom: 4px;
}

/* ===== Footer ===== */
.footer {
  padding: 24px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 11px;
  border-top: 1px solid var(--line);
  letter-spacing: 0.04em;
}

/* ===== Empty/finish states ===== */
.empty {
  text-align: center;
  padding: 60px 30px;
  color: var(--ink-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.empty-title { font-size: 18px; color: var(--ink); margin-bottom: 8px; font-weight: 700; }
.empty-sub { font-size: 13.5px; line-height: 1.7; }
.empty-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; }

/* ===== Welcome ===== */
.welcome {
  text-align: center;
  padding: 50px 20px 30px;
}
.welcome-h {
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.welcome-sub {
  color: var(--ink-2); font-size: 14.5px;
  max-width: 540px; margin: 0 auto;
  line-height: 1.75;
}

/* ===== Modes overview ===== */
.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}
.mode-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font: inherit;
  color: var(--ink);
  position: relative;
}
.mode-card:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.mode-card-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--bg-2);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 16px;
}
.mode-card-title {
  font-size: 14px; font-weight: 700;
  margin-bottom: 4px;
}
.mode-card-sub {
  font-size: 12px; color: var(--ink-3);
  line-height: 1.55;
}

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .app { padding: 0 14px; }
  .header { padding: 18px 0 6px; flex-wrap: wrap; }
  .stats-pill { font-size: 11px; padding: 5px 10px; gap: 10px; }
  .q-shell, .fc-face { padding: 22px 18px; }
  .q-text { font-size: 16.5px; }
  .fc-front-term { font-size: 22px; }
  .welcome-h { font-size: 24px; }
  .modes { grid-template-columns: 1fr; }
  .tab { padding: 10px 12px 12px; font-size: 13px; }
  .browse-section { padding: 16px; }
  .q-actions { flex-wrap: wrap; }
  .fc-controls { flex-wrap: wrap; }
}
