/* ==========================================================================
   English Grammar Studio - Human-Centered EdTech Design
   ========================================================================== */

:root {
  /* 基調色: 落ち着いたニュートラルグレー & スレート */
  --bg-app: #f4f5f8;
  --bg-card: #ffffff;
  --bg-card-sub: #f8fafc;
  --bg-card-hover: #f1f5f9;

  /* 境界線 */
  --border-light: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-focus: #3b82f6;

  /* テキスト色（視認性重視） */
  --text-main: #1e293b;        /* 主テキスト: 深みのあるチャコール */
  --text-sub: #475569;         /* 補助テキスト */
  --text-muted: #64748b;       /* 注釈・ラベル */
  --text-disabled: #94a3b8;

  /* ブランド・アクセントカラー（控えめで実用的） */
  --primary: #2563eb;          /* ロイヤルブルー */
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --success: #059669;          /* エメラルドグリーン */
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;

  --danger: #dc2626;           /* クリムゾンレッド */
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --warning: #d97706;
  --warning-light: #fffbeb;

  /* シャドウ（控えめで自然な影） */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* タイポグラフィ */
  --font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   1. PIN Auth Screen
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 2.2rem;
  text-align: center;
}

.auth-header {
  margin-bottom: 1.8rem;
}

.auth-app-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.auth-app-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.section-guide-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 1.2rem;
}

.user-avatar-list {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-bottom: 0.5rem;
}

.user-select-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  transition: transform 0.15s ease;
}

.user-select-item:hover {
  transform: translateY(-2px);
}

.avatar-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.user-select-item:hover .avatar-circle {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.user-select-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-select-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* PIN Input Section */
.pin-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  margin-bottom: 1.2rem;
}

.avatar-circle.large {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  background: var(--primary);
  color: #ffffff;
  margin-bottom: 0;
}

.pin-user-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.pin-user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 0.2rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 0.2rem;
}

.pin-box-wrapper input {
  width: 180px;
  background: var(--bg-card-sub);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  font-size: 1.3rem;
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.3rem;
  color: var(--text-main);
  outline: none;
  margin-bottom: 1.2rem;
}

.pin-box-wrapper input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 250px;
  margin: 0 auto;
}

.numpad-btn {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 600;
  font-family: var(--font-family);
  padding: 0.75rem 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s ease;
}

.numpad-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
}

.numpad-btn:active {
  background: #e2e8f0;
}

.numpad-btn.func-clear {
  font-size: 0.82rem;
  color: var(--text-sub);
}

.numpad-btn.func-submit {
  font-size: 0.82rem;
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.numpad-btn.func-submit:hover {
  background: var(--primary-hover);
}

.auth-error-text {
  margin-top: 0.8rem;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

.auth-hint {
  margin-top: 1.2rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* ==========================================================================
   2. App Header & Navbar
   ========================================================================== */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text-group {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.logo-badge {
  font-size: 0.7rem;
  background: var(--bg-card-sub);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

/* Segment Tab Control */
.nav-segment-control {
  display: flex;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  gap: 0.2rem;
}

.segment-tab {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.segment-tab:hover {
  color: var(--text-main);
}

.segment-tab.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.nav-stock-badge {
  font-size: 0.68rem;
  background: #e2e8f0;
  color: var(--text-sub);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-full);
}

.segment-tab.active .nav-stock-badge {
  background: var(--primary-light);
  color: var(--primary);
}

.navbar-right {
  display: flex;
  align-items: center;
}

.user-status-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  padding: 0.3rem 0.6rem 0.3rem 0.4rem;
  border-radius: var(--radius-full);
}

.avatar-circle.small {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  background: var(--primary);
  color: #fff;
  margin-bottom: 0;
}

.user-status-text {
  display: flex;
  flex-direction: column;
}

.user-status-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
}

.user-status-badge {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  margin-left: 0.2rem;
}

.btn-logout:hover {
  color: var(--text-main);
}

/* ==========================================================================
   3. Main Content Layout
   ========================================================================== */
.content-area {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-panel {
  display: none;
}

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

/* ==========================================================================
   4. Quiz Practice Screen (Live Lab)
   ========================================================================== */
.quiz-layout-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.2rem;
  align-items: start;
}

@media (max-width: 860px) {
  .quiz-layout-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-card, .quiz-main-card, .dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.4rem;
}

.card-header {
  margin-bottom: 1.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-block {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 0.4rem;
}

.form-select, .form-input {
  width: 100%;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.form-select:focus, .form-input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: transparent;
  padding: 0;
}

.mode-selector.triple {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mode-pill {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
}

.mode-pill:hover {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.mode-pill.active {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.1);
  font-weight: 700;
}

.mode-pill.active::after {
  content: "●";
  font-size: 0.65rem;
  color: var(--primary);
}

.id-jump-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#btn-id-jump {
  min-width: 68px;
  white-space: nowrap;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.8rem;
}

.form-select.small, .form-input.small {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}

.topic-annotation {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* ==========================================================================
   Scramble / Word Order Exercise Styles
   ========================================================================== */
.scramble-slot-box {
  background: var(--bg-card-sub);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.2rem;
  min-height: 80px;
}

.word-slots-area {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-height: 40px;
}

.slots-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.scramble-pool-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.4rem;
}

.word-chips-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* 単語カードチップ */
.word-chip {
  background: #ffffff;
  border: 1.5px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  user-select: none;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
}

.word-chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.word-chip:active {
  transform: scale(0.96);
}

.word-chip.in-slot {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  border-style: solid;
}

.word-chip.disabled-pool {
  opacity: 0.25;
  pointer-events: none;
  border-style: dashed;
}

.scramble-action-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.mode-pill {
  background: transparent;
  border: none;
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-sub);
  padding: 0.45rem 0.2rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.mode-pill.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}

.action-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.4rem;
}

.btn-cta {
  width: 100%;
  border: none;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cta.primary {
  background: var(--primary);
  color: #ffffff;
}

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

.btn-cta.secondary {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  color: var(--text-sub);
}

.btn-cta.secondary:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.system-status-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}

/* Quiz Main Panel */
.quiz-main-card {
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.placeholder-view, .generating-view {
  margin: auto;
  text-align: center;
  padding: 3rem 1rem;
}

.placeholder-icon-box {
  width: 60px;
  height: 60px;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.placeholder-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.placeholder-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.generating-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.generating-timer {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.4rem;
}

/* Question Area */
.question-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.4rem;
}

.tag-group {
  display: flex;
  gap: 0.4rem;
}

.pill-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-sub);
}

.pill-tag.topic {
  background: var(--primary-light);
  color: var(--primary);
}

.pill-tag.id-badge {
  background: #fef3c7;
  color: #b45309;
  font-family: var(--font-mono);
  font-weight: 700;
}

.btn-copy-url {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-sub);
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-copy-url:hover {
  background: #ffffff;
  border-color: var(--border-subtle);
  color: var(--primary);
}

.id-jump-box {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-light);
}

.id-jump-row {
  display: flex;
  gap: 0.4rem;
}

.meta-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sentence-display-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.4rem;
}

.box-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.sentence-text {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.6;
}

/* 4択選択肢 */
.options-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

@media (max-width: 640px) {
  .options-container {
    grid-template-columns: 1fr;
  }
}

.option-btn {
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-card);
}

.option-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.option-index {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
}

.option-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-main);
}

.option-btn.correct {
  background: var(--success-light) !important;
  border-color: var(--success) !important;
}

.option-btn.correct .option-index {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.option-btn.correct .option-text {
  color: var(--success);
  font-weight: 600;
}

.option-btn.wrong {
  background: var(--danger-light) !important;
  border-color: var(--danger) !important;
}

.option-btn.wrong .option-index {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.option-btn.wrong .option-text {
  color: var(--danger);
  font-weight: 600;
}

/* 和文英訳 */
.write-form-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.btn-check-answer {
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-check-answer:hover {
  background: var(--primary-hover);
}

.model-answer-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-top: 1.2rem;
}

.answer-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.btn-audio {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  color: var(--primary);
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-audio:hover {
  background: #dbeafe;
}

.model-sentence-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.2rem 0 0.8rem;
  line-height: 1.5;
}

.diff-feedback-box {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.diff-feedback-box.perfect {
  background: var(--success-light);
  border-color: var(--success-border);
  color: var(--success);
  font-weight: 600;
}

.diff-feedback-box.near {
  background: var(--warning-light);
  border-color: #fde68a;
  color: #92400e;
}

.self-grading-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.grading-guide {
  font-weight: 600;
  color: var(--text-sub);
}

.btn-grade {
  border: none;
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-grade.pass {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.btn-grade.retry {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* 解説エリア */
.explanation-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1.2rem 1.4rem;
  margin-top: 1.4rem;
}

.explanation-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.explanation-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.explanation-body-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-main);
}

/* 次の問題へ進むボタン（学習フローの主導線） */
.next-action-row {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.btn-next-cta {
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 1.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  transition: all 0.15s ease;
}

.btn-next-cta:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-next-cta:active {
  transform: translateY(0);
}

.key-shortcut-hint {
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.streak-pill {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #ea580c;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  animation: pulse-orange 2s infinite;
}

@keyframes pulse-orange {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ==========================================================================
   5. Dashboard / Stats / Admin Layout
   ========================================================================== */
.panel-header-simple, .panel-header-with-action {
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.panel-header-with-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-main-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-sub-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.content-sub-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.6rem 0 0.8rem;
}

.metrics-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  text-align: left;
}

.metric-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-number {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.2;
  margin: 0.3rem 0;
  display: block;
}

.metric-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

.topics-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.topic-metric-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
}

.topic-metric-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
}

.bar-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.4rem;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.clean-table th, .clean-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.clean-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-card-sub);
}

.clean-table td {
  color: var(--text-sub);
}

/* Pool Warmer UI */
.pool-action-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-select-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-sub);
  font-weight: 600;
}

.btn-action {
  border: none;
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-action.start { background: var(--primary); color: #fff; }
.btn-action.stop { background: var(--warning); color: #fff; }
.btn-action.delete { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }

.status-summary-strip {
  display: flex;
  gap: 2rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.2rem;
}

.strip-item {
  font-size: 0.85rem;
}

.strip-label {
  color: var(--text-muted);
  margin-right: 0.4rem;
}

.strip-value.strong {
  font-weight: 700;
  color: var(--primary);
}

.split-view-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

@media (max-width: 800px) {
  .split-view-grid {
    grid-template-columns: 1fr;
  }
}

.stock-list-container {
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stock-row-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
}

.terminal-log-view {
  height: 440px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-sub);
}

/* Family Admin */
.family-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.member-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  text-align: center;
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.6rem;
}

.member-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.member-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.member-stats-row {
  display: flex;
  justify-content: space-around;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
}

.stat-col-val {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-col-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sub-section-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.pin-change-layout {
  display: flex;
  gap: 0.5rem;
  max-width: 440px;
  margin-top: 0.5rem;
}

.feedback-text {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   Weakness Analysis & AI Coach Styles
   ========================================================================== */
.study-insights-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 900px) {
  .study-insights-row {
    grid-template-columns: 1fr;
  }
}

.insight-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
}

.weak-focus-box {
  border-left: 4px solid var(--danger);
}

.ai-coach-box {
  border-left: 4px solid var(--primary);
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.insight-header-with-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.insight-icon {
  font-size: 1.1rem;
}

.insight-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.weak-topics-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.weak-topic-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  gap: 0.6rem;
}

.weak-topic-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.weak-topic-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.weak-topic-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-drill {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-drill:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-action.small-outline {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-action.small-outline:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.ai-coach-content {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  min-height: 90px;
  white-space: pre-line;
}

.ai-placeholder-text {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0;
}

.weak-empty-msg {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0;
  padding: 0.5rem 0;
}

/* 単元進捗 & ストック情報バー */
.topic-progress-strip {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.progress-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.progress-info-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.progress-info-item .p-label {
  color: var(--text-muted);
  font-weight: 500;
}

.progress-info-item .p-val {
  font-weight: 700;
  color: var(--text-main);
}

.progress-info-item .p-val.text-primary {
  color: var(--primary);
}

.progress-info-item .p-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.progress-track-thin {
  width: 100%;
  height: 5px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill-thin {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  border-radius: 999px;
  transition: width 0.4s ease;
}
