:root {
  --bg: #0d0f12;
  --panel: #171a1f;
  --line: #262a31;
  --text: #f2f3f5;
  --muted: #8b919b;
  --work: #ff5a36;
  --accent: #ff5a36;
  --rest: #2f8cff;
  --prep: #f2b72c;
  --done: #2fbf71;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.wrap {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.iconbtn { padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.back { padding: 8px 0; color: var(--muted); }

.warn { background: #3a2a0c; border: 1px solid #6b4d12; color: #ffd98a; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

.days { display: grid; gap: 8px; }
.day {
  display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.day.today { border-color: var(--accent); }
.day .d { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.day .n { font-size: 18px; font-weight: 650; }
.day .t { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; flex: none; margin-left: 12px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: #fff; margin-left: 6px; vertical-align: 2px; }

.sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.sec h2 { font-size: 17px; margin: 0 0 2px; display: flex; justify-content: space-between; gap: 8px; }
.sec h2 span { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.scheme { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.scheme b { color: var(--text); font-weight: 600; }
.free { color: var(--prep); }
.zone { border-top: 1px solid var(--line); padding: 8px 0; }
.zone .zt { font-weight: 650; font-size: 14px; }
.zone .zn { font-size: 13px; color: var(--muted); font-style: italic; }
.zone ul { margin: 4px 0 0; padding-left: 18px; }
.zone li { font-size: 15px; }
.startfrom { margin-top: 6px; font-size: 14px; color: var(--accent); padding: 6px 0; }

.cta {
  position: sticky; bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 100%; padding: 18px; border-radius: 16px; background: var(--accent); color: #fff;
  font-size: 19px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.opts { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 16px; font-size: 14px; color: var(--muted); }
.opts label { display: flex; gap: 6px; align-items: center; }

/* Runner */
.run {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--bg); transition: background-color .25s;
}
.run.work { background: color-mix(in srgb, var(--accent) 14%, #0d0f12); }
.run.rest { background: #0b1a2e; }
.run.prep { background: #2a210b; }
.run.finished { background: #0c2418; }
.run .bar { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); gap: 8px; }
.run .phase { margin-top: 18px; font-size: 15px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.run.work .phase { color: var(--accent); }
.run.rest .phase { color: var(--rest); }
.run.prep .phase { color: var(--prep); }
.run.finished .phase { color: var(--done); }
.run .clock {
  font-size: min(34vw, 30vh); font-weight: 750; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; margin: 4px 0 8px;
}
.run .title { font-size: 28px; font-weight: 750; line-height: 1.15; }
.run .exs { list-style: none; padding: 0; margin: 8px 0 0; font-size: 21px; }
.run .exs li { padding: 3px 0; }
.run .note { margin-top: 8px; font-size: 15px; color: var(--muted); font-style: italic; }
.run .spacer { flex: 1; }
.run .next { border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; font-size: 16px; color: var(--muted); }
.run .next b { color: var(--text); font-weight: 600; }
.progress { height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; margin: 12px 0; }
.progress > i { display: block; height: 100%; background: currentColor; opacity: .85; }
.run.work .progress { color: var(--accent); }
.run.rest .progress { color: var(--rest); }
.run.prep .progress { color: var(--prep); }
.ctrls { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 10px; }
.ctrls button { padding: 18px 0; border-radius: 14px; background: rgba(255,255,255,.08); font-size: 18px; font-weight: 650; }
.ctrls .main { background: var(--text); color: var(--bg); }
.x { font-size: 15px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.08); }

/* Install */
.steps { padding-left: 20px; }
.steps li { margin-bottom: 10px; }
.bm { display: inline-block; padding: 10px 14px; background: var(--accent); color: #fff; border-radius: 10px; font-weight: 700; text-decoration: none; }
textarea.code { width: 100%; height: 90px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 10px; font: 11px ui-monospace, Menlo, monospace; padding: 8px; }
.ok-msg { background: #0c2418; border: 1px solid #1d5a37; color: #9fe6bd; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

/* Flikar Veckan / Övningsbank */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; }
.tabs button { padding: 10px 0; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--line); color: var(--text); }
.tabs .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); padding: 1px 7px; border-radius: 10px; margin-left: 4px; }

/* Övningsbank */
.search { width: 100%; padding: 12px 14px; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; -webkit-appearance: none; }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 20px; font-size: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.grp { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
#blist .day { margin-bottom: 8px; }
.day .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.backup { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
.backup summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.backup .row { display: flex; gap: 8px; }
.backup label.iconbtn { cursor: pointer; }

.empty { text-align: center; padding: 40px 8px; }
.empty h2 { margin: 0 0 8px; }

/* ---------- Startsida ---------- */
.start .hero { padding: 28px 0 22px; }
.start .kicker { color: var(--muted); font-weight: 600; font-size: 15px; }
.start h1 { font-size: clamp(34px, 10vw, 48px); line-height: 1.02; letter-spacing: -0.03em; margin: 6px 0 10px; font-weight: 800; }
.start h1 .hl {
  background: linear-gradient(90deg, #ff5a36, #ff3d6e 45%, #f7a531);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 17px; color: #c9ccd2; margin: 0; }
.pgrid { display: grid; gap: 12px; }
@media (min-width: 560px) { .pgrid { grid-template-columns: 1fr 1fr; } }
.pcard {
  position: relative; text-align: left; width: 100%; overflow: hidden;
  padding: 18px 18px 16px; border-radius: 18px; border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent) 34%, transparent) 0%, transparent 60%),
    var(--panel);
  transition: transform .12s ease, border-color .12s ease;
}
.pcard:hover, .pcard:focus-visible { border-color: var(--accent); }
.pcard:active { transform: scale(.985); }
.pcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.ptag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.pname { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.ppep { color: #c9ccd2; font-size: 15px; margin: 4px 36px 12px 0; }
.pmeta { font-size: 13px; color: var(--muted); }
.pmeta b { color: var(--text); }
.parrow { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--accent); transition: transform .12s ease; }
.pcard:hover .parrow { transform: translate(4px, -50%); }
.pcard.is-soon { opacity: .92; }
.pcard .soon { display: inline-block; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); font-weight: 700; font-size: 12px; }
.foot { text-align: center; margin-top: 22px; }
.linkbtn { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.soonhero { padding: 24px 0; }
.soonhero h1 { font-size: 36px; letter-spacing: -0.02em; margin: 4px 0 10px; }
.soonhero .bm { margin-top: 8px; border: 0; }

/* ---------- Fritext (FF/HybridX) ---------- */
.fftext { white-space: pre-line; font-size: 15px; line-height: 1.5; border-top: 1px solid var(--line); padding-top: 10px; }
.runtext { white-space: pre-line; margin-top: 10px; font-size: 18px; line-height: 1.45; max-height: 34vh; overflow-y: auto; color: #e6e7ea; }
.run.open .clock { color: var(--accent); }
.run.open .phase { color: var(--accent); }
.ctrls button.done { background: var(--accent); color: #fff; }
.clock small { font-size: .3em; letter-spacing: 0; font-weight: 600; }
.day .dl { min-width: 0; }
.day .n { overflow-wrap: anywhere; }
