/* shadcn/ui（zinc テーマ）のトークンと部品の形に合わせたスタイル */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #a1a1aa;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --success: #16a34a;
  --destructive: #dc2626;
  --radius: 0.625rem;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #09090b; --foreground: #fafafa; --card: #0f0f11; --muted: #27272a; --muted-foreground: #a1a1aa;
    --accent: #27272a; --border: #27272a; --input: #3f3f46; --ring: #71717a;
    --primary: #fafafa; --primary-foreground: #18181b; --success: #4ade80; --destructive: #f87171;
  }
}
:root[data-theme="dark"] {
  --background: #09090b; --foreground: #fafafa; --card: #0f0f11; --muted: #27272a; --muted-foreground: #a1a1aa;
  --accent: #27272a; --border: #27272a; --input: #3f3f46; --ring: #71717a;
  --primary: #fafafa; --primary-foreground: #18181b; --success: #4ade80; --destructive: #f87171;
}

* { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }

/* ヘッダー */
.topbar-wrap { border-bottom: 1px solid var(--border); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 880px; margin: 0 auto; padding: 10px 20px;
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.nav { display: flex; align-items: center; gap: 2px; }
.nav a, .icon-btn {
  border: 0; background: none; padding: 6px 12px; border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground); font-size: 14px; font-weight: 500;
}
.nav a:hover, .icon-btn:hover { background: var(--accent); color: var(--foreground); }
.nav a.active { color: var(--foreground); background: var(--accent); }
.icon-btn { font-size: 13px; }
body.focus-mode .topbar-wrap { display: none; }

/* レイアウト */
.app { max-width: 880px; margin: 0 auto; padding: 28px 20px 64px; }
.stack { display: grid; gap: 32px; }
.section-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 12px; }
.muted { color: var(--muted-foreground); }
.small { font-size: 13px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }

/* Card */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-xs);
}
.card > .section-title { margin-bottom: 8px; }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input); background: var(--background); box-shadow: var(--shadow-xs);
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: background-color .15s, opacity .15s;
}
.btn:hover { background: var(--accent); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { border-color: transparent; background: none; box-shadow: none; }
.btn.ghost:hover { background: var(--accent); }
.btn.danger { color: var(--destructive); }
kbd {
  display: inline-flex; align-items: center; height: 20px; padding: 0 5px; border-radius: 4px;
  font: 500 11px var(--mono); background: var(--muted); color: var(--muted-foreground);
}
.btn kbd { margin-right: -6px; }
.btn.primary kbd { background: color-mix(in srgb, var(--primary-foreground) 16%, transparent); color: inherit; }

/* ホーム */
.hero { display: grid; gap: 12px; padding: 28px; }
.hero h1 { font-size: 24px; }
.hero .btn { justify-self: start; height: 40px; padding: 0 24px; margin-top: 8px; }

/* Tabs 風の選択ボタン */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--muted); }
.seg button {
  border: 1px solid transparent; background: none; height: 30px; padding: 0 12px;
  border-radius: calc(var(--radius) - 3px); font-size: 14px; font-weight: 500; color: var(--muted-foreground);
}
.seg button:hover { color: var(--foreground); }
.seg button.on { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }
:root[data-theme="dark"] .seg button.on { background: var(--input); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: var(--input); } }

.settings { display: flex; flex-wrap: wrap; gap: 16px 28px; }
.settings label { display: grid; gap: 8px; font-size: 14px; font-weight: 500; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile {
  text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 4px; align-content: start; position: relative;
  box-shadow: var(--shadow-xs); transition: background-color .15s;
}
.tile:hover { background: var(--accent); }
.tile .name { font-weight: 600; font-size: 15px; }
.tile .ex { font-size: 13px; color: var(--muted-foreground); }
.tile .meta { font-size: 12px; color: var(--muted-foreground); margin-top: 8px; }
.tile kbd { position: absolute; top: 14px; right: 14px; }
.tile.wide { border-style: dashed; box-shadow: none; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; line-height: 1;
  padding: 4px 8px; border-radius: calc(var(--radius) - 4px); border: 1px solid var(--border);
  color: var(--foreground); white-space: nowrap;
}
.badge.master { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.badge.learning { background: var(--muted); border-color: transparent; }
.badge.weak { background: color-mix(in srgb, var(--destructive) 10%, transparent); border-color: transparent; color: var(--destructive); }

/* トレーニング */
.train { min-height: calc(100dvh - 92px); display: grid; grid-template-rows: auto 1fr; }
.train-bar { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted-foreground); }
.progress { flex: 1; height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.train-body { display: grid; align-content: center; justify-items: center; gap: 20px; padding: 24px 0 48px; text-align: center; }
.q-cat { font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
.q-text { font-size: clamp(34px, 9vw, 76px); font-weight: 600; line-height: 1.15; letter-spacing: -.03em; overflow-wrap: anywhere; }
.q-text.long { font-size: clamp(24px, 5.4vw, 44px); letter-spacing: -.02em; }
.q-hint { color: var(--muted-foreground); font-size: 14px; min-height: 1.6em; }
.answer { display: grid; gap: 12px; justify-items: center; width: 100%; }
.answer-line { display: flex; align-items: stretch; justify-content: center; gap: 8px; flex-wrap: wrap; width: 100%; }
.answer input {
  width: min(100%, 300px); height: 56px; font-family: inherit; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center;
  padding: 0 14px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--input); background: var(--background);
  color: var(--foreground); outline: none; box-shadow: var(--shadow-xs); transition: box-shadow .15s, border-color .15s;
}
.answer input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
.answer input.shake { animation: shake .25s; border-color: var(--destructive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.unit-fixed { display: flex; align-items: center; font-size: 20px; font-weight: 600; padding: 0 4px; }
.answer .seg { align-self: center; }
.answer .btn { height: 40px; padding: 0 24px; }
.preview { min-height: 1.6em; font-size: 14px; color: var(--muted-foreground); }

/* 正誤表示（Alert 風） */
.feedback { width: 100%; max-width: 560px; text-align: left; display: grid; gap: 16px; }
.feedback > .btn { justify-self: start; }
.verdict {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); font-weight: 600;
}
.verdict.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.verdict.ng { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 35%, var(--border)); }
.verdict .ans { font-size: 22px; color: var(--foreground); letter-spacing: -.01em; }
.verdict .time { margin-left: auto; font-weight: 400; font-size: 13px; color: var(--muted-foreground); }
.solution { border-left: 2px solid var(--border); padding: 2px 0 2px 16px; }
.solution h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.solution ol { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 13.5px; line-height: 1.9; }
.solution .tag {
  font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: calc(var(--radius) - 4px);
  background: var(--muted); color: var(--foreground);
}

/* 結果・記録 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow-xs); display: grid; gap: 2px;
}
.kpi .l { font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
.kpi .v { font-size: 26px; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; }
.kpi .d { font-size: 12px; }
.up { color: var(--success); }
.down { color: var(--destructive); }
.table-wrap { overflow-x: auto; }
.table-wrap.card { padding: 4px 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--muted) 50%, transparent); }
th { height: 40px; font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
td a:hover { text-decoration: underline; text-underline-offset: 3px; }
td.num, th.num { text-align: right; }
.bar { display: inline-block; vertical-align: middle; width: 72px; height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); margin-right: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart .ln { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--primary); }
.chart .axis { stroke: var(--border); stroke-dasharray: 3 3; }
.chart text { fill: var(--muted-foreground); font-size: 10px; }
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.charts .card > p { font-weight: 500; }
.review { display: grid; gap: 12px; }
.review-item { display: grid; gap: 8px; }
.review-item .qa { font-weight: 600; }

/* レッスン */
.lesson h1 { font-size: 28px; }
.lesson > div:first-child { display: grid; gap: 8px; }
.lesson ol.how { margin: 0; padding-left: 1.3em; }
.lesson ol.how li + li { margin-top: 4px; }
.example { font-family: var(--mono); font-size: 13.5px; line-height: 1.9; }
.example b { font-family: inherit; font-size: 15px; font-weight: 600; }
.tech-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

@media (max-width: 520px) {
  .topbar, .app { padding-left: 16px; padding-right: 16px; }
  .app { padding-top: 20px; }
  .nav a, .icon-btn { padding: 6px 8px; }
  kbd { display: none; }
  .hero { padding: 20px; }
  .train-body { align-content: start; padding-top: 8vh; }
}
