/* Femman – eget formspråk: havre, tallgrönt och saffran */
:root {
  --bg: #F5F1E8;
  --surface: #FFFFFF;
  --surface-2: #EDE7DA;
  --ink: #1D2321;
  --muted: #66706B;
  --line: #E0D9CA;
  --primary: #1E5B4F;
  --primary-2: #2A7464;
  --on-primary: #F5F1E8;
  --accent: #E8A33D;
  --ok: #2F8F5B;
  --fail: #C8553D;
  --warm: #B7AE9C;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(29, 35, 33, .06), 0 4px 14px rgba(29, 35, 33, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111714;
  --surface: #1A2320;
  --surface-2: #24302C;
  --ink: #ECEDE6;
  --muted: #9AA59F;
  --line: #2E3A36;
  --primary: #5FB39E;
  --primary-2: #77C6B1;
  --on-primary: #0E1412;
  --accent: #F0B357;
  --ok: #57B884;
  --fail: #E07A61;
  --warm: #5C6661;
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111714; --surface: #1A2320; --surface-2: #24302C; --ink: #ECEDE6; --muted: #9AA59F;
    --line: #2E3A36; --primary: #5FB39E; --primary-2: #77C6B1; --on-primary: #0E1412;
    --accent: #F0B357; --ok: #57B884; --fail: #E07A61; --warm: #5C6661; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Toppfält */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; color: var(--primary); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.view { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + 96px + var(--safe-b)); outline: none; }

/* Flikfält */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg circle { fill: currentColor; stroke: none; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.3; }
body.in-focus .tabbar, body.in-focus .topbar { display: none; }

/* Kort och listor */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.hero { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.card.hero .muted { color: color-mix(in srgb, var(--on-primary) 75%, transparent); }
.card.tip { background: var(--surface-2); border-style: dashed; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.card.hero .eyebrow { color: var(--accent); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list a.row, .row-btn { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; color: inherit; text-decoration: none; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.chev::after { content: "›"; font-size: 1.4rem; color: var(--muted); line-height: 1; }
.plan-line { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed color-mix(in srgb, currentColor 22%, transparent); }
.plan-line:last-child { border-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-s); padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--muted); }

/* Knappar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--primary);
  background: var(--primary); color: var(--on-primary); font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #2A1F0B; }
.btn.danger { background: transparent; color: var(--fail); border-color: var(--fail); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.card.hero .btn { background: var(--accent); border-color: var(--accent); color: #2A1F0B; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row > .btn { flex: 1 1 140px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .875rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; }

/* Formulär */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--warm); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.stepper input { width: 96px; text-align: center; font-weight: 700; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-radius: var(--radius-s); margin-bottom: 10px; cursor: pointer; background: var(--surface); }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.choice input { margin-top: 4px; accent-color: var(--primary); }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-grid label { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.check-grid input { accent-color: var(--primary); }

/* Pass */
.workout-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.clock { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.ex-card { padding: 14px 14px 12px; }
.ex-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ex-title h3 { margin: 0; font-size: 1.05rem; }
.weight-btn {
  border: 0; border-radius: 999px; background: var(--surface-2); padding: 6px 12px; font-weight: 800; cursor: pointer;
  font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.ex-meta { font-size: .85rem; color: var(--muted); margin: 2px 0 10px; }
.sets { display: flex; flex-wrap: wrap; gap: 8px; }
.set {
  position: relative; width: 52px; height: 52px; border-radius: 14px;
  border: 2px dashed var(--warm); background: transparent; color: var(--muted);
  font-weight: 800; font-size: 1.15rem; cursor: pointer; touch-action: manipulation;
  display: grid; place-items: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  font-variant-numeric: tabular-nums;
}
.set small { position: absolute; bottom: -18px; left: 0; right: 0; font-size: .65rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.set.done { border: 2px solid var(--ok); background: var(--ok); color: #fff; }
.set.short { border: 2px solid var(--fail); background: var(--fail); color: #fff; }
.set.next { border-style: solid; border-color: var(--primary); color: var(--primary); }
.set.warm { width: 44px; height: 44px; border-radius: 50%; font-size: .9rem; }
.set.warm.done { background: var(--warm); border-color: var(--warm); color: var(--ink); }
.set .ow { position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.set-row-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 6px; }
.sets.has-labels { padding-bottom: 18px; }
.ex-actions { display: flex; gap: 14px; margin-top: 10px; font-size: .875rem; }
.badge { display: inline-block; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #2A1F0B; letter-spacing: .03em; }
.badge.soft { background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok); color: #fff; }
.badge.fail { background: var(--fail); color: #fff; }

/* Vilotimer */
.restbar {
  position: fixed; left: 12px; right: 12px; z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  max-width: 656px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 18px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.restbar[hidden], .toast[hidden] { display: none; }
.restbar .t { font-family: var(--mono); font-size: 1.6rem; font-weight: 800; min-width: 84px; }
.restbar .lbl { flex: 1; font-size: .8rem; line-height: 1.25; }
.restbar button { background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--bg); border: 0; border-radius: 10px; min-width: 44px; height: 40px; font-weight: 700; cursor: pointer; }
.restbar.over .t { color: var(--accent); }
.restbar .prog { position: absolute; left: 12px; right: 12px; bottom: 4px; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--bg) 20%, transparent); overflow: hidden; }
.restbar .prog i { display: block; height: 100%; background: var(--accent); }
body.in-focus .restbar { bottom: calc(16px + var(--safe-b)); }

/* Fokusläge */
.focus { min-height: calc(100vh - 40px); display: flex; flex-direction: column; gap: 14px; padding-top: env(safe-area-inset-top, 0px); }
.focus-top { display: flex; justify-content: space-between; align-items: center; }
.focus-ex { text-align: center; margin-top: 8px; }
.focus-ex h1 { font-size: 2.1rem; margin-bottom: 4px; }
.focus-weight { font-size: 3.4rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.focus-setinfo { color: var(--muted); font-weight: 700; margin-top: 6px; }
.focus-big {
  flex: 1; min-height: 200px; border: 0; border-radius: 28px; background: var(--primary); color: var(--on-primary);
  font-size: 2rem; font-weight: 900; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.focus-big span { font-size: 1rem; font-weight: 600; opacity: .85; }
.focus-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.focus-row .btn { min-height: 64px; font-size: 1.1rem; border-radius: 20px; }
.focus-plates { text-align: center; color: var(--muted); font-size: .9rem; }

/* Skivor */
.plates-vis { display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 120px; padding: 10px 0; overflow-x: auto; }
.plates-vis .sleeve { width: 30px; height: 12px; background: var(--warm); border-radius: 2px; }
.plates-vis .collar { width: 8px; height: 26px; background: var(--muted); border-radius: 2px; }
.plates-vis .shaft { width: 46px; height: 8px; background: var(--warm); }
.plate { border-radius: 4px; display: grid; place-items: center; color: #fff; font-size: .6rem; font-weight: 800; writing-mode: vertical-rl; flex: none; }
.plate-list { font-family: var(--mono); font-weight: 700; text-align: center; font-size: 1.1rem; }
.warm-table { width: 100%; border-collapse: collapse; }
.warm-table th, .warm-table td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.warm-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Diagram */
.chart-wrap { position: relative; }
canvas.chart { width: 100%; height: 220px; display: block; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); display: block; }
.heat i.on { background: var(--primary); }
.heat i.today { outline: 2px solid var(--accent); }
.heat-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: .65rem; color: var(--muted); text-align: center; margin-bottom: 4px; }
.week-bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.week-bars i { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 3px; opacity: .9; }
.week-bars i.zero { background: var(--surface-2); }

/* Ark (bottom sheet) */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 14, 12, .45); }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--warm); margin: 4px auto 14px; }
.sheet h2 { font-size: 1.25rem; }

.toast {
  position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; stroke: var(--warm); fill: none; stroke-width: 1.6; }
.cue-list { padding-left: 1.2em; margin: 0 0 10px; }
.cue-list li { margin-bottom: 6px; }
.ex-figure { display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.ex-figure svg { width: 140px; height: 110px; fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ex-figure svg .bar { stroke: var(--accent); stroke-width: 4; }
.ex-figure svg circle { fill: var(--primary); stroke: none; }
.search { margin-bottom: 12px; }
.noscript { padding: 20px; }

/* Guidesidor (webbplatsdelen) */
body.guide { background: var(--bg); }
.guide-header { background: var(--primary); color: var(--on-primary); }
.guide-header .inner { max-width: 960px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.guide-header .brand { color: var(--on-primary); }
.guide-header .brand-mark { color: var(--accent); }
.guide-nav { display: flex; gap: 6px 16px; flex-wrap: wrap; }
.guide-nav a { color: var(--on-primary); text-decoration: none; font-weight: 600; font-size: .95rem; opacity: .85; }
.guide-nav a[aria-current="page"] { opacity: 1; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--accent); text-decoration-thickness: 3px; }
.guide-main { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }
.guide-main h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.guide-main h2 { margin-top: 1.6em; font-size: 1.35rem; }
.guide-lead { font-size: 1.15rem; color: var(--muted); }
.guide-table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; background: var(--surface); border-radius: var(--radius-s); overflow: hidden; }
.guide-table th, .guide-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.guide-table th { background: var(--surface-2); font-size: .85rem; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.guide-footer { border-top: 1px solid var(--line); padding: 24px 20px; text-align: center; color: var(--muted); font-size: .875rem; }
.table-scroll { overflow-x: auto; }

@media (min-width: 760px) {
  .view { padding-top: 24px; }
  h1 { font-size: 1.9rem; }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: min(680px, 100%); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
