@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+JP:wght@400;500;700&display=swap');

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

:root {
  --bg: #0a0a1a;
  --panel: rgba(20, 20, 40, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary: #6366f1;
  --primary-light: #818cf8;
  --accent: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
}

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* === Background === */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 20%, rgba(236, 72, 153, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 60%);
  will-change: auto;
}
@media (prefers-reduced-motion: no-preference) {
  .bg-gradient { animation: bgShift 20s ease-in-out infinite alternate; }
}
@keyframes bgShift {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.1) rotate(3deg); }
}

.floating-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.2;
}
@media (prefers-reduced-motion: no-preference) {
  .orb { animation: float 30s ease-in-out infinite; will-change: transform; }
}
.orb:nth-child(1) { width: 300px; height: 300px; background: #6366f1; top: -100px; left: -50px; }
.orb:nth-child(2) { width: 400px; height: 400px; background: #ec4899; top: 50%; right: -100px; animation-delay: -5s; }
.orb:nth-child(3) { width: 250px; height: 250px; background: #0ea5e9; bottom: -50px; left: 50%; animation-delay: -10s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(50px, -30px); }
  66% { transform: translate(-30px, 50px); }
}

/* === Layout === */
.header, .student-bar, .tabs, .content, .footer { position: relative; z-index: 1; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2.5rem;
  background: rgba(10, 10, 26, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--panel-border);
}
.logo { display: flex; align-items: center; gap: 1rem; }
.logo-icon { font-size: 2.5rem; }
.logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { font-size: 0.75rem; color: var(--text-dim); font-weight: 500; }

.header-actions { display: flex; align-items: center; gap: 1rem; }
.mode-badge {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.cost-meter {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-family: 'Inter', monospace;
}
.cost-meter.warn { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.25); }
.cost-meter.danger { background: rgba(239, 68, 68, 0.1); color: var(--error); border-color: rgba(239, 68, 68, 0.25); }

/* Parent view (read-only) */
body.parent-view .tabs .tab[data-tab="mentor"],
body.parent-view .tabs .tab[data-tab="essay"],
body.parent-view .tabs .tab[data-tab="diagnostic"] { display: none; }
body.parent-view .student-bar button,
body.parent-view #addStudentBtn,
body.parent-view #importStudentsBtn,
body.parent-view #exportDataBtn,
body.parent-view #openSettings,
body.parent-view #studentSelect { display: none; }
body.parent-view .student-bar label::after { content: "（保護者様専用）"; color: var(--accent); font-weight: 700; margin-left: 0.5rem; }
body.parent-view #currentStudentName { color: var(--text); font-weight: 700; padding: 0.4rem 0.8rem; background: rgba(255,255,255,0.06); border-radius: 8px; font-size: 0.9rem; }

/* Printable */
@media print {
  body { background: white !important; color: #111 !important; }
  .bg-gradient, .floating-orbs, .header, .student-bar, .tabs, .footer,
  .btn-primary, .btn-secondary, .btn-icon, .btn-icon-small,
  .kpi-cards, .charts-row, .summary-header button { display: none !important; }
  .tab-content { display: block !important; }
  .tab-content:not(#tab-parent) { display: none !important; }
  .result-box { background: white !important; color: #111 !important; border: 1px solid #ccc !important; max-height: none !important; }
  .panel-header h2 { color: #111 !important; }
  .parent-summary-box { background: white !important; border: 1px solid #ccc !important; }
}
.mode-badge.demo { background: rgba(245, 158, 11, 0.15); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.mode-badge.live { background: rgba(16, 185, 129, 0.15); color: var(--success); border-color: rgba(16, 185, 129, 0.3); }

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-1px); }

/* ラベル付きナビゲーションピル（textbook-generator header等で使用） */
.btn-nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-nav-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  border-color: rgba(129, 140, 248, 0.4);
}
.btn-nav-pill .bnp-icon { font-size: 1rem; line-height: 1; }
.btn-nav-pill .bnp-label { line-height: 1; }

/* ==========================================================================
   管理ナビゲーションバー（ラベル付きアイコン）
   ========================================================================== */
.nav-status-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-right: 0.75rem;
  border-right: 1px solid var(--panel-border);
}

.nav-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.nav-bar-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding-left: 0.2rem;
}
.nav-bar-icons {
  display: flex;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.4rem 0.5rem;
}

.btn-icon-labeled {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  min-width: 56px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon-labeled:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}
.btn-icon-labeled .icon {
  font-size: 1.25rem;
  line-height: 1;
}
.btn-icon-labeled .label {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.btn-icon-labeled:hover .label { color: var(--text); }

/* 保護者モードでは管理メニュー全体を隠す（設計思想: 顧客には見せない） */
body.parent-view .nav-bar-wrapper,
body.parent-view .nav-status-group { display: none; }

@media (max-width: 1024px) {
  .nav-bar-label { display: none; }
  .btn-icon-labeled { min-width: 48px; padding: 0.3rem; }
  .btn-icon-labeled .label { font-size: 0.6rem; }
}

.btn-icon-small {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-icon-small:hover { background: rgba(99, 102, 241, 0.25); }

/* === Student Bar === */
.student-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2.5rem;
  background: rgba(20, 20, 40, 0.4);
  border-bottom: 1px solid var(--panel-border);
}
.student-bar label { font-weight: 600; color: var(--text-dim); font-size: 0.85rem; }
.student-info { margin-left: auto; display: flex; gap: 1rem; font-size: 0.85rem; color: var(--text-dim); }
.student-info span { padding: 0.3rem 0.7rem; background: rgba(255,255,255,0.05); border-radius: 6px; }

/* === Tabs === */
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 1rem 2.5rem 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.85rem 1.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px 10px 0 0;
  transition: all 0.2s;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.tab.active {
  color: var(--primary-light);
  background: var(--panel);
  border-bottom-color: var(--primary);
}

/* === Content === */
.content {
  padding: 2rem 2.5rem;
  min-height: 60vh;
}
.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header { margin-bottom: 1.5rem; }
.panel-header h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.3rem; }
.panel-header p { color: var(--text-dim); font-size: 0.9rem; }

/* === Forms === */
select, input[type="text"], input[type="number"], input[type="password"], input[type="date"], textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
  resize: vertical;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  padding: 0.8rem 1.8rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.btn-small { padding: 0.5rem 1rem; font-size: 0.8rem; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 0.8rem 1.8rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.btn-secondary.btn-small { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

/* === Tutor === */
.tutor-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 320px);
  min-height: 500px;
}
.tutor-sidebar {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.subject-selector label { font-size: 0.8rem; color: var(--text-dim); display: block; margin-bottom: 0.4rem; }
.session-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.stat {
  background: rgba(99, 102, 241, 0.08);
  padding: 0.75rem;
  border-radius: 10px;
  text-align: center;
  border: 1px solid rgba(99, 102, 241, 0.15);
}
.stat-label { display: block; font-size: 0.7rem; color: var(--text-dim); margin-bottom: 0.2rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--primary-light); }

.chat-container {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.message { display: flex; gap: 0.75rem; align-items: flex-start; }
.message.user-msg { flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.user-msg .msg-avatar { background: rgba(236, 72, 153, 0.15); }
.msg-body {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  max-width: 75%;
  line-height: 1.6;
  font-size: 0.92rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  white-space: pre-wrap;
  word-break: break-word;
}
.user-msg .msg-body {
  background: rgba(236, 72, 153, 0.08);
  border-color: rgba(236, 72, 153, 0.2);
}
.ai-msg .msg-body { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.2); }
.msg-body.thinking { color: var(--text-dim); font-style: italic; }

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.2);
  align-items: flex-end;
}
.chat-input-area textarea { flex: 1; resize: none; }

.btn-attach {
  width: 44px;
  height: 44px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary-light);
  border-radius: 10px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-attach:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}
.btn-attach.has-file {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
  animation: pulse-attach 1.5s infinite;
}
@keyframes pulse-attach {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

.chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin: 0 1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(236, 72, 153, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  position: relative;
}
.chat-attach-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.attach-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.attach-info span:first-child {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-hint {
  font-size: 0.78rem;
  color: var(--primary-light);
}
.attach-remove {
  width: 32px;
  height: 32px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 900;
  flex-shrink: 0;
  transition: all 0.2s;
}
.attach-remove:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(1.05);
}

/* メッセージ内の画像表示 */
.message .msg-body img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid var(--panel-border);
}

/* Speaking practice */
.speaking-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}
.speaking-sidebar, .speaking-main {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
}
.speaking-controls { margin-top: 1.5rem; }
.speaking-controls .btn-primary.recording {
  background: linear-gradient(135deg, var(--error), var(--accent));
  animation: pulse-rec 1.5s infinite;
}
@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}
.speaking-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--panel-border);
}
.stat-ring {
  text-align: center;
  padding: 0.75rem 0.4rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
}
.ring-label { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 0.3rem; }
.ring-value {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.speaking-session { display: flex; flex-direction: column; gap: 1.25rem; min-height: 500px; }
.ai-prompt-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
}
.ai-prompt-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 0.5rem;
}
.ai-prompt-text { font-size: 1.05rem; line-height: 1.7; }
.transcript-area {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  min-height: 120px;
}
.transcript-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.transcript-box {
  font-size: 1rem;
  line-height: 1.8;
  min-height: 60px;
}
.transcript-placeholder { color: var(--text-muted); font-style: italic; }
.transcript-interim { color: var(--text-dim); font-style: italic; }

.feedback-area {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}
.feedback-area h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.feedback-content { line-height: 1.8; font-size: 0.92rem; }
.feedback-content h4 { margin: 1rem 0 0.3rem; color: var(--primary-light); font-size: 0.95rem; }
.feedback-content strong { color: var(--accent); }
.feedback-content .highlight-correct { background: rgba(16, 185, 129, 0.15); padding: 0 0.3rem; border-radius: 4px; }
.feedback-content .highlight-wrong { background: rgba(239, 68, 68, 0.15); padding: 0 0.3rem; border-radius: 4px; text-decoration: line-through; }

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

/* Moshi image upload */
.moshi-upload {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.08), rgba(99, 102, 241, 0.05));
  border: 1px dashed rgba(236, 72, 153, 0.3);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.moshi-header {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.badge-new {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  margin-left: 0.4rem;
  letter-spacing: 0.03em;
}
.moshi-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}
#moshiStatus {
  margin-top: 0.75rem;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
}
#moshiStatus.loading { background: rgba(99, 102, 241, 0.1); color: var(--primary-light); }
#moshiStatus.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
#moshiStatus.error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
#moshiPreview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid var(--panel-border);
}

/* Quick-fill bar */
.quick-fill-bar {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(99, 102, 241, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.qf-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 0.6rem;
}
.qf-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
}
.qf-btn {
  padding: 0.5rem 0.7rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--success);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.qf-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}
.qf-status {
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.6;
}
.qf-status.loading { background: rgba(99, 102, 241, 0.1); color: var(--primary-light); }
.qf-status.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.qf-status.error { background: rgba(239, 68, 68, 0.1); color: var(--error); }

.field-hint-small {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.weakness-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}
.weakness-chip {
  padding: 0.35rem 0.8rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary-light);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.weakness-chip:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}
.weakness-chip.selected {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
}

/* 問題生成のレイアウト選択 */
.prob-layout-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.prob-layout-opt { cursor: pointer; display: block; }
.prob-layout-opt input { display: none; }
.prob-layout-card {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  text-align: center;
  transition: all 0.2s;
}
.prob-layout-opt:hover .prob-layout-card { border-color: rgba(99, 102, 241, 0.3); }
.prob-layout-opt input:checked + .prob-layout-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.05));
  border-color: var(--primary);
}
.pl-emoji { font-size: 1.5rem; margin-bottom: 0.2rem; }
.pl-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.2rem; }
.pl-desc { font-size: 0.7rem; color: var(--text-dim); line-height: 1.5; }
.pl-desc strong { color: var(--accent); }

/* 生成された問題のブロック表示 */
.problem-block {
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-left: 4px solid var(--primary);
  border-radius: 0 10px 10px 0;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}
.problem-block-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.problem-block-num {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
}
.problem-block-body {
  font-size: 0.95rem;
  line-height: 2;
}

.answer-block-v2 {
  background: rgba(236, 72, 153, 0.05);
  border: 1px solid rgba(236, 72, 153, 0.2);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.5rem;
  margin: 0.75rem 0;
}
.answer-block-v2 .ab-label {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.answer-block-v2 .ab-content {
  font-size: 0.92rem;
  line-height: 2;
}
.answer-block-v2 .ab-content strong { color: var(--accent); }

.answers-section-header {
  margin: 2.5rem 0 1.5rem;
  padding: 1.5rem 2rem;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.12), rgba(99, 102, 241, 0.05));
  border: 2px solid rgba(236, 72, 153, 0.3);
  border-radius: 14px;
  text-align: center;
  page-break-before: always;
}
.answers-section-header h2 {
  color: var(--accent) !important;
  font-size: 1.5rem !important;
  border: none !important;
  background: none !important;
}

.reveal-problem-btn {
  margin-top: 1rem;
  padding: 0.55rem 1.1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(236, 72, 153, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.reveal-problem-btn:hover { background: rgba(99, 102, 241, 0.25); }
.reveal-hidden { display: none; }
.reveal-hidden.show { display: block; }

/* Problems layout */
.problems-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
}
.problems-form, .problems-output {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
}
.problems-form h3, .problems-output h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.problems-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
@media (max-width: 1024px) {
  .problems-layout { grid-template-columns: 1fr; }
}

/* mypage: アクションボタン強調版（新機能紹介） */
.action-btn-highlight {
  border-color: rgba(236, 72, 153, 0.45) !important;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.10), rgba(236, 72, 153, 0.08)) !important;
}
.action-btn-highlight:hover {
  border-color: rgba(236, 72, 153, 0.75) !important;
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.25) !important;
}
.action-badge-new {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.3rem;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* 生徒向けテキスト教材生成CTA（問題作成タブ内） */
.student-textbook-cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.25rem 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.12), rgba(236, 72, 153, 0.10));
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.student-textbook-cta:hover {
  transform: translateY(-2px);
  border-color: rgba(236, 72, 153, 0.55);
  box-shadow: 0 8px 24px rgba(129, 140, 248, 0.20);
}
.student-textbook-cta .stc-icon {
  font-size: 2rem;
  line-height: 1;
}
.student-textbook-cta .stc-body { flex: 1; }
.student-textbook-cta .stc-title {
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #818cf8, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.25rem;
}
.student-textbook-cta .stc-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.student-textbook-cta .stc-arrow {
  font-size: 1.5rem;
  color: #ec4899;
  font-weight: 700;
}

/* 模試登録後のメール提案モーダル */
.mep-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.mep-card {
  background: var(--panel-bg);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 16px;
  max-width: 540px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.mep-success {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 10px;
}
.mep-success-icon { font-size: 1.8rem; }
.mep-success-text strong { display: block; font-size: 0.95rem; }
.mep-success-sub { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.2rem; }
.mep-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 1.25rem 0;
}
.mep-title {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mep-desc { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 1rem; }
.mep-preview {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.9rem;
  margin-bottom: 1rem;
}
.mep-preview-row {
  font-size: 0.88rem;
  padding: 0.25rem 0;
  word-break: break-word;
}
.mep-label {
  color: var(--text-dim);
  margin-right: 0.4rem;
  display: inline-block;
  min-width: 4em;
}
.mep-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
.mep-actions button { padding: 0.75rem 1rem; }
.mep-btn-send { font-weight: 700; }
.mep-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  text-align: center;
}

/* メールタブ */
.email-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.25rem;
}
@media (max-width: 1024px) { .email-layout { grid-template-columns: 1fr; } }
.email-students-panel, .email-compose-panel, .email-log-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
}
.email-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.email-panel-header h3 { margin: 0; font-size: 1.05rem; }

.email-students-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}
.email-student-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  gap: 0.5rem;
}
.esi-info { flex: 1; min-width: 0; }
.esi-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.esi-grade {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 400;
}
.esi-email { font-size: 0.82rem; margin-top: 0.2rem; }
.esi-email-addr { color: var(--text-dim); word-break: break-all; }
.esi-email-missing { color: #fca5a5; }

.esi-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}
.esi-actions .btn-small {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  min-width: auto;
}
.esi-actions .btn-small:hover { background: rgba(255, 255, 255, 0.1); }
.email-select-btn {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
  color: #10b981 !important;
}

.email-compose-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.email-compose-actions button { flex: 1; min-width: 120px; }

.email-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 40vh;
  overflow-y: auto;
}
.email-log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.eli-subject { font-weight: 600; font-size: 0.88rem; }
.eli-meta { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.15rem; }
.eli-date { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }

/* プランインジケーター */
.plan-indicator-bar {
  display: inline-flex;
  align-items: center;
  margin-left: 0.75rem;
  padding: 0.25rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}

/* 家族ダッシュボード */
.family-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 600px;
  margin: 2rem auto;
}
.family-empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.family-empty-state h3 { font-size: 1.4rem; margin: 1rem 0; }
.family-pricing-card {
  background: rgba(236, 72, 153, 0.08);
  border: 1px solid rgba(236, 72, 153, 0.3);
  border-radius: 14px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.family-price-old {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 1rem;
}
.family-price-new {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0.5rem 0;
}
.family-price-save {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  display: inline-block;
  font-weight: 700;
}

.family-overview-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
  .family-overview-stats { grid-template-columns: repeat(2, 1fr); }
}
.fos-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
}
.fos-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.fos-value {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.family-students-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}
@media (max-width: 900px) {
  .family-students-grid { grid-template-columns: 1fr; }
}
.family-student-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
  transition: all 0.2s;
}
.family-student-card.active {
  border-color: rgba(236, 72, 153, 0.5);
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.08), rgba(139, 92, 246, 0.06));
}
.fsc-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
}
.fsc-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  color: #fff;
}
.fsc-name { font-weight: 700; font-size: 1.1rem; }
.fsc-grade { color: var(--text-dim); font-size: 0.85rem; }
.fsc-active-badge {
  position: absolute;
  right: 0;
  top: 0;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
}
.fsc-stats {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.fsc-stat-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}
.fsc-stat-label { color: var(--text-dim); }
.fsc-stat-value { font-weight: 600; }

.fsc-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.fsc-actions .btn-small {
  flex: 1;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  min-width: 100px;
}
.fsc-actions .btn-small:hover { background: rgba(255, 255, 255, 0.1); }
.fsc-actions .btn-small.btn-disabled { opacity: 0.5; cursor: default; }
.fsc-actions .btn-small.btn-delete {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.family-add-slot, .family-full-slot {
  background: rgba(255, 255, 255, 0.02);
  border: 2px dashed var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.family-add-slot:hover {
  border-color: rgba(236, 72, 153, 0.5);
  background: rgba(236, 72, 153, 0.05);
  color: var(--text);
}
.fas-icon { font-size: 2.5rem; }
.fas-text { text-align: center; }
.fas-text small { color: var(--text-muted); font-size: 0.8rem; }

.family-actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* 模試履歴ストック */
.moshi-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 1.25rem;
}
@media (max-width: 1024px) {
  .moshi-layout { grid-template-columns: 1fr; }
}
.moshi-form-panel, .moshi-list-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
}
.moshi-form-panel h3, .moshi-list-panel h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.moshi-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.moshi-count-badge {
  display: inline-block;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  margin-left: 0.5rem;
  font-weight: 700;
}
.moshi-filters select {
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.85rem;
}
.moshi-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 70vh;
  overflow-y: auto;
}
.moshi-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  padding: 1rem;
  transition: transform 0.15s, border-color 0.15s;
}
.moshi-card:hover {
  border-color: rgba(16, 185, 129, 0.45);
  transform: translateY(-1px);
}
.moshi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.moshi-card-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
.moshi-card-date {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.moshi-card-body > div {
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
}
.moshi-deviation strong {
  background: linear-gradient(135deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.1em;
}
.moshi-meta {
  color: var(--text-dim);
}
.moshi-weakness {
  color: #fca5a5;
  font-size: 0.85rem;
}
.moshi-scores {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.moshi-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.moshi-card-actions .btn-small {
  flex: 1;
  min-width: 90px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.moshi-card-actions .btn-small:hover { background: rgba(255, 255, 255, 0.1); }
.moshi-card-actions .btn-gen-problems {
  background: rgba(129, 140, 248, 0.12);
  border-color: rgba(129, 140, 248, 0.35);
  color: #a5b4fc;
}
.moshi-card-actions .btn-delete-moshi {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* 詳細モーダル */
.moshi-detail {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.moshi-detail-inner {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}
.moshi-detail-close {
  position: sticky;
  top: 0;
  float: right;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.moshi-detail-meta {
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.moshi-scores-detail, .moshi-ai-analysis {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* 問題生成ボタン行: 生成 + リセット */
.gen-btn-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.gen-btn-row .btn-primary { flex: 1; min-width: 200px; }
.btn-reset {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-reset:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-reset:active { transform: translateY(1px); }

/* === Two-column layouts === */
/* 英作文添削の画像添付 */
.label-with-attach {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.label-with-attach label {
  margin-bottom: 0;
}
.btn-attach-small {
  padding: 0.3rem 0.7rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--primary-light);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-attach-small:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}
.btn-attach-small.has-file {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
}

.essay-attach-preview {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
}
.essay-attach-preview img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.eap-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.eap-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eap-hint {
  font-size: 0.75rem;
  color: var(--primary-light);
}
.eap-remove {
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  flex-shrink: 0;
}
.eap-remove:hover { background: rgba(239, 68, 68, 0.25); }

.diagnostic-layout, .curriculum-layout, .essay-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.diagnostic-input, .diagnostic-output,
.curriculum-form, .curriculum-output,
.essay-input, .essay-output,
.mentor-schedule, .mentor-prep {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
}
.diagnostic-input h3, .diagnostic-output h3,
.curriculum-form h3, .curriculum-output h3,
.essay-input h3, .essay-output h3,
.mentor-schedule h3, .mentor-prep h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.result-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 1.25rem;
  min-height: 200px;
  max-height: 600px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-box .placeholder { color: var(--text-muted); font-style: italic; }
.result-box h1, .result-box h2, .result-box h3, .result-box h4 {
  margin: 0.8rem 0 0.4rem;
  color: var(--primary-light);
}
.result-box h1 { font-size: 1.15rem; }
.result-box h2 { font-size: 1.05rem; }
.result-box h3 { font-size: 0.95rem; }
.result-box strong { color: var(--accent); font-weight: 700; }
.result-box ul, .result-box ol { margin: 0.4rem 0 0.4rem 1.5rem; }
.result-box li { margin-bottom: 0.3rem; }
.result-box code {
  background: rgba(0,0,0,0.4);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: #fbbf24;
}

/* === Parent Report === */
.parent-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.kpi-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
}
.kpi-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}
.kpi-trend { font-size: 0.75rem; color: var(--text-muted); }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--error); }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.chart-container {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
  height: 320px;
}
.chart-container h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; }

.parent-summary-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.5rem;
}
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.summary-header h3 { font-size: 1rem; font-weight: 700; }

/* === Mentor === */
.mentor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.schedule-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.schedule-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.schedule-time {
  font-weight: 700;
  color: var(--primary-light);
  font-size: 0.9rem;
}
.schedule-student { font-size: 0.9rem; }
.schedule-meta { font-size: 0.75rem; color: var(--text-dim); }

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.modal.show { display: flex; }
.modal-content {
  background: linear-gradient(135deg, rgba(30, 30, 60, 0.95), rgba(20, 20, 40, 0.95));
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 2.5rem;
  max-width: 480px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.modal-content h2 { font-size: 1.4rem; font-weight: 700; }
.modal-desc { color: var(--text-dim); font-size: 0.9rem; line-height: 1.6; }
.modal-hint { font-size: 0.75rem; color: var(--text-muted); }
.modal-hint a { color: var(--primary-light); text-decoration: none; }
.modal-hint a:hover { text-decoration: underline; }

/* === Footer === */
.footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  margin-top: 3rem;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .tutor-layout, .diagnostic-layout, .curriculum-layout, .essay-layout, .mentor-layout {
    grid-template-columns: 1fr;
  }
  .kpi-cards { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .header, .student-bar, .content, .tabs { padding-left: 1rem; padding-right: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .kpi-cards { grid-template-columns: 1fr; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }
