/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:        #0f172a;
  --surface:   #111827;
  --surface-2: #0b1220;
  --border:    #1f2937;
  --border-2:  #334155;
  --text:      #e5e7eb;
  --muted:     #9ca3af;
  --blue:      #1d4ed8;
  --blue-h:    #1e40af;
  --slate:     #334155;
  --slate-h:   #475569;
  --ok:        #34d399;
  --warn:      #fbbf24;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #020617 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ── Page layout ────────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 { font-size: 1.5rem; margin-bottom: 4px; }

.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.subtitle strong { color: var(--text); }

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Buttons ────────────────────────────────────────────── */
/* Base: no width, no margin — context controls layout */
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: var(--blue);
  color: var(--text);
  transition: background 0.15s;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--blue-h); }
button:disabled              { opacity: 0.45; cursor: not-allowed; }
button.ghost                 { background: var(--slate); }
button.ghost:hover:not(:disabled) { background: var(--slate-h); }
button.loading               { opacity: 0.7; cursor: wait; }

/* Full-width standalone button */
.btn-block { width: 100%; }

/* Row of equal-width buttons / labels */
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row > * { flex: 1; }          /* buttons AND labels stretch equally */

/* ── File input label (visually a button) ───────────────── */
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: var(--blue);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.file-label:hover { background: var(--blue-h); }

/* ── Form elements ──────────────────────────────────────── */
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}
textarea:focus { outline: none; border-color: #3b82f6; }

.input-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: -2px;
}

/* ── Utility ────────────────────────────────────────────── */
.hidden  { display: none !important; }
.status-text { font-size: 13px; color: var(--muted); }
.feedback    { font-size: 14px; min-height: 20px; }
.success     { color: var(--ok); }
.warning     { color: var(--warn); }

/* ── Image preview ──────────────────────────────────────── */
.preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
}

/* ── Topic / difficulty badges ──────────────────────────── */
.topic-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.badge {
  padding: 4px 10px;
  border-radius: 9999px;
  background: #1e3a8a;
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 600;
}
.difficulty-badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.difficulty-badge.easy   { background: #14532d; color: #86efac; }
.difficulty-badge.medium { background: #713f12; color: #fde68a; }
.difficulty-badge.hard   { background: #7f1d1d; color: #fca5a5; }

/* ── Key concepts row ───────────────────────────────────── */
.concepts-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.concepts-label {
  font-size: 12px;
  color: var(--muted);
}
.concepts-label::after { content: ":"; }
.concept-tag {
  padding: 3px 8px;
  background: #1e3a5f;
  color: #93c5fd;
  border-radius: 6px;
  font-size: 12px;
}

/* ── Hint box (tutor 4-part card) ───────────────────────── */
.hint-box {
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
/* Empty / loading state text */
.hint-box > .status-text { padding: 14px; }

.tutor-track {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tutor-track.track-good   { background: #14532d; color: #86efac; }
.tutor-track.track-adjust { background: #713f12; color: #fde68a; }

.tutor-section {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.tutor-section:first-child { border-top: none; }

.tutor-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.tutor-confirm      .tutor-label { color: #64748b; }
.tutor-step         .tutor-label { color: #60a5fa; }
.tutor-hint-section .tutor-label { color: #a78bfa; }
.tutor-turn         .tutor-label { color: #34d399; }

.tutor-section p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* ── Common mistakes box ────────────────────────────────── */
.mistakes-box {
  background: #2d1b00;
  border: 1px solid #78350f;
  border-radius: 10px;
  padding: 12px 14px;
}
.mistakes-title {
  color: var(--warn);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.mistakes-box ul { padding-left: 16px; }
.mistakes-box li { color: #d97706; font-size: 13px; margin: 4px 0; }

/* ── Mistake journal ────────────────────────────────────── */
.card ul   { padding-left: 16px; }
.card li   { font-size: 14px; color: #cbd5e1; margin: 6px 0; }

/* ── Camera modal ───────────────────────────────────────── */
.camera-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.camera-inner {
  width: min(100vw, 640px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.camera-btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
#cameraVideo {
  width: 100%;
  border-radius: 12px;
  background: #000;
  max-height: 60vh;
  object-fit: cover;
  display: block;
}
.camera-controls {
  display: flex;
  gap: 10px;
}
.camera-controls > button { flex: 1; }
.capture-btn {
  flex: 2 !important;
  background: #dc2626 !important;
  font-size: 16px;
}
.capture-btn:hover:not(:disabled) { background: #b91c1c !important; }
