/* ── Q-Road Workspace Dashboard (C×D Hybrid) ──
   共通: ウィジェット行 + アクションカード + モードタブ + スプリット + 固定バー */

body.ws-dash-v1 .ws-dash {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px 72px;
  box-sizing: border-box;
}

/* ── ウィジェット行（C） ── */
.ws-widget-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ws-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--color-surface-raised, #1e2840);
  min-height: 5.5rem;
  box-sizing: border-box;
}

.ws-widget-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary, #94a3b8);
  letter-spacing: 0.02em;
}

.ws-widget-value {
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary, #f1f5f9);
}

.ws-widget-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
}

.ws-widget--quota .ws-widget-value { color: var(--color-brand, #38bdf8); }
.ws-widget--exam .ws-widget-value { color: var(--color-gold, #fbbf24); }
.ws-widget--streak .ws-widget-value { color: #fb923c; }
.ws-widget--rate .ws-widget-value { color: #4ade80; }

.ws-widget--past .ws-widget-value { color: #fca5a5; font-size: 1.35rem; }

.ws-widget-exam-unit {
  font-size: 0.875rem;
  font-weight: 800;
  margin-left: 2px;
  color: var(--text-secondary, #94a3b8);
}

.ws-widget--exam .ws-widget-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

/* ── 試験補足行（コンパクト・モック準拠） ── */
.ws-exam-strip:not([hidden]) {
  display: block;
}

.ws-exam-strip-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.35);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
}

.ws-exam-strip-bar--guide {
  align-items: flex-start;
}

.ws-exam-strip-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ws-exam-strip-meta-ico {
  display: inline-flex;
  opacity: 0.85;
}

.ws-exam-strip-meta strong {
  color: var(--text-primary, #f1f5f9);
  font-weight: 800;
}

.ws-exam-strip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-brand, #38bdf8);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.ws-exam-strip-link:hover { text-decoration: underline; }

.ws-exam-strip-link-ico {
  display: inline-flex;
}

.ws-exam-strip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ws-exam-strip-btn {
  font-size: 0.8125rem;
}

.ws-exam-strip-guide {
  margin: 0;
  flex: 1 1 12rem;
  line-height: 1.45;
}

.ws-exam-strip-guide-copy {
  flex: 1 1 12rem;
  min-width: 0;
}

.ws-exam-strip-guide-title {
  font-weight: 800;
  color: var(--text-primary, #f1f5f9);
}

.ws-exam-strip-note,
.ws-exam-strip-disclaimer {
  margin: 4px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted, #64748b);
}

.ws-exam-strip-note {
  color: #fca5a5;
}

/* ── アクションカード（C） ── */
.ws-action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(56, 189, 248, 0.04) 100%);
}

.ws-action-card-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.ws-action-card-kicker {
  margin: 0 0 2px;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-brand, #38bdf8);
}

.ws-action-card-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.35;
}

.ws-action-card-sub {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.45;
}

.ws-action-card-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: var(--color-brand, #38bdf8);
  color: #0f172a;
  font-size: 0.9375rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.ws-action-card-btn:hover { filter: brightness(1.08); }
.ws-action-card-btn:focus-visible {
  outline: 2px solid var(--color-brand, #38bdf8);
  outline-offset: 2px;
}

.ws-action-card-btn--muted {
  background: rgba(148, 163, 184, 0.25);
  color: var(--text-primary, #f1f5f9);
}

/* ── モードタブ（D） ── */
.ws-mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.ws-mode-tab {
  flex: 1 1 0;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ws-mode-tab:hover { color: var(--text-primary, #f1f5f9); }

.ws-mode-tab.active,
.ws-mode-tab[aria-selected="true"] {
  background: rgba(56, 189, 248, 0.18);
  color: var(--color-brand, #38bdf8);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.ws-mode-tab:focus-visible {
  outline: 2px solid var(--color-brand, #38bdf8);
  outline-offset: 1px;
}

/* settings / glossary 既存ボタンを ws-mode-tabs 内に載せる */
.ws-mode-tabs .settings-subnav-btn,
.ws-mode-tabs .glossary-mode-btn {
  flex: 1 1 0;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
}

.ws-mode-tabs .settings-subnav-btn.active,
.ws-mode-tabs .glossary-mode-btn.is-active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--color-brand, #38bdf8);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

/* ── スプリット（C×D） ── */
.ws-split {
  display: grid;
  grid-template-columns: minmax(11rem, 32%) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.ws-split-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: var(--color-surface-raised, #1e2840);
}

.ws-split-side-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-primary, #f1f5f9);
}

.ws-split-side-sub {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
}

.ws-chapter-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-chapter-bar-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  gap: 6px;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary, #94a3b8);
}

.ws-chapter-bar-row--current { color: var(--color-brand, #38bdf8); }
.ws-chapter-bar-row--done { color: #4ade80; }

.ws-chapter-bar-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.ws-chapter-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-brand, #38bdf8);
}

.ws-chapter-bar-row--done .ws-chapter-bar-fill { background: #4ade80; }

.ws-split-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* ── リスト行（D） ── */
.ws-list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: var(--color-surface, #1a2438);
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

button.ws-list-row {
  appearance: none;
  -webkit-appearance: none;
}

.ws-list-row:hover {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.06);
}

.ws-list-row--current {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.1);
}

.ws-list-row-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--color-brand, #38bdf8);
  white-space: nowrap;
}

.ws-list-row-body { min-width: 0; }

.ws-list-row-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.35;
}

.ws-list-row-meta {
  margin: 2px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
}

.ws-list-row-track {
  margin-top: 6px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.ws-list-row-fill {
  display: block;
  height: 100%;
  background: var(--color-brand, #38bdf8);
  border-radius: inherit;
}

.ws-list-row-action {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: var(--color-brand, #38bdf8);
  color: #0f172a;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.ws-list-row-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.18);
  color: var(--color-brand, #38bdf8);
  margin-left: 6px;
  vertical-align: middle;
}

.ws-pane { display: none; flex-direction: column; gap: 8px; }
.ws-pane.active { display: flex; }

.ws-empty {
  margin: 0;
  padding: 20px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
}

/* ── 固定バー（D） ── */
.ws-sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  box-sizing: border-box;
}

.ws-sticky-bar-copy {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.4;
  min-width: 0;
}

.ws-sticky-bar-copy strong {
  color: var(--text-primary, #f1f5f9);
  font-weight: 800;
}

.ws-sticky-bar-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--color-brand, #38bdf8);
  color: #0f172a;
  font-size: 0.8125rem;
  font-weight: 800;
  cursor: pointer;
}

/* ── ホーム: ヘッダー試験パネルを本体ウィジェットへ移す ── */
body.ws-dash-v1[data-workspace-tab="tab-home"] #home-signal-bar {
  display: none;
}

body.ws-dash-v1 .ws-dash-legacy {
  display: none !important;
}

body.ws-dash-v1 .ws-dash--home {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* ── 成績タブ ── */
body.ws-dash-v1 #stats-dashboard {
  padding: 16px 20px;
  gap: 14px;
  display: flex;
  flex-direction: column;
}

body.ws-dash-v1 .stats-ws-pane { display: none; }
body.ws-dash-v1 .stats-ws-pane.active { display: block; }

body.ws-dash-v1 .stats-dash-head {
  margin-bottom: 0;
}

/* ── 用語タブ ── */
body.ws-dash-v1 .glossary-workspace-shell {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.ws-dash-v1 .glossary-page-header { margin-bottom: 0; }

body.ws-dash-v1 .glossary-toolbar {
  flex-wrap: wrap;
  gap: 10px;
}

body.ws-dash-v1 .glossary-mode-group {
  display: contents;
}

/* ── 設定タブ ── */
body.ws-dash-v1 #settings-dashboard {
  padding: 16px 20px;
  gap: 14px;
  display: flex;
  flex-direction: column;
}

body.ws-dash-v1 #settings-subnav.ws-mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.18);
  margin-bottom: 0;
}

/* ── モバイル ── */
@media (max-width: 767px) {
  body.ws-dash-v1 .ws-dash {
    padding: 12px 14px 72px;
    gap: 12px;
  }

  .ws-widget-row {
    grid-template-columns: 1fr;
  }

  .ws-widget {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    min-height: 0;
    padding: 12px 14px;
  }

  .ws-widget-value { font-size: 1.375rem; }

  .ws-action-card {
    flex-direction: column;
    align-items: stretch;
  }

  .ws-action-card-btn {
    width: 100%;
    justify-content: center;
  }

  .ws-split {
    grid-template-columns: 1fr;
  }

  .ws-mode-tab,
  .ws-mode-tabs .settings-subnav-btn {
    font-size: 0.75rem;
    padding: 8px 6px;
  }

  .ws-sticky-bar {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (min-width: 768px) {
  body.ws-dash-v1 .ws-widget-row--stats,
  body.ws-dash-v1 .ws-widget-row--glossary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
