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

/* ── Tokens ── */
:root {
  --bg:             #F7F6F3;
  --card:           #FFFFFF;
  --text:           #1A1A18;
  --soft:           #6B6B68;
  --hint:           #9A9A96;
  --border:         #E2DED6;
  --accent:         #4A7C59;
  --accent-light:   #EBF3EE;
  --accent-border:  #B8D9C3;
  --warn:           #8B6914;
  --warn-light:     #FBF5E6;
  --warn-border:    #E0C97A;
  --canvas-bg:      #FDFCFA;
  --canvas-border:  #D4D0C8;
  --radius:         14px;
  --radius-sm:      8px;
}

body {
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: none;
}

/* ── LOGIN ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

.login-wrap {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.login-logo {
  font-size: 52px;
  line-height: 1;
}

.login-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  text-align: center;
}

.login-card {
  width: 100%;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-error {
  font-size: 14px;
  color: #A0341A;
  min-height: 20px;
}

/* ── APP ── */
.app-header {
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-title {
  font-size: 16px;
  font-weight: 600;
}

.app-main {
  padding: 1.5rem 1.25rem;
  max-width: 600px;
  margin: 0 auto;
}

.app-greeting {
  font-size: 15px;
  color: var(--soft);
  margin-bottom: 1.5rem;
}

.module-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.module-card.active {
  border-color: var(--accent);
  cursor: pointer;
}

.module-card.active:active {
  background: var(--accent-light);
}

.module-card.disabled {
  opacity: 0.4;
  cursor: default;
}

.module-icon { font-size: 22px; width: 36px; text-align: center; }

.module-info { flex: 1; }
.module-name { font-size: 15px; font-weight: 500; }
.module-desc { font-size: 12px; color: var(--hint); margin-top: 2px; }
.module-arrow { font-size: 18px; color: var(--accent); }

/* ── LEKTION ── */
.lesson-header {
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.lesson-title { font-size: 16px; font-weight: 600; flex: 1; }

.step-dots { display: flex; gap: 5px; }
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #D4D0C8;
  transition: all 0.2s;
}
.dot.done { background: var(--accent); }
.dot.active { background: var(--accent); width: 18px; border-radius: 4px; }

.lesson-content {
  padding: 1.25rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ── TEORI ── */
.theory-block {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
}

.theory-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.theory-text {
  font-size: 15px;
  line-height: 1.7;
}

.theory-example {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin-top: 0.875rem;
  font-size: 15px;
  line-height: 2;
}

/* ── UPPGIFT ── */
.exercise-q {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

/* ── RITYTA ── */
.draw-wrap { margin-bottom: 1rem; }
.draw-label { font-size: 12px; color: var(--hint); margin-bottom: 6px; }

canvas.draw-canvas {
  display: block;
  width: 100%;
  height: 170px;
  background: var(--canvas-bg);
  border: 1.5px solid var(--canvas-border);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

.draw-tools { display: flex; gap: 8px; margin-top: 8px; }

/* ── SVARSFÄLT ── */
.answer-input {
  width: 100%;
  font-size: 24px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--canvas-border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  outline: none;
  text-align: center;
  -webkit-appearance: none;
  margin-bottom: 0.75rem;
}
.answer-input:focus { border-color: var(--accent); }
.answer-input.correct { border-color: var(--accent); background: var(--accent-light); }
.answer-input.retry   { border-color: #C89B3C; background: var(--warn-light); }

/* ── FEEDBACK ── */
.feedback {
  font-size: 14px;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: none;
}
.feedback.correct {
  display: block;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}
.feedback.retry {
  display: block;
  background: var(--warn-light);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

/* ── KLAR-SKÄRM ── */
.done-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1.25rem;
  text-align: center;
  padding: 2rem 1.5rem;
}
.done-icon  { font-size: 56px; }
.done-title { font-size: 22px; font-weight: 600; }
.done-sub   { font-size: 15px; color: var(--soft); line-height: 1.6; max-width: 280px; }

/* ── KNAPPAR ── */
.btn-primary {
  width: 100%;
  padding: 0.9rem;
  font-size: 16px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.btn-primary:active   { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.5; }

.btn-secondary {
  width: 100%;
  padding: 0.9rem;
  font-size: 16px;
  font-weight: 500;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
  margin-top: 8px;
}
.btn-secondary:active { opacity: 0.8; }

.btn-ghost {
  width: 100%;
  padding: 0.6rem;
  font-size: 13px;
  color: var(--hint);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}

.btn-back {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--soft);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-logout {
  font-size: 13px;
  color: var(--hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}

/* ── FÄLT ── */
.field-label {
  font-size: 13px;
  color: var(--soft);
  font-weight: 500;
}

.field-input {
  width: 100%;
  font-size: 18px;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.field-input:focus { border-color: var(--accent); }

/* ── MATHJAX ── */
mjx-container { overflow-x: auto; max-width: 100%; }
