/* ============================================================
   Focusio – visuellt tema: papper, bläck & terrakotta
   Endast utseende. Ingen logik eller text ändras här.
   ============================================================ */

/* Typsnitt: self-hostade, inga externa anrop. Bara latinska tecken
   (räcker för engelska och å ä ö), så filerna hålls små. */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/newsreader-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/instrument-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f4f0e7;
  --surface: #fbf8f1;
  --surface-2: #ede7da;
  --ink: #24211b;
  --ink-soft: #47423a;
  --muted: #655f54;
  --line: #d8d0c1;
  --line-strong: #b3a996;
  --accent: #b34e27;
  --accent-deep: #8c3a1d;
  --accent-soft: #f0dfd3;
  --good: #42603c;
  --good-soft: #e6ede2;
  --bad: #8e3728;
  --bad-soft: #f3e2dd;
  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  --radius-sm: 4px;
  --field: #fffdf8;
  --field-alt: #f7f0e4;
  --warm: #f6efe3;
  --ring-track: #e3dccd;
  --plan-line: #c9d3bf;
  --on-accent: #fffaf2;
  --cream: #fdf8ef;
  color-scheme: light;
}

/* Mörkt läge. Följer systeminställningen tills man väljer tema i
   Inställningar – då sätter theme.js data-theme på <html>.
   Endast variabler byts ut, så typsnitt och layout är identiska. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161411;
    --surface: #1e1b17;
    --surface-2: #2a261f;
    --ink: #f1ece2;
    --ink-soft: #d7d0c3;
    --muted: #a89e8d;
    --line: #3a342b;
    --line-strong: #57503f;
    --accent: #d97757;
    --accent-deep: #e9a184;
    --accent-soft: #3a2a22;
    --good: #a3c793;
    --good-soft: #232c1f;
    --bad: #e2937d;
    --bad-soft: #33231f;
    --field: #201d18;
    --field-alt: #262119;
    --warm: #241f18;
    --ring-track: #332d24;
    --plan-line: #3f4a37;
    --on-accent: #1a1611;
    --cream: #1a1712;
    color-scheme: dark;
  }
}

/* Manuellt mörkt läge spelar över ett ljust system. */
:root[data-theme="dark"] {
  --paper: #161411;
  --surface: #1e1b17;
  --surface-2: #2a261f;
  --ink: #f1ece2;
  --ink-soft: #d7d0c3;
  --muted: #a89e8d;
  --line: #3a342b;
  --line-strong: #57503f;
  --accent: #d97757;
  --accent-deep: #e9a184;
  --accent-soft: #3a2a22;
  --good: #a3c793;
  --good-soft: #232c1f;
  --bad: #e2937d;
  --bad-soft: #33231f;
  --field: #201d18;
  --field-alt: #262119;
  --warm: #241f18;
  --ring-track: #332d24;
  --plan-line: #3f4a37;
  --on-accent: #1a1611;
  --cream: #1a1712;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

.hidden {
  display: none !important;
}

/* ---------- Toppbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 0 20px;
  border-bottom: 1px solid var(--line);
}

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

.brand-logo {
  display: block;
  height: 40px;
  width: auto;
}

.level {
  width: 230px;
}

.level-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.level-row #levelLabel {
  color: var(--ink);
}

.xp-track {
  height: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.35s ease;
}

/* ---------- Generella byggstenar ---------- */

.view {
  animation: viewIn 0.22s ease both;
}

@keyframes viewIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mini-label {
  margin: 0 0 10px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.58;
  color: var(--muted);
  text-wrap: pretty;
}

.hint.error {
  color: var(--bad);
}

.hint.center {
  margin-top: 18px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.015em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.btn.ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--line-strong);
}

.btn.ghost:hover {
  background: var(--surface-2);
  border-color: var(--ink);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.btn.danger {
  color: var(--bad);
  background: transparent;
  border-color: var(--bad);
}

.btn.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--ink);
  color: var(--ink);
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-deep);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: var(--ink);
}

/* ---------- Hemskärmens meny & sektioner ---------- */

.home-layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.home-nav {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: calc(100vh - 200px);
  padding-top: 8px;
}

/* Inställningar ligger alltid längst ner i menykolumnen. */
.home-nav-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.home-nav-label {
  margin: 0 0 10px;
  padding-left: 12px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.home-nav-item svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.home-nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.home-nav-item.is-active {
  border-left-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
}

.home-nav-item.is-active svg {
  opacity: 1;
  color: var(--accent-deep);
}

.home-nav-sep {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.home-content {
  min-width: 0;
}

.home-page[hidden] {
  display: none !important;
}

.home-layout .hero {
  max-width: 860px;
  padding: 6px 0 40px;
}

.home-panel {
  padding: 26px 32px 30px;
}

.home-panel-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.home-panel-head .mini-label {
  margin-bottom: 6px;
}

.home-panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.42rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
}

/* Beskrivningarna under panelrubrikerna läses, inte skummas –
   de får därför serif och en kortare radbredd. */
.home-panel-head .hint {
  margin-top: 10px;
  max-width: 56ch;
  font-family: var(--display);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.home-page .data-panel {
  margin-top: 24px;
  padding: 22px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- Startvy ---------- */

.hero {
  max-width: 860px;
  padding: 64px 0 48px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.21em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.85rem, 5.9vw, 4.7rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.grad {
  color: var(--accent-deep);
  font-style: italic;
  font-weight: 400;
}

.lede {
  max-width: 52ch;
  margin: 24px 0 0;
  font-family: var(--display);
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.setup-card {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: 30px 40px;
  padding: 32px;
}

.field {
  min-width: 0;
}

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

.field-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.step {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.preset {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.preset:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.preset-time {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.preset-time span {
  margin-left: 3px;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

.preset-tag {
  font-size: 11px;
  color: var(--muted);
}

.preset.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.preset.active .preset-time {
  color: var(--accent-deep);
}

.preset.active .preset-tag {
  color: var(--ink-soft);
}

/* ---------- Pausval ---------- */

.field-wide {
  grid-column: 1 / -1;
}

.break-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.break-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.break-chip:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.break-icon {
  font-size: 16px;
  line-height: 1.2;
}

.break-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.break-title {
  font-size: 13px;
  font-weight: 600;
}

.break-text {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.break-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.break-chip.active .break-title {
  color: var(--accent-deep);
}

.break-chip.active .break-text {
  color: var(--ink-soft);
}

.break-custom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.break-custom[hidden] {
  display: none;
}

.break-custom span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.break-custom input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
}

.break-custom input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.study-type {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.study-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.study-chip:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.study-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.study-chip-title {
  font-size: 13px;
  font-weight: 600;
}

.study-chip-note {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.study-chip.active .study-chip-title {
  color: var(--accent-deep);
}

.language-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.language-row[hidden] {
  display: none;
}

.language-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.language-row select {
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
}

.language-row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field .hint {
  margin-top: 12px;
}

#materialInput {
  width: 100%;
  min-height: 190px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.94rem;
  line-height: 1.65;
  resize: vertical;
}

#materialInput::placeholder {
  color: var(--muted);
}

#materialInput:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.material-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.setup-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  grid-column: 1 / -1;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* Stats och Today är egna menysidor – korten behöver ingen extra luft upptill. */
.home-page[data-home-page="stats"] .stats-row {
  margin-top: 4px;
}

.home-page[data-home-page="today"] .today {
  margin-top: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 22px 20px 0;
  border-right: 1px solid var(--line);
}

.stat + .stat {
  padding-left: 22px;
}

.stat:last-child {
  border-right: 0;
}

.stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---------- Grafer på statistsidan ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.chart-card {
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-head h3 {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
}

.chart-badge {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  height: 132px;
  padding-top: 4px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to top, var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
  background-position: 0 100%;
}

.chart-bar {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.chart-bar:hover,
.chart-bar.is-today {
  opacity: 1;
}

.chart-days {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
}

.chart-day {
  font-size: 9px;
  line-height: 1;
  text-align: center;
  color: var(--muted);
}

.chart-day.is-today {
  color: var(--accent-deep);
  font-weight: 700;
}

.chart-line {
  height: 132px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to top, var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
  background-position: 0 100%;
}

.chart-line svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-area {
  fill: var(--accent);
  opacity: 0.16;
}

.chart-stroke {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-foot {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.chart-trend {
  margin-top: 3px;
}

/* ---------- Dagens mål, vecka & data ---------- */

.today {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 24px 40px;
  margin-top: 32px;
  padding: 26px 32px 28px;
}

.today-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  grid-column: 1 / -1;
}

.today-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 700;
}

.today-head .mini-label {
  margin-bottom: 6px;
}

.goal-picker {
  display: flex;
  gap: 6px;
}

.goal-chip {
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.goal-chip:hover {
  background: var(--surface-2);
}

.goal-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.goal-line {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.goal-line strong {
  font-family: var(--display);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--ink);
}

.goal-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.goal-track > div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

.goal-block .hint {
  margin-top: 10px;
}

.week-block .mini-label {
  margin-bottom: 10px;
}

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

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.week-bar {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 66px;
  background: var(--surface-2);
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}

.week-bar > span {
  display: block;
  width: 100%;
  background: var(--line-strong);
  transition: height 0.3s ease;
}

.week-day.is-today .week-bar > span {
  background: var(--accent);
}

.week-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.week-value {
  font-size: 10px;
  color: var(--muted);
}

.week-day.is-today .week-label,
.week-day.is-today .week-value {
  color: var(--ink);
}

.data-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.data-copy .mini-label {
  margin-bottom: 6px;
}

.data-copy h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
}

.data-copy .hint {
  max-width: 62ch;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Passvy ---------- */

.session-grid {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 304px;
  align-items: start;
  gap: 24px;
}

.techniques {
  padding: 8px 0 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.techniques .mini-label {
  margin-bottom: 8px;
  padding-left: 12px;
}

.technique {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 2px;
  padding: 10px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.technique:hover {
  background: var(--surface-2);
}

.technique.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--ink);
}

.tech-icon {
  display: none;
}

.tech-body {
  min-width: 0;
}

.tech-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.tech-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.technique.active .tech-title {
  color: var(--accent-deep);
}

.tech-arrow {
  margin-left: auto;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--line-strong);
}

.technique.active .tech-arrow {
  color: var(--accent);
}

.session-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 20px;
  padding: 18px 12px 0;
  border-top: 1px solid var(--line);
}

.session-info .mini-label {
  margin-bottom: 0;
  padding-left: 0;
}

#sessionMeta {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.session-break {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--accent-deep);
}

.session-info .btn {
  margin-top: 6px;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  padding: 30px 32px 32px;
  border-top: 3px solid var(--accent);
}

.work-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.work-head .mini-label {
  margin-bottom: 6px;
}

.work-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
}

.pill {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.pill.good {
  color: var(--good);
  border-color: var(--good);
  background: var(--good-soft);
}

.bar {
  height: 3px;
  margin: 18px 0 24px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

/* Flashkort */

.flashcard {
  position: relative;
  display: block;
  width: 100%;
  height: 320px;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1400px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.3, 1);
}

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

.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.fc-back {
  background: var(--field-alt);
  transform: rotateY(180deg);
}

.fc-hint {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.fc-text {
  max-height: 175px;
  overflow-y: auto;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.fc-back .fc-text {
  font-family: var(--sans);
  font-size: 1.04rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--ink-soft);
}

.fc-tap {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  font-size: 10.5px;
  color: var(--muted);
}

.fc-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.fc-actions .btn {
  min-width: 150px;
}

/* Quiz */

.quiz-prompt {
  margin: 0 0 20px;
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.94rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quiz-option:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--ink);
}

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

.quiz-option.correct {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--ink);
}

.quiz-option.wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--ink);
}

.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.quiz-feedback {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.quiz-feedback.good {
  color: var(--good);
}

.quiz-feedback.bad {
  color: var(--bad);
}

/* Klar-vy / tomt läge */

.done-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 36px 10px 20px;
  text-align: center;
}

.done-emoji {
  display: none;
}

.done-box h3 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.25;
}

.done-box p {
  max-width: 48ch;
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--muted);
}

.done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 48ch;
  margin: 0 auto;
  padding: 40px 10px;
  text-align: center;
}

.empty-icon {
  display: none;
}

.empty h2 {
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
}

.empty p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--muted);
}

/* Läsning */

.summary-box {
  display: flex;
  gap: 14px;
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  background: var(--warm);
}

.summary-icon {
  display: none;
}

.summary-box strong {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.summary-box p {
  margin: 6px 0 0;
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--ink-soft);
}

.reader-text {
  flex: 1;
  max-height: 340px;
  margin-bottom: 20px;
  padding-right: 12px;
  overflow-y: auto;
  font-family: var(--display);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--ink-soft);
}

.reader-text p {
  margin: 0 0 16px;
}

.reader-text p:last-child {
  margin-bottom: 0;
}

.term-chips {
  margin-bottom: 20px;
}

.term-chips .mini-label {
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: transparent;
  font-size: 11px;
  color: var(--ink-soft);
}

.reader-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.read-done {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--good);
}

/* Begrepp */

.term-list {
  margin: 4px 0 0;
}

.term-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.term-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.term-item dt {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--ink);
}

.term-item dd {
  margin: 4px 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Timer ---------- */

.timer {
  position: sticky;
  top: 24px;
  padding: 24px 22px;
  text-align: center;
}

.timer .mini-label {
  margin-bottom: 4px;
}

.timer-ring {
  position: relative;
  width: 100%;
  max-width: 214px;
  aspect-ratio: 1;
  margin: 10px auto 6px;
}

.timer-ring svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 6;
}

.ring-bg {
  stroke: var(--ring-track);
}

.ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke 0.3s ease, stroke-dashoffset 0.3s linear;
}

.ring-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.phase {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.clock {
  font-family: var(--display);
  font-size: 2.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.block-label {
  font-size: 11px;
  color: var(--muted);
}

.timer.is-break .ring-fg {
  stroke: var(--good);
}

.timer.is-break .phase {
  color: var(--good);
}

.timer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.break-plan {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--plan-line);
  border-radius: 3px;
  background: var(--good-soft);
  text-align: left;
}

.break-plan[hidden] {
  display: none;
}

.break-plan .mini-label {
  margin-bottom: 3px;
  color: var(--good);
}

.break-plan strong {
  display: block;
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.25;
  color: var(--ink);
}

.dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 6px;
  margin-top: 18px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.2s ease;
}

.dot.done {
  background: var(--accent);
}

.dot.current {
  background: var(--ink);
}

.session-xp {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.session-xp strong {
  color: var(--ink);
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 340px;
  padding: 11px 14px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.xp {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
}

.toast.level {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: var(--cream);
  font-weight: 600;
}

/* ---------- Animationer ---------- */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Responsivt ---------- */

@media (max-width: 1180px) {
  .session-grid {
    grid-template-columns: minmax(0, 1fr) 292px;
    grid-template-areas:
      "work timer"
      "tech tech";
  }

  .techniques { grid-area: tech; margin-top: 4px; }
  .workspace { grid-area: work; }
  .timer { grid-area: timer; }

  #techniqueList {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .technique {
    min-width: 176px;
    margin-bottom: 0;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: 3px 3px 0 0;
  }

  .technique.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .session-info {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
  }

  .session-info .mini-label {
    display: none;
  }
}

@media (max-width: 980px) {
  .setup-card {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero {
    padding: 48px 0 40px;
  }
}

@media (max-width: 900px) {
  .session-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "timer"
      "work"
      "tech";
  }

  .timer {
    position: static;
  }

  .timer-ring {
    max-width: 200px;
  }

  .workspace {
    min-height: 520px;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 18px 16px 48px;
  }

  .topbar {
    gap: 16px;
    padding-bottom: 16px;
  }

  .level {
    width: 170px;
  }

  .hero {
    padding: 36px 0 32px;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 8vw, 3rem);
  }

  .lede {
    font-size: 0.98rem;
  }

  .setup-card {
    gap: 24px;
    padding: 24px 18px;
  }

  .presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .setup-actions .btn {
    width: 100%;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    margin-top: 32px;
  }

  .stat {
    padding: 16px 18px 16px 0;
    border-bottom: 0;
  }

  .stat + .stat {
    padding-left: 18px;
  }

  .stat:nth-child(odd) {
    padding-left: 0;
  }

  .stat:nth-child(even) {
    border-right: 0;
  }

  .stat:nth-child(1),
  .stat:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .session-grid {
    gap: 20px;
  }

  .workspace {
    min-height: 500px;
    padding: 22px 20px 24px;
  }

  .work-head h2 {
    font-size: 1.4rem;
  }

  .flashcard {
    height: 290px;
  }

  .fc-text {
    max-height: 155px;
    font-size: 1.32rem;
  }

  .fc-back .fc-text {
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 16px 14px 44px;
  }

  .brand {
    gap: 9px;
  }

  .brand-logo {
    height: 34px;
  }

  .level {
    flex: 0 0 auto;
    width: 138px;
  }

  .level-row {
    gap: 8px;
    margin-bottom: 6px;
    font-size: 10px;
  }

  .hero h1 {
    font-size: 2.15rem;
  }

  .eyebrow {
    gap: 8px;
    font-size: 10px;
    letter-spacing: 0.13em;
  }

  .eyebrow::before {
    width: 18px;
  }

  .preset-time {
    font-size: 1.3rem;
  }

  .preset-tag {
    font-size: 10px;
  }

  .stat {
    padding: 14px 12px 14px 0;
  }

  .stat + .stat {
    padding-left: 12px;
  }

  .stat:nth-child(odd) {
    padding-left: 0;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .workspace {
    padding: 20px 16px 22px;
  }

  .work-head {
    gap: 10px;
  }

  .pill {
    font-size: 9.5px;
  }

  .quiz-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-footer .btn,
  .done-actions .btn,
  .fc-actions .btn {
    width: 100%;
  }

  .fc-actions .btn {
    min-width: 0;
  }

  .toasts {
    left: 14px;
    right: 14px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 980px) {
  .today {
    grid-template-columns: 1fr;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .today {
    padding: 22px 18px;
  }

  .data-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .today-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .week-bar {
    height: 56px;
  }

  .data-actions {
    width: 100%;
  }

  .data-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 380px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .level {
    width: 100%;
  }

  .hero h1 {
    font-size: 2rem;
  }
}

/* ---------- Hemskärmens meny: smala skärmar ---------- */

@media (max-width: 980px) {
  .home-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .home-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-height: 0;
    margin: 0 -32px;
    padding: 10px 32px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .home-nav-foot {
    display: contents;
  }

  .home-nav::-webkit-scrollbar {
    display: none;
  }

  .home-nav-label,
  .home-nav-sep {
    display: none;
  }

  .home-nav-item {
    flex: 0 0 auto;
    width: auto;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12.5px;
    white-space: nowrap;
  }

  .home-nav-item.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-deep);
  }

  .home-layout .hero {
    padding: 16px 0 32px;
  }

  .home-panel {
    padding: 22px 18px 26px;
  }

  .home-page .data-panel {
    padding: 20px 18px;
  }
}

@media (max-width: 760px) {
  .home-nav {
    margin: 0 -16px;
    padding: 10px 16px;
  }
}

@media (max-width: 520px) {
  .home-nav {
    margin: 0 -14px;
    padding: 9px 14px;
  }

  .home-nav-item {
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* ---------- Rörelse & klickrespons ---------- */

.btn {
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
    transform 0.12s ease, box-shadow 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.96);
}

.btn.primary:hover:not(:disabled) {
  box-shadow: 0 7px 18px rgba(179, 78, 39, 0.24);
}

.btn.primary:active:not(:disabled) {
  box-shadow: 0 2px 7px rgba(179, 78, 39, 0.22);
}

.preset,
.goal-chip,
.quiz-option,
.technique,
.icon-btn,
.home-nav-item {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.12s ease;
}

.preset:active,
.goal-chip:active,
.quiz-option:active:not(:disabled),
.technique:active,
.icon-btn:active,
.home-nav-item:active {
  transform: scale(0.97);
}

/* Mjuk övergång när man byter menysektion */

.home-page:not([hidden]) {
  animation: pageIn 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Nytt innehåll i arbetsytan tonar in när man byter teknik eller går vidare */

.workspace > *:not(.flashcard) {
  animation: contentIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes contentIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.bar > div {
  transform-origin: left center;
  animation: barGrow 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes barGrow {
  from {
    transform: scaleX(0);
  }
}

/* Quiz: rätt och fel svar */

.quiz-option {
  position: relative;
}

.quiz-option.correct,
.quiz-option.wrong {
  padding-right: 44px;
}

.quiz-option.correct {
  animation: correctPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-option.wrong {
  animation: wrongShake 0.38s ease;
}

@keyframes correctPop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
}

.quiz-mark {
  position: absolute;
  top: 50%;
  right: 13px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--cream);
  animation: markIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-option.correct .quiz-mark {
  background: var(--good);
}

.quiz-option.wrong .quiz-mark {
  background: var(--bad);
}

@keyframes markIn {
  from {
    opacity: 0;
    transform: translateY(-50%) scale(0.4);
  }
}

.quiz-feedback {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: feedbackIn 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-feedback-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--cream);
}

.quiz-feedback.good .quiz-feedback-icon {
  background: var(--good);
}

.quiz-feedback.bad .quiz-feedback-icon {
  background: var(--bad);
}

@keyframes feedbackIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.xp-float {
  position: absolute;
  left: 0;
  bottom: calc(100% + 2px);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  animation: xpFloat 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes xpFloat {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.9);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-24px) scale(1);
  }
}

/* Resultat och XP-räknare */

.done-box h3 {
  animation: resultPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes resultPop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.session-xp strong {
  display: inline-block;
}

.session-xp strong.bump {
  animation: xpBump 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes xpBump {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.25);
    color: var(--accent-deep);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Laddning medan AI bygger studiematerialet ---------- */

body.is-generating {
  overflow: hidden;
}

.gen-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 33, 27, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.gen-overlay[hidden] {
  display: none;
}

.gen-card {
  width: min(360px, 100%);
  padding: 30px 26px 24px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(36, 33, 27, 0.18);
  text-align: center;
  animation: genCardIn 0.22s ease both;
}

.gen-rings {
  position: relative;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
}

.gen-rings span {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  animation: genPulse 1.8s ease-out infinite;
}

.gen-rings span:nth-child(2) {
  animation-delay: 0.6s;
}

.gen-rings span:nth-child(3) {
  animation-delay: 1.2s;
}

.gen-rings::after {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: var(--accent);
}

.gen-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.gen-text {
  min-height: 1.4em;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink);
}

.gen-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

@keyframes genPulse {
  from {
    transform: scale(0.55);
    opacity: 0.9;
  }
  to {
    transform: scale(1.15);
    opacity: 0;
  }
}

@keyframes genCardIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gen-rings span,
  .gen-card {
    animation: none;
  }
}

/* ---------- Roadmap: månadens väg ---------- */

.roadmap-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: stretch;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.roadmap-rank {
  --tier-1: #c98f5f;
  --tier-2: #7b4f2c;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 148px;
  padding: 14px 18px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--tier-1), var(--tier-2));
  color: #fff;
}

.roadmap-rank-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.8;
}

.roadmap-rank-name {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.1;
}

.roadmap-rank-sub {
  font-size: 11.5px;
  opacity: 0.88;
}

.roadmap-progress {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.roadmap-progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.roadmap-progress-row strong {
  font-family: var(--display);
  font-size: 1.1rem;
  color: var(--ink);
}

.roadmap-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.roadmap-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width 0.35s ease;
}

.roadmap-progress .hint {
  margin: 0;
}

.roadmap-path {
  margin: 0;
  padding: 22px 0 4px;
  list-style: none;
  display: grid;
  gap: 22px;
}

.roadmap-group {
  list-style: none;
}

.roadmap-group-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.roadmap-pill {
  --tier-1: #c98f5f;
  --tier-2: #7b4f2c;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tier-1), var(--tier-2));
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.roadmap-group-note {
  font-size: 11px;
  color: var(--muted);
}

.roadmap-levels {
  position: relative;
  margin: 0;
  padding: 12px 0;
  list-style: none;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.roadmap-levels::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 50%;
  border-left: 1px dashed var(--line-strong);
}

.roadmap-node {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
}

.roadmap-node:nth-child(odd) { transform: translateX(-30px); }
.roadmap-node:nth-child(even) { transform: translateX(30px); }

.roadmap-dot {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--field);
  color: var(--muted);
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
}

.roadmap-node.is-done .roadmap-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.roadmap-node.is-current .roadmap-dot {
  width: 52px;
  height: 52px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.roadmap-node.is-locked .roadmap-dot {
  opacity: 0.55;
}

@media (max-width: 620px) {
  .roadmap-summary {
    padding: 14px;
    gap: 14px;
  }

  .roadmap-node:nth-child(odd) { transform: translateX(-18px); }
  .roadmap-node:nth-child(even) { transform: translateX(18px); }
}
