[hidden] {
  display: none !important;
}

:root {
  --ink: #0F1524;
  --ink-raised: #161F35;
  --ink-line: #2A3552;
  --paper: #F3EFE4;
  --paper-dim: #B9C0D4;
  --amber: #E8A33D;
  --amber-dim: #7A5C2A;
  --periwinkle: #8B7FD6;
  --teal: #5FA8A0;
  --coral: #D6602F;

  --bg: var(--ink);
  --bg-raised: var(--ink-raised);
  --line: var(--ink-line);
  --text: var(--paper);
  --text-dim: var(--paper-dim);
  --accent: var(--amber);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

[data-theme="light"] {
  --bg: #F6F3EA;
  --bg-raised: #FFFFFF;
  --line: #DCD6C4;
  --text: #1B2033;
  --text-dim: #5B6076;
  --accent: #B77B1E;
}

[data-theme="midnight"] {
  --bg: #030508;
  --bg-raised: #0C1018;
  --line: #1E2530;
  --text: #E8ECF2;
  --text-dim: #7A8496;
  --accent: #4FB6E8;
}

[data-theme="sepia"] {
  --bg: #F1E6D3;
  --bg-raised: #FBF4E7;
  --line: #DFCBA8;
  --text: #3A2E1F;
  --text-dim: #7A6A50;
  --accent: #B5562E;
}

* {
  box-sizing: border-box;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  transition: background .25s ease, color .25s ease;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--amber), var(--periwinkle));
  color: #14162A;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.brand-disclaimer {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}

.brand-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: .03em;
  margin-top: 2px;
}

.icon-btn {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn-label {
  font-family: var(--font-body);
  font-size: 13px;
  white-space: nowrap;
}

.theme-select {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  height: 36px;
  border-radius: 8px;
  padding: 0 10px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.theme-select:hover {
  border-color: var(--accent);
}

/* ---------- Layout ---------- */
#app {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 100px;
}

.view-head {
  margin-bottom: 28px;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  margin: 0 0 10px;
}

.subhead {
  color: var(--text-dim);
  max-width: 55ch;
  line-height: 1.5;
  margin: 0;
}

.back-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
  display: block;
}

.back-link:hover {
  color: var(--accent);
}

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

.exam-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
  text-align: left;
}

.exam-card:hover:not(.disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.exam-card.disabled {
  opacity: .5;
  cursor: not-allowed;
}

.exam-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 6px;
}

.exam-card p {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0;
}

.status-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.status-pill.active {
  background: rgba(95, 168, 160, .18);
  color: var(--teal);
}

.status-pill.coming_soon {
  background: rgba(185, 192, 212, .15);
  color: var(--text-dim);
}

/* ---------- Subjects / topics ---------- */
.subject-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.subject-block h2 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 10px;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.topic-row:hover {
  border-color: var(--accent);
}

.topic-name {
  flex: 1;
  font-size: 14px;
}

.weightage-bar {
  width: 60px;
  height: 6px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  flex-shrink: 0;
}

.weightage-bar-fill {
  height: 100%;
  background: var(--accent);
}

.weightage-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  width: 46px;
  text-align: right;
  flex-shrink: 0;
}

.contest-cta {
  margin-top: 26px;
  width: 100%;
  background: linear-gradient(135deg, var(--periwinkle), var(--amber));
  border: none;
  border-radius: 10px;
  padding: 18px;
  color: #14162A;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.contest-cta-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  opacity: .8;
}

.contest-cta.locked {
  background: var(--bg-raised);
  color: var(--text-dim);
  cursor: not-allowed;
  border: 1px solid var(--line);
}

.contest-cta.locked .contest-cta-sub {
  opacity: 1;
}

/* ---------- Workspace ---------- */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-tab {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}

.mode-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-dim);
}

.lang-row select {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--font-body);
  font-size: 13px;
}

.pyq-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: wrap;
}

.pyq-picker-head .hint {
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
}

.small-btn {
  padding: 7px 12px;
  font-size: 12px;
  margin-top: 0;
}

.pyq-picker {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pyq-picker-item {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}

.pyq-picker-item.selected {
  border-color: var(--accent);
}

.output-panel {
  display: flex;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 220px;
  margin-bottom: 18px;
  overflow: hidden;
}

.output-margin {
  width: 6px;
  background: var(--coral);
  flex-shrink: 0;
}

.output-content {
  padding: 22px;
  flex: 1;
  line-height: 1.65;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.output-content .placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.output-content .error-msg {
  color: var(--coral);
  font-family: var(--font-mono);
  font-size: 13px;
}

.retry-btn {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--coral);
  color: var(--coral);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
}

.workspace-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.workspace-actions .secondary-btn {
  margin-top: 0;
}

.primary-btn {
  background: var(--accent);
  color: #14162A;
  border: none;
  padding: 13px 22px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.secondary-btn {
  background: none;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 20px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  margin-top: 10px;
}

.secondary-btn:hover {
  border-color: var(--accent);
}

/* ---------- Contest ---------- */
.contest-intro {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.contest-intro h1 {
  margin-bottom: 12px;
}

.contest-intro .subhead {
  margin: 0 auto 24px;
}

.contest-topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}

.contest-topic-picker {
  display: flex;
  flex-direction: column;
  gap: 22px;
  text-align: left;
  margin-bottom: 26px;
}

.contest-topic-picker-subject h3 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0 0 10px;
  color: var(--text-dim);
}

.contest-topic-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}

.contest-topic-checkbox:hover {
  border-color: var(--accent);
}

.contest-topic-checkbox.checked {
  border-color: var(--accent);
  background: rgba(232, 163, 61, .08);
}

.contest-topic-checkbox input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.contest-topic-checkbox .cb-name {
  flex: 1;
  font-size: 14px;
}

.contest-topic-checkbox .cb-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.score-breakdown {
  max-width: 460px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
}

.score-breakdown .score-number {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
}

.score-breakdown .score-fraction {
  font-size: 22px;
  color: var(--text-dim);
  font-weight: 500;
}

.score-breakdown .score-label {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

.score-breakdown .score-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}

.score-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--line);
}

.score-dot.correct {
  background: var(--teal);
}

.score-dot.incorrect {
  background: var(--coral);
}

.contest-header {
  text-align: center;
  margin-bottom: 28px;
}

.contest-progress-bar {
  max-width: 400px;
  margin: 14px auto 0;
  height: 6px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.contest-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--periwinkle), var(--amber));
  transition: width .3s ease;
}

.flip-clock {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: .05em;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-block;
  padding: 10px 26px;
  margin-top: 8px;
  color: var(--accent);
}

.contest-card {
  max-width: 620px;
  margin: 0 auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
}

.contest-topic-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--periwinkle);
  margin-bottom: 12px;
}

.contest-question {
  font-size: 19px;
  line-height: 1.5;
  margin-bottom: 24px;
  font-weight: 600;
}

.contest-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contest-option {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14.5px;
  text-align: left;
  transition: border-color .15s ease, transform .1s ease;
}

.contest-option:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateX(2px);
}

.contest-option:disabled {
  cursor: default;
}

.contest-option-badge {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.contest-option.selected {
  border-color: var(--accent);
  background: rgba(232, 163, 61, .1);
}

.contest-option.selected .contest-option-badge {
  border-color: var(--accent);
  color: var(--accent);
}

.contest-option.correct {
  border-color: var(--teal);
  background: rgba(95, 168, 160, .12);
}

.contest-option.correct .contest-option-badge {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(95, 168, 160, .2);
}

.contest-option.incorrect {
  border-color: var(--coral);
  background: rgba(214, 96, 47, .12);
}

.contest-option.incorrect .contest-option-badge {
  border-color: var(--coral);
  color: var(--coral);
  background: rgba(214, 96, 47, .2);
}

.contest-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 620px;
  margin: 22px auto 0;
}

.contest-progress {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.reschedule-box {
  margin-top: 24px;
  padding: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.reschedule-box h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 16px;
}

.reschedule-box .hint {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 12px;
}

.reschedule-box input[type="date"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  margin-right: 10px;
}

.reschedule-msg {
  font-size: 13px;
  margin-top: 10px;
  font-family: var(--font-mono);
}

.reschedule-msg.ok {
  color: var(--teal);
}

.reschedule-msg.err {
  color: var(--coral);
}

/* ---------- Streak pill ---------- */
.streak-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  margin-right: 4px;
}

.streak-pill-label {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 2px;
}

/* ---------- Subject-level action buttons ---------- */
.subject-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.subject-actions {
  display: flex;
  gap: 6px;
}

.subject-action-btn {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 6px 11px;
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.subject-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Bookmark star on topic rows ---------- */
.topic-bookmark-star {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--line);
  padding: 2px;
}

.topic-bookmark-star.active {
  color: var(--accent);
}

/* ---------- Bookmarks list view ---------- */
.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bookmark-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
}

.bookmark-item:hover {
  border-color: var(--accent);
}

.bookmark-item-name {
  font-size: 14px;
}

.bookmark-item-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.bookmark-remove-btn {
  color: var(--coral);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ---------- Doubt chat ---------- */
.doubt-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.doubt-messages {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doubt-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.doubt-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #14162A;
}

.doubt-bubble.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
}

.doubt-input-row {
  display: flex;
  gap: 8px;
}

.doubt-input-row input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}

.doubt-input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Study plan form ---------- */
.study-plan-form {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.study-plan-form label {
  font-size: 13px;
  color: var(--text-dim);
}

.study-plan-form input[type="date"] {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-family: var(--font-mono);
}

/* ---------- Mermaid diagram container ---------- */
.diagram-container {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin: 14px 0;
  overflow-x: auto;
  text-align: center;
}

.diagram-container svg {
  max-width: 100%;
  height: auto;
}

/* ---------- Confetti canvas ---------- */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  display: none;
}

/* ---------- Quote of the day ---------- */
.quote-of-day {
  font-family: var(--font-mono);
  font-style: italic;
  font-size: 13px;
  color: var(--accent);
  margin: 16px 0 0;
  max-width: 55ch;
}

/* ---------- Exam header row (headline + goal card side by side) ---------- */
.view-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.view-head-row .view-head {
  margin-bottom: 0;
  flex: 1;
  min-width: 280px;
}

@media (max-width: 700px) {
  .view-head-row {
    flex-direction: column;
  }
}

/* ---------- Daily goal ring (sidebar card) ---------- */
.daily-goal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 18px;
  width: 190px;
  flex-shrink: 0;
  margin-top: 4px;
}

.goal-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 12px;
}

.goal-ring {
  width: 110px;
  height: 110px;
  transform: rotate(-90deg);
}

.goal-ring-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 9;
}

.goal-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 263.9;
  stroke-dashoffset: 263.9;
  transition: stroke-dashoffset .4s ease;
}

.goal-ring-pct {
  transform: rotate(90deg);
  transform-origin: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  fill: var(--text);
}

.goal-progress-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin-top: 10px;
}

.goal-status-text {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  margin-bottom: 14px;
  min-height: 16px;
}

.goal-adjust {
  display: flex;
  align-items: center;
  gap: 8px;
}

.goal-adjust-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.goal-adjust-btn:hover {
  border-color: var(--accent);
}

.goal-adjust-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
}

/* ---------- Badges ---------- */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.badge-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  opacity: .4;
}

.badge-card.earned {
  opacity: 1;
  border-color: var(--accent);
}

.badge-icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.badge-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Flashcards ---------- */
.flashcards-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.flashcard-stage {
  width: 100%;
  max-width: 480px;
  min-height: 220px;
  perspective: 1200px;
}

.flashcard-stage .placeholder {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding-top: 80px;
}

.flashcard {
  width: 100%;
  min-height: 220px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .5s ease;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  font-size: 15px;
  text-align: center;
  line-height: 1.5;
}

.flashcard-face.back {
  transform: rotateY(180deg);
  border-color: var(--accent);
}

.flashcard-hint {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.flashcard-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---------- Diagnose Mistake ---------- */
.diagnose-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 560px;
}

.diagnose-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

.diagnose-textarea {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  resize: vertical;
}

.diagnose-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

#diagnoseBtn {
  margin-top: 14px;
  align-self: flex-start;
}

#diagnosePanel {
  margin-top: 16px;
}

/* ---------- Cheat sheet cards ---------- */
.cheat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.cheat-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: 3px solid var(--cheat-accent);
  border-radius: 10px;
  padding: 16px;
}

.cheat-card-title {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--cheat-accent);
}

.cheat-point {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.cheat-point-num {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.cheat-point-label {
  font-weight: 600;
  font-size: 13px;
}

.cheat-point-detail {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
}

/* ---------- Name-entry modal ---------- */
.name-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.name-modal {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.name-modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 8px;
}

.name-modal .hint {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 20px;
}

.name-modal input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 14px;
  text-align: center;
}

.name-modal input:focus {
  outline: none;
  border-color: var(--accent);
}

.greeting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-greeting {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.change-name-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px 10px;
}

.change-name-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Developer credit ---------- */
.developer-credit {
  text-align: center;
  margin: 60px 0 20px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.developer-credit-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .04em;
  color: var(--text);
}

.developer-credit-uni {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: .06em;
  margin-top: 6px;
}

@media (max-width: 600px) {
  #app {
    padding: 24px 16px 80px;
  }

  .flip-clock {
    font-size: 34px;
    padding: 8px 18px;
  }
}