:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Inter", sans-serif;

  --color-bg: #fbfbfd;
  --color-surface: #ffffff;
  --color-subtle: #f5f5f7;
  --color-text: #111112;
  --color-text-secondary: #3a3a3c;
  --color-text-tertiary: #555558;
  --color-border: #d2d2d7;
  --color-border-strong: #b8b8bd;
  --color-accent: #0071e3;
  --color-accent-hover: #0077ed;
  --color-accent-soft: rgba(0, 113, 227, 0.08);
  --color-success: #1d7a3a;
  --color-success-soft: #e8f5ed;
  --color-warn: #a35a00;
  --color-warn-soft: #fff4e5;
  --color-error: #b3261e;
  --color-error-soft: #fce8e6;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 980px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition: all 0.2s var(--ease);
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.47;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ---------- Layout containers ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Header ---------- */
.header {
  text-align: center;
  margin-bottom: 48px;
  position: relative;
}

.header::before {
  content: '';
  position: absolute;
  inset: -40px -40px auto -40px;
  height: 220px;
  background: radial-gradient(ellipse at center top, rgba(0, 113, 227, 0.10), transparent 60%);
  z-index: -1;
  pointer-events: none;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 12px;
}

.header h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 8px;
  line-height: 1.15;
}

.header p {
  font-size: 16px;
  font-weight: 400;
  color: var(--color-text-secondary);
  letter-spacing: -0.005em;
}

.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 6px;
}
.auth-header p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* ---------- User bar ---------- */
.user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 32px;
}

.logout-form { margin: 0; }
.logout-link {
  background: none;
  border: none;
  font: inherit;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0;
  transition: var(--transition);
}
.logout-link:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 32px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 40px;
}

.tab {
  padding: 14px 0;
  cursor: pointer;
  font-size: 15px;
  font-weight: 400;
  color: var(--color-text-secondary);
  position: relative;
  transition: color 0.2s var(--ease);
}

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

.tab.active { color: var(--color-text); font-weight: 500; }
.tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
}

.content { min-height: 400px; }
.hidden, .hidden-result { display: none; }

/* ---------- Inputs ---------- */
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--color-text);
  margin-bottom: 14px;
  transition: var(--transition);
  letter-spacing: -0.005em;
}

input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}

textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
  transition: var(--transition);
}

.btn:hover { background: var(--color-accent-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.ai-btn,
.btn.adjust-btn { background: var(--color-text); }
.btn.ai-btn:hover,
.btn.adjust-btn:hover { background: #000; }

/* ---------- AI section ---------- */
.ai-section {
  position: relative;
  background:
    linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 28px;
  margin-bottom: 40px;
  overflow: hidden;
}

.ai-section::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(0, 113, 227, 0.12), transparent 65%);
  pointer-events: none;
}

.ai-section .eyebrow { color: var(--color-accent); }

.ai-section h3 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text);
  margin-bottom: 6px;
  position: relative;
}

.ai-intro {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  letter-spacing: -0.005em;
  position: relative;
}

.ai-form { position: relative; }

.ai-form input,
.ai-form textarea {
  background: var(--color-surface);
}

/* ---------- Subject cards ---------- */
.subject-card {
  position: relative;
  padding: 22px 56px 22px 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  margin-bottom: 12px;
  transition: var(--transition);
}

.subject-card::after {
  content: '›';
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  color: var(--color-text-tertiary);
  font-weight: 300;
  transition: var(--transition);
  line-height: 1;
}

.subject-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.subject-card:hover::after {
  color: var(--color-accent);
  transform: translateY(-50%) translateX(3px);
}

.subject-name {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--color-text);
  margin-bottom: 4px;
}

.subject-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.subject-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.subject-actions button {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-subtle);
  color: var(--color-text-secondary);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.subject-actions button:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.subject-meta {
  display: inline-block;
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-subtle);
  border: 1px solid var(--color-border);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.01em;
}

.subject-delete-btn {
  position: absolute;
  top: 12px;
  right: 52px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  opacity: 0;
}

.subject-card:hover .subject-delete-btn { opacity: 1; }

.subject-delete-btn:hover {
  background: var(--color-error-soft);
  border-color: #f1c4c0;
  color: var(--color-error);
}

.subject-delete-btn:focus-visible {
  opacity: 1;
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.subject-delete-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 720px) {
  .subject-delete-btn { opacity: 1; }
}

/* ---------- Plan header ---------- */
.plan-header {
  position: relative;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(0, 113, 227, 0.45), transparent 55%),
    linear-gradient(135deg, #1d1d1f 0%, #2c2c2e 100%);
  color: #fff;
  padding: 32px 32px 28px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  overflow: hidden;
}

.plan-header .eyebrow {
  color: #5ea1ff;
  margin-bottom: 10px;
}

.plan-header h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  line-height: 1.2;
}

.plan-header p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: -0.005em;
  line-height: 1.55;
}

.plan-info { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.info-item {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0;
  backdrop-filter: blur(4px);
}

/* ---------- Progress overview ---------- */
.progress-overview {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(280px, 1.4fr);
  gap: 14px;
  margin-bottom: 18px;
}

.progress-main,
.metric-card,
.today-focus {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.progress-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.progress-ring {
  --progress: 0%;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--color-surface) 58%, transparent 60%),
    conic-gradient(var(--color-accent) var(--progress), var(--color-subtle) 0);
  border: 1px solid var(--color-border);
}

.progress-ring span {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
}

.progress-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.progress-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.progress-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .progress-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.streak-card.streak-active {
  background: linear-gradient(135deg, #fff5e6, #ffe2c2);
  border-color: rgba(255, 140, 0, 0.3);
}
.streak-card.streak-active .metric-value { color: #b35a00; }
.streak-card.streak-pending {
  background: var(--color-warn-soft);
  border-color: rgba(163, 90, 0, 0.25);
}
.streak-card.streak-pending .metric-label { color: var(--color-warn); }

.metric-card {
  padding: 16px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.15;
}

.metric-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.today-focus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 22px;
  border-left: 3px solid var(--color-accent);
}

.today-focus-copy { min-width: 0; }

.today-focus-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 5px;
}

.today-focus h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 5px;
}

.today-focus p {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.today-focus-btn {
  flex: 0 0 auto;
  padding: 9px 18px;
  font-size: 13px;
}

/* ---------- Weak points ---------- */
.weak-points {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 22px;
}

.weak-points-empty {
  border-left: 3px solid var(--color-success);
}

.weak-points-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-warn);
  margin-bottom: 5px;
}

.weak-points-empty .weak-points-label { color: var(--color-success); }

.weak-points h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.weak-points p {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.weak-points-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.weak-point-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.weak-point-item {
  background: var(--color-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.weak-point-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--color-text-secondary);
  font-size: 11px;
  margin-bottom: 8px;
}

.weak-point-meta span:first-child {
  color: var(--color-warn);
  font-weight: 600;
}

.weak-point-item strong {
  display: block;
  color: var(--color-text);
  font-size: 14px;
  margin-bottom: 6px;
}

.weak-point-question {
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Modules ---------- */
.module-card {
  margin-bottom: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.module-header {
  position: relative;
  padding: 16px 24px 16px 28px;
  background: var(--color-subtle);
  border-bottom: 1px solid var(--color-border);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.module-header::before {
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  background: var(--color-accent);
  border-radius: 0 2px 2px 0;
}

.module-body { padding: 24px; }

.module-topics {
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.module-meta { margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 6px; }

.topic-tag {
  background: var(--color-accent-soft);
  border: 1px solid transparent;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
  display: inline-block;
}

/* ---------- Exercises ---------- */
.exercise-list { margin-top: 20px; }
.exercise-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
}
.exercise-list-header strong { font-weight: 500; color: var(--color-text); }

.exercise-progress {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-success);
  background: var(--color-success-soft);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.exercise-item {
  padding: 16px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.exercise-item:hover { border-color: var(--color-border-strong); }

.exercise-item.exercise-done {
  border-left-color: var(--color-success);
  background: var(--color-subtle);
}

.exercise-question {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.6;
}

.exercise-type {
  display: inline-block;
  background: var(--color-text);
  color: #fff;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 500;
  margin-right: 10px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}
.exercise-item.exercise-done .exercise-type { background: var(--color-success); }

/* ---------- Daily plan ---------- */
.daily-plan { margin-top: 24px; }
.daily-plan-main { margin-top: 0; }
.daily-plan-title {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.day-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin-bottom: 12px;
  transition: var(--transition);
}
.day-card:hover { border-color: var(--color-border-strong); }

.day-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.day-label {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 3px 11px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.day-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text);
  letter-spacing: -0.005em;
}

.day-date {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-left: auto;
}

/* ---------- Inline controls ---------- */
.info-item-btn {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.info-item-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.info-item-btn { font-size: 12px; }

/* Plan header specific controls must always be high-contrast light colored because plan-header is always dark */
.plan-header .info-item-btn {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
}
.plan-header .info-item-btn:hover {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Plan subnav ---------- */
.plan-subnav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
  margin: -8px 0 24px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.plan-subnav-item {
  appearance: none;
  position: relative;
  border: 0;
  background: transparent;
  color: var(--color-text-secondary);
  padding: 12px 4px;
  margin-right: 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.plan-subnav-item:hover { color: var(--color-text); }

.plan-subnav-item.active {
  color: var(--color-text);
}

.plan-subnav-item.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
}

.edit-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.edit-label input,
.edit-label textarea {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  resize: vertical;
  line-height: 1.5;
}

.edit-label input:focus,
.edit-label textarea:focus {
  outline: 2px solid var(--color-accent-soft);
  border-color: var(--color-accent);
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  color: #fff;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { border-color: var(--color-text); color: var(--color-text); }

.exercise-question {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}
.exercise-question-text { flex: 1 1 200px; min-width: 0; }

.day-content {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.7;
  min-height: 1.7em;
}

.day-content-empty {
  color: var(--color-text-tertiary);
  font-size: 13px;
  margin: 0;
}

.day-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.day-lesson-btn {
  padding: 7px 14px;
  font-size: 13px;
}

/* ---------- Markdown rendering ---------- */
.markdown-body {
  font-size: 14px;
  line-height: 1.68;
  color: inherit;
  overflow-wrap: anywhere;
}

.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body p { margin: 0.45em 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 0.9em 0 0.35em;
  color: var(--color-text);
  line-height: 1.35;
  font-weight: 600;
}
.markdown-body h1 { font-size: 1.18em; }
.markdown-body h2 { font-size: 1.12em; }
.markdown-body h3 { font-size: 1.03em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body ul,
.markdown-body ol {
  margin: 0.45em 0;
  padding-left: 1.35em;
}
.markdown-body li { margin: 0.14em 0; padding-left: 0.1em; }
.markdown-body li > p { margin: 0.15em 0; }

.markdown-body strong { color: var(--color-text); font-weight: 600; }
.markdown-body em { font-style: italic; }

.markdown-body a {
  color: var(--color-accent);
  text-decoration: none;
  text-underline-offset: 3px;
}
.markdown-body a:hover { text-decoration: underline; }

.markdown-body code {
  background: rgba(0, 113, 227, 0.08);
  border: 1px solid rgba(0, 113, 227, 0.10);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--color-text);
}

.markdown-body pre {
  background: #17191f;
  color: #f2f3f5;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.12);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
  margin: 0.65em 0;
  max-width: 100%;
}
.markdown-body pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.markdown-body blockquote {
  margin: 0.65em 0;
  padding: 8px 12px;
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-secondary);
  background: var(--color-accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body table {
  border-collapse: collapse;
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 0.7em 0;
  font-size: 0.94em;
  white-space: nowrap;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
}
.markdown-body th { background: var(--color-subtle); }

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 1em 0;
}

.markdown-inline {
  display: inline;
  line-height: inherit;
  overflow-wrap: anywhere;
}
.markdown-inline > p { display: inline; margin: 0; }
.markdown-inline > p + p { display: block; margin-top: 0.3em; }
.markdown-inline code {
  background: rgba(0, 113, 227, 0.08);
  border: 1px solid rgba(0, 113, 227, 0.10);
  border-radius: 4px;
  padding: 1px 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.markdown-inline a {
  color: var(--color-accent);
  text-decoration: none;
  text-underline-offset: 3px;
}
.markdown-inline a:hover { text-decoration: underline; }

/* ---------- Calendar ---------- */
.calendar-wrapper { margin-bottom: 24px; }

.calendar-month {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.calendar-month-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  padding: 6px 0;
  letter-spacing: 0.06em;
}

.calendar-cell {
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.calendar-cell-empty { border: none; background: transparent; }

.calendar-cell-disabled {
  background: var(--color-subtle);
  border-style: dashed;
}
.calendar-cell-disabled .calendar-day-num {
  color: var(--color-text-tertiary);
  font-weight: 400;
}

.calendar-cell-active {
  cursor: pointer;
  border-left: 3px solid var(--color-accent);
}
.calendar-cell-active:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.calendar-cell-active.completed {
  border-left-color: var(--color-success);
  background: var(--color-success-soft);
}
.calendar-cell-active.partial {
  border-left-color: var(--color-warn);
  background: var(--color-warn-soft);
}

.calendar-cell-active.is-today .calendar-day-num {
  color: var(--color-accent);
}

.calendar-cell-active.selected {
  box-shadow: 0 0 0 2px var(--color-accent);
  border-color: var(--color-accent);
}

.calendar-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1;
}

.calendar-day-title {
  font-size: 11px;
  color: var(--color-text-secondary);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.calendar-day-progress {
  margin-top: auto;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-success);
  background: rgba(29, 122, 58, 0.12);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}
.calendar-cell-active.partial .calendar-day-progress {
  color: var(--color-warn);
  background: rgba(163, 90, 0, 0.14);
}

.day-detail-panel { margin-top: 8px; }
.day-detail-panel .day-card { margin-bottom: 0; }

.day-detail-empty {
  text-align: center;
  color: var(--color-text-tertiary);
  padding: 40px 20px;
  background: var(--color-subtle);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  font-size: 14px;
}

@media (max-width: 720px) {
  .calendar-month { padding: 16px 12px; }
  .calendar-grid { gap: 4px; }
  .calendar-cell { min-height: 56px; padding: 6px; }
  .calendar-day-title { display: none; }
  .calendar-day-progress { font-size: 9px; padding: 1px 5px; }
  .feedback-grid { grid-template-columns: 1fr; }
  .feedback-header { flex-direction: column; }
  .feedback-time { white-space: normal; }
}

/* ---------- Submission ---------- */
.submission-form {
  background: var(--color-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-top: 14px;
  border: 1px solid var(--color-border);
}

.submission-form textarea { background: var(--color-surface); }

.submission-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.submission-controls label { font-size: 13px; color: var(--color-text-secondary); }
.submission-hint { font-size: 13px; color: var(--color-text-secondary); }
.submission-controls select {
  padding: 6px 10px;
  width: auto;
  margin-bottom: 0;
  font-size: 13px;
}

.submission-submit-btn {
  padding: 8px 18px;
  font-size: 13px;
}

.submission-view {
  background: var(--color-success-soft);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-top: 14px;
  border: 1px solid #cbe8d4;
}

.submission-meta {
  font-size: 13px;
  color: var(--color-success);
  font-weight: 500;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.submission-time { color: var(--color-text-secondary); font-weight: 400; }

.submission-content {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.6;
}

.submission-edit-btn {
  background: transparent;
  border: 1px solid var(--color-success);
  color: var(--color-success);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 10px;
}
.submission-edit-btn:hover { background: var(--color-success); color: #fff; }

/* ---------- Submission attachments ---------- */
.attachment-existing { margin-top: 12px; }
.attachment-existing-empty { display: none; }
.attachment-existing-title {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}
.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
}
.attachment-chip-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
}
.attachment-chip-link:hover { color: var(--color-accent); }
.attachment-chip-icon { font-size: 14px; }
.attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.attachment-chip-size { color: var(--color-text-tertiary); font-size: 12px; }
.attachment-chip-flag {
  font-size: 11px;
  color: var(--color-success);
  background: var(--color-success-soft);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.attachment-chip-flag-warn {
  color: var(--color-warn);
  background: var(--color-warn-soft);
}
.attachment-chip-remove {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.attachment-chip-remove:hover {
  color: var(--color-error);
  border-color: var(--color-error);
}
.attachment-chip-remove:disabled { opacity: 0.5; cursor: not-allowed; }

.attachment-picker {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-picker-label { display: inline-block; }
.attachment-picker-label input[type="file"] { display: none; }
.attachment-picker-btn {
  display: inline-block;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  color: var(--color-text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
.attachment-picker-label:hover .attachment-picker-btn {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.attachment-pending-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.attachment-pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-secondary);
  background: var(--color-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.attachment-picker-full {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* ---------- AI feedback ---------- */
.feedback-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 12px;
}

.feedback-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.feedback-btn:hover {
  background: var(--color-accent);
  color: #fff;
}

.feedback-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.feedback-btn-secondary {
  border-color: var(--color-border-strong);
  color: var(--color-text-secondary);
}

.feedback-card {
  margin-top: 14px;
  padding: 16px;
  background: var(--color-accent-soft);
  border: 1px solid rgba(0, 113, 227, 0.18);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
}

.feedback-card.feedback-verdict-correct {
  background: var(--color-success-soft);
  border-color: #cbe8d4;
  border-left-color: var(--color-success);
}
.feedback-card.feedback-verdict-incorrect {
  background: var(--color-error-soft);
  border-color: #f1c4c0;
  border-left-color: var(--color-error);
}
.feedback-card.feedback-verdict-partial {
  background: var(--color-warn-soft);
  border-color: rgba(163, 90, 0, 0.22);
  border-left-color: var(--color-warn);
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.feedback-header strong {
  display: block;
  color: var(--color-text);
  font-size: 14px;
  margin-top: 2px;
}

.feedback-label {
  display: block;
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.feedback-verdict { font-weight: 700; }
.feedback-verdict-correct .feedback-label,
.feedback-verdict-correct .feedback-verdict { color: var(--color-success); }
.feedback-verdict-incorrect .feedback-label,
.feedback-verdict-incorrect .feedback-verdict { color: var(--color-error); }
.feedback-verdict-partial .feedback-label,
.feedback-verdict-partial .feedback-verdict { color: var(--color-warn); }

.feedback-time {
  color: var(--color-text-tertiary);
  font-size: 12px;
  white-space: nowrap;
}

.feedback-summary,
.feedback-suggested p {
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.65;
}

.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.feedback-list,
.feedback-suggested {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 113, 227, 0.12);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.feedback-list strong,
.feedback-suggested strong {
  display: block;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 6px;
}

.feedback-list ul {
  margin: 0;
  padding-left: 18px;
}

.feedback-list li {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 4px;
}

.feedback-card > .feedback-list { margin-top: 12px; }

/* ---------- Plan actions / adjust ---------- */
.plan-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.adjust-hint {
  font-size: 13px;
  color: var(--color-text-tertiary);
}

.adjust-summary {
  padding: 14px 18px;
  background: var(--color-accent-soft);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  color: var(--color-text);
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
}

.plan-actions-ready {
  align-items: stretch;
  padding: 16px 18px;
  background: var(--color-success-soft);
  border: 1px solid #cbe8d4;
  border-radius: var(--radius-md);
  justify-content: space-between;
}

.plan-actions-ready .plan-actions-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 200px;
}

.plan-actions-ready .plan-actions-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-success);
}

.plan-actions-ready .plan-actions-text span {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.55;
}

/* ---------- Misc ---------- */
.section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--color-text);
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--color-accent);
  border-radius: 2px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  padding: 4px 0;
  margin-bottom: 16px;
  transition: var(--transition);
  text-decoration: none;
}
.back-btn:hover { color: var(--color-accent-hover); }

.result-title {
  margin: 8px 0 24px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.empty-state {
  text-align: center;
  color: var(--color-text-tertiary);
  padding: 80px 20px;
  font-size: 15px;
  background: var(--color-subtle);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.mastery-list {
  padding-left: 20px;
  color: var(--color-text);
  font-size: 15px;
  margin-bottom: 24px;
}
.mastery-list li { margin-bottom: 8px; line-height: 1.55; }

/* ---------- Auth forms ---------- */
.auth-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  margin-top: 16px;
  display: block;
}
.auth-form label:first-child { margin-top: 0; }

.auth-btn {
  margin-top: 28px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.auth-error {
  margin-top: 16px;
  padding: 11px 14px;
  background: var(--color-error-soft);
  color: var(--color-error);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 400;
  border: 1px solid #f1c4c0;
}

.auth-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 14px;
  color: var(--color-text-secondary);
}
.auth-footer a {
  color: var(--color-accent);
  text-decoration: none;
  transition: var(--transition);
}
.auth-footer a:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 32px 20px 64px; }
  .header { margin-bottom: 40px; }
  .header h1 { font-size: 36px; }
  .header p { font-size: 17px; }
  .ai-section { padding: 28px 24px; }
  .ai-section h3 { font-size: 20px; }
  .plan-header { padding: 28px 24px; }
  .plan-header h2 { font-size: 26px; }
  .plan-info { flex-direction: column; gap: 8px; align-items: flex-start; }
  .progress-overview { grid-template-columns: 1fr; }
  .progress-metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: auto; }
  .today-focus { align-items: stretch; flex-direction: column; }
  .today-focus-btn { width: 100%; }
  .weak-point-list { grid-template-columns: 1fr; }
  .result-title { font-size: 26px; }
  .auth-card { padding: 32px 24px 28px; }
  .tabs { gap: 24px; }
}

/* ---------- Subtle entrance ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.container, .auth-card { animation: fadeUp 0.4s var(--ease) both; }

/* ---------- Streaming skeleton ---------- */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton-line {
  display: block;
  height: 12px;
  margin: 6px 0;
  border-radius: 6px;
  background: linear-gradient(90deg, #eceef2 0%, #f7f8fa 50%, #eceef2 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-line-title { height: 18px; width: 60%; }
.skeleton-line-short { width: 40%; }

.streaming-plan-title .skeleton-line { height: 28px; width: 70%; }
.streaming-plan-description .skeleton-line { height: 14px; }
.streaming-plan-description .skeleton-line + .skeleton-line { width: 80%; }

.skeleton-day .day-content .skeleton-line + .skeleton-line { width: 92%; }

.streaming-progress {
  margin: 18px 0 22px;
  padding: 14px 18px;
  background: var(--color-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.streaming-progress-bar {
  height: 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 10px;
}
.streaming-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent), #5ac8fa);
  border-radius: 4px;
  transition: width 0.4s var(--ease);
}
.streaming-progress-text {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.day-card.skeleton-day { background: var(--color-subtle); }
.day-card.skeleton-day .day-title,
.day-card.skeleton-day .day-content { display: block; }
.day-card.skeleton-day .skeleton-line-title { width: 50%; }

/* 复习 tab：徽标、卡片、变体题表单 */
.tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-accent, #1f8a70);
  color: #fff;
  border-radius: 999px;
}
.review-intro {
  color: var(--color-text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}
.review-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.review-card {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.review-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-secondary);
  flex-wrap: wrap;
}
.review-due {
  font-weight: 600;
}
.review-due-overdue {
  color: #c0392b;
}
.review-original {
  background: var(--color-subtle, #f6f7f9);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
}
.review-original strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}
.review-variant-card {
  border: 1px dashed var(--color-border, #e5e7eb);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.review-focus {
  font-size: 13px;
  color: var(--color-text-secondary);
}
.review-hint summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--color-accent, #1f8a70);
}
.review-schedule {
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--color-subtle, #f6f7f9);
  border-radius: 6px;
  color: var(--color-text-secondary);
}

/* ---------- Course dashboard + AI classroom ---------- */
.course-builder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.learning-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.learning-hero h2 {
  font-size: 26px;
  line-height: 1.18;
  margin-bottom: 8px;
}

.learning-hero p {
  color: var(--color-text-secondary);
  font-size: 15px;
}

.learning-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}

.quick-card,
.recent-lesson-item {
  appearance: none;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.quick-card:hover,
.recent-lesson-item:hover,
.course-row:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.quick-card strong {
  display: block;
  font-size: 26px;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--color-text);
}

.quick-card span,
.course-row span,
.recent-lesson-item span,
.recent-lesson-item small {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.course-dashboard-list,
.recent-lesson-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 34px;
}

.course-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.course-row-main {
  flex: 1;
  min-width: 0;
}

.course-row-main strong,
.recent-lesson-item strong {
  display: block;
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--color-text);
}

.course-progress-bar {
  height: 6px;
  margin-top: 10px;
  background: var(--color-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.course-progress-bar div {
  height: 100%;
  background: var(--color-accent);
}

.course-row-action {
  border: 1px solid var(--color-border);
  background: var(--color-subtle);
  color: var(--color-text);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-family: inherit;
  cursor: pointer;
}

.lesson-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.lesson-header,
.lesson-outline,
.lesson-stage {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.lesson-header h2 {
  font-size: 26px;
  line-height: 1.18;
  margin-bottom: 6px;
}

.lesson-header p {
  color: var(--color-text-secondary);
}

.lesson-status {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-warn-soft);
  color: var(--color-warn);
  font-size: 13px;
  font-weight: 600;
}

.lesson-status.completed {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.lesson-outline h3,
.lesson-stage h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.lesson-outline .btn {
  margin-top: 16px;
}

.lesson-message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lesson-message {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: #fff;
}

.lesson-message-user {
  background: var(--color-accent-soft);
  border-color: rgba(0, 113, 227, 0.18);
}

.lesson-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.lesson-message-meta span {
  font-weight: 600;
  color: var(--color-text);
}

.lesson-checkpoints {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--color-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.lesson-checkpoints ul {
  margin: 10px 0 0 20px;
}

.lesson-video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lesson-video-header h3 {
  margin-bottom: 0;
}

.lesson-video-header span {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.lesson-video-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-video-resource {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--color-subtle);
}

.lesson-video-resource-main strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.lesson-video-resource-main p,
.lesson-video-resource-main small {
  display: block;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.lesson-video-query {
  margin: 10px 0 8px;
  padding: 9px 11px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.lesson-video-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.video-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.video-tag-cover {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.video-tag-avoid {
  color: var(--color-warn);
  background: var(--color-warn-soft);
}

.lesson-video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-accent);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.resource-link:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.resource-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.video-refresh-btn {
  font-family: inherit;
  cursor: pointer;
}

.video-candidate-empty {
  margin-top: 12px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.video-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.video-candidate {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.video-candidate-clickable {
  cursor: pointer;
  transition: var(--transition);
}

.video-candidate-clickable:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.video-candidate-failed {
  display: block;
  color: var(--color-error);
  background: var(--color-error-soft);
  border-color: rgba(179, 38, 30, 0.22);
  font-size: 13px;
}

.video-candidate-score {
  min-height: 52px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.video-candidate-score strong {
  font-size: 18px;
  line-height: 1;
}

.video-candidate-score span {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
}

.video-candidate-score em {
  margin-top: 3px;
  color: var(--color-text-secondary);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
}

.video-candidate-main {
  min-width: 0;
}

.video-candidate-main a {
  display: inline-block;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}

.video-candidate-main a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.video-candidate-main small {
  display: block;
  color: var(--color-text-secondary);
  font-size: 12px;
  margin-top: 3px;
}

.video-candidate-main p {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 7px;
}

.video-candidate-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.video-candidate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.lesson-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.lesson-chat-form textarea {
  margin-bottom: 0;
}

.lesson-complete-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .course-builder-grid,
  .learning-quick-grid,
  .lesson-chat-form {
    grid-template-columns: 1fr;
  }

  .learning-hero,
  .course-row,
  .lesson-header,
  .lesson-video-header {
    align-items: stretch;
    flex-direction: column;
  }

  .video-candidate {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   AESTHETIC UPGRADES: GLASSMORPHISM, DARK MODE, LOADERS & HEATMAPS
   ========================================================================= */

/* Glassmorphism utility card */
.glassmorphic {
  background: rgba(255, 255, 255, 0.45) !important;
  backdrop-filter: blur(20px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(190%) !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.04) !important;
}

/* Theme toggle button inside header */
.theme-toggle-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-btn:hover {
  background: var(--color-subtle);
  transform: scale(1.1);
}

/* Webcal sync widget styles */
.calendar-sync-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius-lg);
  margin: 24px 0;
  transition: var(--transition);
}

.calendar-sync-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.08) !important;
}

.sync-icon {
  font-size: 28px;
  background: var(--color-accent-soft);
  padding: 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sync-info {
  flex: 1;
}

.sync-info h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.sync-info p {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.sync-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.sync-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: monospace;
  background: rgba(255, 255, 255, 0.8);
  color: var(--color-text-secondary);
  outline: none;
}

.sync-input:focus {
  border-color: var(--color-accent);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.sync-subscribe-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Pulsating micro-animations and thinking skeletons */
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.pulsating-loader {
  animation: pulse 1.5s infinite ease-in-out;
  background: linear-gradient(90deg, var(--color-subtle) 25%, var(--color-border) 50%, var(--color-subtle) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  height: 16px;
  width: 100%;
  margin: 10px 0;
}

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--color-subtle);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  animation: pulse 1.8s infinite ease-in-out;
  margin: 14px 0;
}

.dot-flashing {
  display: inline-flex;
  gap: 4px;
}

.dot-flashing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-text-secondary);
  animation: pulse 1s infinite alternate;
}

.dot-flashing span:nth-child(2) { animation-delay: 0.2s; }
.dot-flashing span:nth-child(3) { animation-delay: 0.4s; }

/* Interactive study heatmap container */
.study-heatmap-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.heatmap-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.legend-box {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.heatmap-svg-wrapper {
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-svg {
  display: block;
}

/* ==========================================================================
   CLASS-BASED DARK THEME SUPPORT
   ========================================================================== */

/* Explicit class-based dark theme toggler */
body.dark-theme {
  --color-bg: #09090b;
  --color-surface: #18181b;
  --color-subtle: #27272a;
  --color-text: #ffffff;
  --color-text-secondary: #f2f2f7;
  --color-text-tertiary: #d1d1d6;
  --color-border: #27272a;
  --color-border-strong: #3f3f46;
  --color-accent: #3b82f6;
  --color-accent-hover: #60a5fa;
  --color-accent-soft: rgba(59, 130, 246, 0.15);
  --color-success: #10b981;
  --color-success-soft: rgba(16, 185, 129, 0.15);
  --color-warn: #f59e0b;
  --color-warn-soft: rgba(245, 158, 11, 0.15);
  --color-error: #ef4444;
  --color-error-soft: rgba(239, 68, 68, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.dark-theme .ai-section {
  background: linear-gradient(180deg, #1c1c1e 0%, #121214 100%);
  border-color: var(--color-border);
}

body.dark-theme .streak-card.streak-active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.22));
  border-color: rgba(245, 158, 11, 0.35);
}

body.dark-theme .streak-card.streak-active .metric-value {
  color: #fbbf24;
}

body.dark-theme .btn.ai-btn:hover,
body.dark-theme .btn.adjust-btn:hover {
  background: #3a3a3c;
  color: #ffffff;
}

body.dark-theme .lesson-message {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
}

body.dark-theme .lesson-message-user {
  background: var(--color-accent-soft) !important;
}

body.dark-theme .glassmorphic {
  background: rgba(24, 24, 27, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.dark-theme .calendar-sync-card {
  background: rgba(24, 24, 27, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-theme .sync-input {
  background: rgba(0, 0, 0, 0.4);
  border-color: var(--color-border);
  color: var(--color-text);
}

body.dark-theme .btn.ai-btn,
body.dark-theme .btn.adjust-btn {
  background: #f4f4f5;
  color: #09090b !important;
}

body.dark-theme .exercise-type {
  background: #f4f4f5;
  color: #09090b !important;
}

body.dark-theme .exercise-item.exercise-done .exercise-type {
  background: var(--color-success);
  color: #04130c !important;
}

body.dark-theme .feedback-list,
body.dark-theme .feedback-suggested {
  background: rgba(9, 9, 11, 0.42);
  border-color: rgba(255, 255, 255, 0.10);
}

body.dark-theme .feedback-summary,
body.dark-theme .feedback-suggested p,
body.dark-theme .feedback-list li {
  color: var(--color-text-secondary);
}

body.dark-theme .feedback-card.feedback-verdict-correct {
  border-color: rgba(16, 185, 129, 0.3) !important;
}

body.dark-theme .feedback-card.feedback-verdict-incorrect {
  border-color: rgba(239, 68, 68, 0.3) !important;
}

body.dark-theme .feedback-card.feedback-verdict-partial {
  border-color: rgba(245, 158, 11, 0.3) !important;
}

body.dark-theme .submission-view {
  border-color: rgba(16, 185, 129, 0.3);
}

body.dark-theme .auth-error {
  border-color: rgba(239, 68, 68, 0.3);
  color: #ff6b6b;
}

body.dark-theme .review-due-overdue {
  color: #ff6b6b;
}
