/* ============================================================
   Typing Trainer — Modern SaaS light tokens
   Notion / Linear (light) 寄り: 白背景 + ニュートラルグレー階調
   絵文字なし。
   英語: 技術用語/単位/固有名詞のみ（WPM, ACC, JSON, ms, JIS-106）
   日本語: UI ラベル/メニュー/ボタン
   ============================================================ */

:root {
  /* Background layers */
  --bg:        #f4f5f7;      /* page — やや暗めのオフホワイト */
  --bg-2:      #eceef1;      /* sidebar / subtle panel / table head */
  --surface:   #ffffff;      /* card */
  --surface-2: #f0f1f4;      /* hovered / nested */
  --surface-3: #e5e7eb;      /* input bg pressed */

  /* Borders */
  --border:        #d9dce1;
  --border-strong: #c4c9d1;

  /* Text */
  --fg:         #111318;
  --fg-soft:    #3b4048;
  --fg-mute:    #5f666f;
  --fg-faint:   #8c939d;

  /* Accent — single brand color */
  --accent:        #3b6df0;
  --accent-hover:  #4f7ef5;
  --accent-press:  #2a5ee0;
  --accent-on:     #ffffff;
  --accent-soft:   #eef3ff;
  --accent-ring:   rgba(59, 109, 240, 0.25);

  /* States */
  --success: #16a06a;
  --warning: #c47a06;
  --danger:  #d6453a;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 10px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(15, 20, 30, 0.04);
  --shadow:    0 4px 14px rgba(15, 20, 30, 0.06);
  --shadow-lg: 0 8px 28px rgba(15, 20, 30, 0.10);

  /* Type */
  --font-sans: "Inter", "IBM Plex Sans JP", -apple-system, BlinkMacSystemFont,
    "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

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

body { min-height: 100vh; }

input, textarea, button, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--fg); }
.hidden { display: none !important; }

/* ============================================================
   App shell
   ============================================================ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ============================================================
   Header
   ============================================================ */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.brand__mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--fg);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px; letter-spacing: -0.04em;
}
.brand__version { font-family: var(--font-mono); font-size: 11px; color: var(--fg-mute); font-weight: 400; }

.app-nav { display: flex; gap: 2px; margin-left: 24px; }
.app-nav a {
  display: inline-flex; align-items: center;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--fg-soft);
  font-size: 13px; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.app-nav a:hover { background: var(--surface-2); color: var(--fg); }
.app-nav a.is-active { background: var(--surface-2); color: var(--fg); }

.app-header__spacer { flex: 1; }

/* ============================================================
   Page head
   ============================================================ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 32px; }
.page-head__eyebrow { font-size: 12px; color: var(--fg-mute); font-weight: 500; margin-bottom: 6px; letter-spacing: 0.02em; }
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
.page-head__sub { color: var(--fg-soft); font-size: 14px; margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Section
   ============================================================ */
.section { margin-bottom: 36px; }
.section__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 12px; }
.section__title { font-size: 13px; font-weight: 600; color: var(--fg); letter-spacing: 0.01em; margin: 0; text-transform: none; }
.section__count { font-size: 12px; color: var(--fg-mute); font-weight: 500; }
.section__action { font-size: 12px; color: var(--fg-soft); }
.section__action:hover { color: var(--accent); }

/* ============================================================
   Cards & set cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.card__title { font-size: 14px; font-weight: 600; color: var(--fg); margin: 0; }
.card__sub { font-size: 12px; color: var(--fg-mute); }

/* Set grid */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.set-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  position: relative;
  min-height: 116px;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}
.set-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.set-card:hover .set-card__enter { color: var(--accent); }

.set-card__name { font-size: 14px; font-weight: 600; color: var(--fg); line-height: 1.3; display: flex; align-items: center; gap: 6px; min-width: 0; }
.set-card__name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-card__badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  background: var(--accent);
  color: var(--accent-on);
  padding: 1px 6px;
  border-radius: 8px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.set-card__meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--fg-mute); }
.adv-progress-bar {
  flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 60px;
}
.adv-progress-bar__fill {
  height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s;
}
.set-card__bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.set-card__count { font-family: var(--font-mono); font-size: 11px; color: var(--fg-mute); font-variant-numeric: tabular-nums; }
.set-card__enter {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-faint);
  font-weight: 500;
  transition: color 0.14s;
}

.set-card--new {
  border-style: dashed;
  background: transparent;
  align-items: center;
  justify-content: center;
  color: var(--fg-mute);
  font-size: 13px;
  text-align: center;
  min-height: 116px;
}
.set-card--new:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: none; box-shadow: none; }
.set-card--new__plus { font-size: 18px; font-weight: 300; line-height: 1; margin-bottom: 4px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }

.btn--primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-soft); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg); }

.btn--danger { color: var(--danger); border-color: var(--border); background: var(--surface); }
.btn--danger:hover { background: #fdeceb; border-color: #f3c4bf; }

.btn--sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn--lg { height: 38px; padding: 0 16px; font-size: 14px; }
.btn--icon { width: 32px; padding: 0; }

/* ============================================================
   Form controls
   ============================================================ */
.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; padding: 8px 10px; font-family: var(--font-mono); line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder, .textarea::placeholder { color: var(--fg-faint); }

.label { display: block; font-size: 12px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.help { font-size: 12px; color: var(--fg-mute); margin-top: 4px; }
.field { margin-bottom: 16px; }

/* Toggle */
.switch {
  position: relative;
  width: 32px; height: 18px;
  border-radius: 9px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  border: 0;
  padding: 0;
}
.switch.is-on { background: var(--accent); }
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 7px;
  background: #fff;
  transition: left 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.is-on::after { left: 16px; }

/* Radio cards */
.radio-row { display: flex; gap: 8px; }
.radio-card {
  flex: 1;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--fg);
  transition: border-color 0.12s, background 0.12s;
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio-card__title { font-size: 13px; font-weight: 600; }
.radio-card__desc { font-size: 12px; color: var(--fg-mute); margin-top: 2px; }

/* Segmented */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 2px;
}
.segmented button {
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: var(--fg-soft);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-xs);
}
.segmented button:hover { color: var(--fg); }
.segmented button.is-active {
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-sm);
}

/* Setting row (label : control) */
.setting-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.setting-row:last-child { border-bottom: 0; }
.setting-row__label { font-size: 13px; font-weight: 500; color: var(--fg); }
.setting-row__desc { font-size: 12px; color: var(--fg-mute); margin-top: 4px; line-height: 1.5; }
.setting-row__control { display: flex; flex-direction: column; gap: 4px; }

/* ============================================================
   Sidebar (config / editor pages)
   ============================================================ */
.split {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  align-items: start;
}
.split-narrow {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: stretch;
  min-height: 600px;
}

.sidenav {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidenav__group { font-size: 11px; font-weight: 600; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px 4px; }
.sidenav button, .sidenav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--fg-soft);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  width: 100%;
}
.sidenav button:hover, .sidenav a:hover { background: var(--surface-2); color: var(--fg); }
.sidenav button.is-active, .sidenav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   Editor list
   ============================================================ */
.editor-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-list__head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.editor-list__items {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.editor-list__item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
}
.editor-list__item:hover { background: var(--surface-2); }
.editor-list__item.is-selected { background: var(--accent-soft); }
.editor-list__item-name { font-size: 13px; font-weight: 600; }
.editor-list__item-meta { font-size: 11px; color: var(--fg-mute); margin-top: 2px; display: flex; gap: 8px; }

.editor-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   Badges, tags, misc
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-soft);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--success { background: #e7f5ee; color: var(--success); border-color: transparent; }
.badge--ghost { background: transparent; color: var(--fg-mute); border-color: var(--border); }

.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--fg-soft);
}

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-mute);
  font-size: 13px;
}

/* ============================================================
   KPI tiles
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi__value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.kpi__unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-mute);
}
.kpi__delta {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-mute);
}
.kpi__delta.is-up { color: var(--success); }
.kpi__delta.is-down { color: var(--danger); }

/* ============================================================
   Chart
   ============================================================ */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.chart-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.chart-card__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.chart-card__legend {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-soft);
}
.chart-card__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  width: 10px; height: 10px; border-radius: 2px;
}
.legend-swatch--line {
  width: 16px; height: 2px; border-radius: 1px;
}
.chart-svg {
  width: 100%;
  height: 280px;
  display: block;
}
.chart-svg .axis-line { stroke: var(--border); stroke-width: 1; }
.chart-svg .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-svg .axis-label { fill: var(--fg-mute); font-size: 10px; font-family: var(--font-mono); }
.chart-svg .bar { fill: var(--surface-3); }
.chart-svg .line-wpm { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart-svg .line-acc { stroke: var(--success); stroke-width: 2; fill: none; stroke-dasharray: 0; }
.chart-svg .dot-wpm { fill: var(--accent); }
.chart-svg .dot-acc { fill: var(--success); }

/* ============================================================
   Prose (静的ページ用)
   ============================================================ */
.prose { max-width: 720px; line-height: 1.75; color: var(--fg); }
.prose p { margin: 0 0 14px; }
.prose h2 {
  font-size: 16px; font-weight: 600;
  margin: 32px 0 12px; padding-top: 16px;
  border-top: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.prose h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 24px; }
.prose ul { margin: 0 0 14px; padding-left: 20px; }
.prose li { margin: 4px 0; }
.prose a:not(.btn) { color: var(--accent); }
.prose a:not(.btn):hover { text-decoration: underline; }
.prose__meta { font-size: 12px; color: var(--fg-mute); margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ============================================================
   Site footer (法的リンク導線)
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg-mute);
  background: var(--bg-2);
}
.site-footer__links { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer__links a { color: var(--fg-soft); }
.site-footer__links a:hover { color: var(--accent); }
.site-footer__copy { font-family: var(--font-mono); }
