:root {
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #243247;
  --bg-input: #0b1120;
  --border: #334155;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-jev: #8b5cf6;
  --accent-jev-hover: #7c3aed;

  --font-sans: 'Zen Kaku Gothic New', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[hidden] {
  display: none !important;
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ヘッダー */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  gap: 6px;
  padding-bottom: 14px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.nav-tab:hover {
  color: #fff;
  background: var(--bg-card);
}

.nav-tab.active {
  background: #3b82f622;
  color: #60a5fa;
  border-color: #3b82f655;
}

.nav-badge {
  background: var(--accent-red);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* ビュー切り替え */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  font-size: 20px;
  color: #fff;
}

.panel-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* フィルターバー (ピル選択) */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  width: 76px;
  flex-shrink: 0;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  background: #172554;
  color: var(--text-main);
  border-color: #3b82f655;
}

.pill.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

/* 今日のクエスト カード (メインヒーロー) */
.quest-hero-card {
  background: linear-gradient(160deg, #1e293b 0%, #16202e 100%);
  border: 1px solid #3b82f666;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  position: relative;
  margin-bottom: 24px;
}

.quest-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.tag-cat {
  background: #312e81;
  color: #c7d2fe;
}

.tag-type {
  background: #0f172a;
  color: #cbd5e1;
  border: 1px solid #334155;
}

.tag-time {
  background: #064e3b;
  color: #a7f3d0;
}

.tag-source {
  background: #3b0764;
  color: #f3e8ff;
  border: 1px solid #7e22ce;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.tag-source.rule {
  background: #172554;
  color: #bfdbfe;
  border-color: #1d4ed8;
}

.quest-hero-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.4;
}

.quest-hero-source {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.quest-summary-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.summary-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #93c5fd;
}

.summary-item p {
  font-size: 14px;
  color: #e2e8f0;
}

.quest-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ボタン */
.btn {
  font-family: inherit;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: #64748b;
  color: #fff;
}

.btn-sm {
  font-size: 12.5px;
  padding: 6px 12px;
}

.btn-lg {
  font-size: 16px;
  padding: 12px 24px;
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* クエスト実行モード (インライン展開) */
.quest-run-card {
  background: #1e293b;
  border: 2px solid var(--accent-blue);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.2);
}

.run-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.run-title {
  font-size: 18px;
  color: #fff;
  margin-top: 6px;
}

.timer-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.timer-clock {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: #60a5fa;
}

.run-instruction-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-left: 4px solid #60a5fa;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
}

.box-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: #93c5fd;
  margin-bottom: 6px;
}

.box-content {
  font-size: 14px;
  line-height: 1.7;
  color: #f1f5f9;
  white-space: pre-wrap;
}

.run-input-group {
  margin-bottom: 18px;
}

.input-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.req {
  color: var(--accent-red);
}

textarea.simple-input, input.simple-input, select.simple-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

textarea.simple-input:focus, input.simple-input:focus, select.simple-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.run-eval-section {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 20px;
}

.eval-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mistake-drawer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed #334155;
}

.run-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 完了バナー */
.completion-banner {
  background: linear-gradient(145deg, #134e4a 0%, #0f3d3a 100%);
  border: 1px solid #14b8a6;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
}

.completion-badge {
  font-size: 12px;
  font-weight: 700;
  color: #5eead4;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.completion-banner h3 {
  font-size: 20px;
  color: #fff;
  margin-bottom: 8px;
}

.completion-banner p {
  font-size: 14px;
  color: #ccfbf1;
  margin-bottom: 16px;
}

.comp-eval-tags {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.comp-tag {
  background: #042f2e;
  border: 1px solid #115e59;
  color: #a7f3d0;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

/* 弱点・復習カード */
.review-items-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.review-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.review-item-main h4 {
  font-size: 15px;
  color: #fff;
  margin-bottom: 4px;
}

.review-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.mistake-badge {
  color: #f87171;
  font-weight: 700;
}

.mistake-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.mistake-summary-card h3 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 12px;
}

.mistake-counts-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.mistake-count-box {
  background: var(--bg-input);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
}

.mistake-name {
  font-size: 11.5px;
  color: var(--text-muted);
}

.mistake-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: #f87171;
}

/* 設定カード */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.status-indicator-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #334155;
  color: #cbd5e1;
}

.status-indicator-tag.active {
  background: #064e3b;
  color: #a7f3d0;
}

.text-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.key-input-row {
  display: flex;
  gap: 8px;
}

.key-input-row input {
  flex-grow: 1;
}

.jev-test-result {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.jev-test-result.success {
  border-color: #10b981;
  color: #6ee7b7;
}

.jev-test-result.error {
  border-color: #ef4444;
  color: #fca5a5;
}

.subtab-row {
  display: flex;
  gap: 8px;
  margin: 14px 0 16px;
}

.subtab {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.subtab.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.simple-form {
  display: none;
}

.simple-form.active {
  display: block;
}

.form-row {
  margin-bottom: 14px;
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.btn-group-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* モーダル */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  color: #fff;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-item:hover {
  border-color: var(--accent-blue);
  background: #172554;
}

.modal-item h4 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 4px;
}

.modal-item p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== v1.2: Jev ブランド & 使いやすさ改善 ===== */

/* Jev ステータスチップ (ヘッダー右上) */
.jev-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.jev-chip:hover {
  border-color: var(--accent-jev);
  color: #fff;
}

.jev-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.jev-chip.on {
  border-color: #7c3aed88;
  color: #ddd6fe;
}

.jev-chip.on .jev-chip-dot {
  background: #a78bfa;
  box-shadow: 0 0 8px #a78bfa;
}

/* 初回セットアップ案内 */
.setup-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #2e1065 0%, #1e1b4b 100%);
  border: 1px solid #7c3aed88;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.setup-banner strong {
  color: #ede9fe;
  font-size: 14px;
}

.setup-banner p {
  font-size: 12.5px;
  color: #c4b5fd;
  margin-top: 2px;
}

.setup-banner-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ボタン追加バリエーション */
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-jev {
  background: var(--accent-jev);
  color: #fff;
  padding: 10px 16px;
}

.btn-jev:hover:not(:disabled) {
  background: var(--accent-jev-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: #fff;
  background: #ffffff10;
}

.btn-ghost.danger:hover {
  color: #fca5a5;
}

.btn-secondary,
.btn-outline,
.btn-primary {
  padding: 10px 16px;
}

.btn-sm {
  font-size: 12.5px;
  padding: 6px 12px;
}

.btn-lg {
  font-size: 16px;
  padding: 12px 24px;
}

/* 判定元タグ */
.tag-source.jev {
  background: #2e1065;
  color: #ede9fe;
  border-color: #7c3aed;
}

.tag-source.warn {
  background: #451a03;
  color: #fde68a;
  border-color: #b45309;
}

.decision-note {
  font-size: 12px;
  color: var(--text-dim);
  margin: -12px 0 18px;
}

.quest-hero-card.loading {
  opacity: 0.6;
}

/* 実行モード */
.timer-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b5cf6, #3b82f6);
  transition: width 1s linear;
}

.timer-clock.over {
  color: #f87171;
}

.run-steps {
  display: flex;
  gap: 8px;
  list-style: none;
  counter-reset: step;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.run-steps li {
  counter-increment: step;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-input);
  border-radius: 6px;
  padding: 4px 10px;
}

.run-steps li::before {
  content: counter(step) ". ";
  color: #a78bfa;
  font-weight: 700;
}

.char-count {
  text-align: right;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.input-label.warn {
  color: #f87171;
}

.mt-8 {
  margin-top: 8px;
}

/* 完了後の解答ポイント */
.answer-notes {
  text-align: left;
  background: #042f2e;
  border: 1px solid #115e59;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 auto 18px;
  max-width: 560px;
}

/* 共通カード */
.card-heading {
  font-size: 15px;
  color: #fff;
  margin-bottom: 12px;
}

.card-title-row .card-heading {
  margin-bottom: 0;
}

.count-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.empty-state {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  color: #6ee7b7;
}

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* 復習 */
.review-item-card {
  gap: 16px;
}

.review-item-tags,
.modal-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}

.due-badge {
  font-size: 11px;
  font-weight: 700;
  color: #fde68a;
  background: #451a03;
  padding: 2px 8px;
  border-radius: 6px;
}

.due-badge.later {
  color: var(--text-muted);
  background: var(--bg-input);
}

.review-item-meta {
  flex-wrap: wrap;
}

.mistake-count-box.top {
  outline: 1px solid #f8717188;
}

.mistake-num small {
  font-size: 11px;
  margin-left: 2px;
}

.history-list,
.item-list {
  display: flex;
  flex-direction: column;
}

.history-row,
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid #ffffff0d;
  font-size: 13px;
}

.history-row:last-child,
.item-row:last-child {
  border-bottom: none;
}

.history-date {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 12px;
  width: 44px;
  flex-shrink: 0;
}

.history-title,
.item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-score,
.item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.hist-ok { color: #6ee7b7; font-size: 12px; white-space: nowrap; }
.hist-ng { color: #f87171; font-size: 12px; }

.mini-jev {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #ddd6fe;
  background: #2e1065;
  border: 1px solid #7c3aed;
  border-radius: 4px;
  padding: 0 5px;
}

/* 設定: Jev */
.card-jev {
  border-color: #7c3aed66;
}

.jev-roles {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 14px;
}

.jev-roles li {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.jev-roles b {
  display: block;
  font-family: var(--font-mono);
  color: #c4b5fd;
  font-size: 13px;
}

.key-status {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.key-status.on {
  border-color: #7c3aed88;
  color: #e2e8f0;
}

.key-status code {
  font-family: var(--font-mono);
  color: #c4b5fd;
}

.key-source {
  display: block;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.key-input-row {
  align-items: stretch;
}

.key-input-wrap {
  position: relative;
  flex: 1;
}

.key-input-wrap input {
  padding-right: 40px;
  font-family: var(--font-mono);
}

.key-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  opacity: 0.7;
}

.key-sub-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.help-details {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.help-details summary {
  cursor: pointer;
  font-weight: 700;
}

.help-details ul {
  margin: 8px 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-details code,
.text-desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #cbd5e1;
}

.file-btn {
  cursor: pointer;
}

.app-version {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* モーダル項目はボタン */
.modal-item {
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.modal-item.current {
  border-color: #7c3aed;
}

/* フォーカス表示 (キーボード操作) */
button:focus-visible,
.simple-input:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

/* トースト通知 */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-blue);
  color: #f1f5f9;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
}

.toast-success { border-left-color: var(--accent-green); }
.toast-error { border-left-color: var(--accent-red); }
.toast-warn { border-left-color: var(--accent-amber); }

/* スマホ対応 */
@media (max-width: 640px) {
  .app-container {
    padding: 16px 16px 60px;
  }

  .header-nav {
    gap: 2px;
    scrollbar-width: none;
  }

  .nav-tab {
    padding: 8px 6px;
    font-size: 12px;
    gap: 3px;
  }

  .brand-sub {
    display: none;
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .quest-hero-card,
  .quest-run-card {
    padding: 18px;
  }

  .quest-hero-title {
    font-size: 19px;
  }

  .quest-card-footer,
  .run-card-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }

  .run-header {
    flex-direction: column;
    gap: 10px;
  }

  .eval-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .review-item-card {
    flex-direction: column;
    align-items: stretch;
  }

  .mistake-counts-row,
  .jev-roles {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row-2col {
    grid-template-columns: 1fr;
  }

  .key-input-row,
  .setup-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .comp-eval-tags {
    flex-wrap: wrap;
  }
}

/* ===== v1.3: クラウド版（ログイン） ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid #7c3aed66;
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.auth-logo {
  margin: 0 auto 14px;
  width: 52px;
  height: 52px;
  font-size: 28px;
}

.auth-title {
  font-size: 22px;
  color: #fff;
}

.auth-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0 24px;
}

.btn-github {
  width: 100%;
  background: #f8fafc;
  color: #0f172a;
}

.btn-github:hover {
  background: #e2e8f0;
}

.auth-message {
  margin-top: 16px;
  font-size: 13px;
  color: #fde68a;
  background: #451a0355;
  border: 1px solid #b4530966;
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-word;
}

.auth-note {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-email {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-key-help {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px dashed #7c3aed88;
  border-radius: 8px;
  padding: 12px 14px;
}

.cloud-key-help ol {
  margin: 8px 0 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cloud-key-help code {
  font-family: var(--font-mono);
  color: #c4b5fd;
}

@media (max-width: 640px) {
  .user-email {
    display: none;
  }
}

/* ===== 一問一答 ===== */
.quiz-counter {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
}

.quiz-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-left: 4px solid var(--accent-purple);
  border-radius: 10px;
  padding: 18px;
  margin: 18px 0;
}

.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.quiz-topic {
  font-size: 12px;
  color: var(--text-muted);
}

.quiz-question {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.7;
  color: #fff;
  margin-bottom: 16px;
}

.quiz-reveal {
  width: 100%;
}

.quiz-answer {
  background: #042f2e;
  border: 1px solid #115e59;
  border-radius: 8px;
  padding: 12px 14px;
}

.quiz-answer .box-label {
  color: #5eead4;
}

.quiz-answer-text {
  font-size: 15px;
  line-height: 1.7;
  color: #f1f5f9;
  margin-bottom: 8px;
}

.quiz-judge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.quiz-score {
  font-size: 13px;
  color: var(--text-muted);
  align-self: center;
}

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  margin-left: 6px;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #cbd5e1;
  opacity: 0.8;
}

.run-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: #93c5fd;
  text-decoration: none;
}

.run-link:hover {
  text-decoration: underline;
}

.wrong-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wrong-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  padding-bottom: 10px;
  border-bottom: 1px solid #115e59;
}

.wrong-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.wrong-q {
  color: #f1f5f9;
  font-weight: 700;
}

.wrong-a {
  color: #99f6e4;
}

.wrong-list a {
  color: #93c5fd;
  font-size: 12px;
  text-decoration: none;
}

/* ===== 教材タブ ===== */
.text-desc a {
  color: #93c5fd;
}

.quiz-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}

.quiz-stat-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.quiz-stat-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.quiz-stat-num {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}

.quiz-stat-num small {
  font-size: 13px;
  color: var(--text-muted);
}

.quiz-stat-bar {
  height: 6px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}

.quiz-stat-bar div {
  width: 0;
  height: 100%;
  background: var(--accent-green);
}

.quiz-stat-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.quiz-start-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.reading-filter {
  margin: 4px 0 12px;
}

.reading-list {
  display: flex;
  flex-direction: column;
}

.reading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

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

.reading-main {
  min-width: 0;
}

.reading-row > .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.reading-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.reading-title {
  display: block;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.reading-title:hover {
  color: #93c5fd;
}

.reading-focus {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.quiz-review-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-review-card .text-desc {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .quiz-start-form {
    grid-template-columns: 1fr 1fr;
  }

  .quiz-question {
    font-size: 16px;
  }

  .reading-row,
  .quiz-review-card {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===== 4択・報告 ===== */
.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.quiz-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-choice:hover:not(:disabled) {
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
}

.quiz-choice:disabled {
  cursor: default;
  opacity: 0.75;
}

.quiz-choice.correct {
  border-color: var(--accent-green);
  background: #064e3b;
  opacity: 1;
}

.quiz-choice.wrong {
  border-color: var(--accent-red);
  background: #450a0a;
  opacity: 1;
}

.choice-no {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #93c5fd;
}

.quiz-next {
  margin-bottom: 8px;
}

.quiz-next .btn {
  width: 100%;
}

.quiz-answer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin-top: 8px;
  font-family: inherit;
  font-size: 12.5px;
  color: #fbbf24;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.quiz-report-form {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 8px;
  margin-top: 10px;
}

/* ===== 記述式の採点補助・添削 ===== */
.written-extra {
  background: #0f172a;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}

.field-hint .run-link {
  margin-top: 0;
}

.keyword-rate {
  font-size: 13px;
  color: #f1f5f9;
  margin-bottom: 8px;
}

.keyword-chips {
  text-align: left;
}

.kw-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 0 6px 6px 0;
}

.kw-chip.ok {
  background: #064e3b;
  color: #a7f3d0;
}

.kw-chip.ng {
  background: #450a0a;
  color: #fecaca;
}

.comp-links {
  margin-bottom: 8px;
}

.review-result {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #115e59;
  font-size: 13.5px;
}

/* ===== 分野別の正答率・報告 ===== */
.field-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.field-name small {
  color: var(--text-dim);
  font-size: 11px;
}

.field-row.weak .field-name {
  color: #fbbf24;
  font-weight: 700;
}

.field-bar {
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
}

.field-bar div {
  width: 0;
  height: 100%;
  background: var(--accent-green);
}

.field-row.weak .field-bar div {
  background: var(--accent-amber);
}

.field-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 90px;
  text-align: right;
}

.field-pct small {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-dim);
  font-size: 11px;
}

.report-list {
  display: flex;
  flex-direction: column;
}

.report-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.report-q {
  font-weight: 700;
  font-size: 13.5px;
}

.report-a,
.report-note {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ===== オフライン ===== */
.offline-chip {
  font-size: 12px;
  font-weight: 700;
  color: #fde68a;
  background: #422006;
  border: 1px solid #92400e;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.offline-banner {
  border-color: #92400e;
  background: linear-gradient(135deg, #422006 0%, #1e293b 100%);
}

@media (max-width: 640px) {
  .quiz-report-form {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr auto;
  }

  .field-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .report-row {
    flex-direction: column;
    align-items: stretch;
  }
}
