:root {
  --bg: #111111;
  --card: #1C1C1C;
  --line: #262626;
  --brown: #4A3530;
  --orange: #FF5A1F;
  --copper: #C94F26;
  --rust: #9E4328;
  --grey: #454545;
  --mid: #737373;
  --muted: #A3A3A3;
  --light: #D4D4D4;
  --white: #FFFFFF;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--white); }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange); text-decoration: none; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: calc(env(safe-area-inset-top) + 20px) 16px 16px 16px; display: flex; flex-direction: column; }
.screen.with-tabs { padding-bottom: calc(env(safe-area-inset-bottom) + 92px); }

/* Rubrik */
.top { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 4px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.3px; text-transform: uppercase; }
h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.pill { font-size: 15px; font-weight: 700; color: var(--orange); background: var(--brown); padding: 7px 12px; border-radius: 999px; border: none; }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--card); border: none; color: var(--light); font-weight: 700; font-size: 15px; }
.top-right { display: flex; gap: 8px; align-items: center; }

/* Widgetar */
.grid2 { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.span2 { grid-column: span 2; }
.card { background: var(--card); border-radius: 22px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card.brown { background: var(--brown); border-radius: 26px; padding: 16px 18px; }
.card.orange { background: var(--orange); color: #111111; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; }
.brown .label { color: var(--light); }
.orange .label { color: #111111; opacity: 0.8; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row.base { align-items: baseline; }
.big { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; line-height: 1.05; }
.mid { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.val { font-size: 17px; font-weight: 800; }
.sub { font-size: 13px; color: var(--muted); }
.brown .sub { color: var(--light); }
.orange .sub { color: #111111; font-weight: 500; }
.small { font-size: 11px; color: var(--muted); }
.accent { color: var(--orange); }
.grow { flex: 1; }

.pixel-big { width: 72px; height: 72px; border-radius: 14px; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12); flex: none; }
.scale { display: flex; align-items: center; gap: 8px; }
.scale .bars { flex: 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.scale .bars span { height: 14px; border-radius: 4px; }

.btn { height: 50px; border-radius: 14px; border: none; font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; width: 100%; }
.btn.dark { background: #111111; color: var(--white); height: 40px; border-radius: 12px; font-size: 15px; }
.btn.primary { background: var(--orange); color: #111111; }
.btn.ghost { background: var(--card); color: var(--white); }
.btn.link { background: none; color: var(--orange); height: 44px; font-size: 15px; font-weight: 600; }
.btn:disabled { opacity: 0.4; }

.weekpix { display: flex; gap: 5px; }
.weekpix span { flex: 1; height: 22px; border-radius: 5px; }

.yeargrid { display: grid; grid-template-columns: repeat(53, minmax(0, 1fr)); grid-template-rows: repeat(7, 5px); grid-auto-flow: column; gap: 1px; }
.yeargrid span { border-radius: 1px; }
.months { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days div { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.days span.box { width: 100%; height: 28px; border-radius: 7px; }

.bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > div { height: 5px; border-radius: 3px; }

/* Cellstatus */
.s-rest { background: var(--line); }
.s-missed { border: 1.5px solid var(--mid); }
.s-future { border: 1.5px dashed var(--grey); }
.s-today { border: 2px solid var(--orange); }
.s-before { background: #161616; }
.s-rest-future { background: var(--line); }

/* Segmentväljare med riktiga radioknappar */
.seg label { display: block; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; height: 40px; align-items: center; justify-content: center; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--light); }
.seg input:checked + span { background: var(--orange); color: #111111; }
.seg input:focus-visible + span { outline: 2px solid var(--white); outline-offset: 1px; }
.yeargrid .s-missed { border-width: 1px; border-color: var(--muted); }
.yeargrid .s-future, .yeargrid .s-rest-future { background: #161616; border: none; }
.yeargrid .s-today { border: none; box-shadow: 0 0 0 1px var(--orange); background: var(--line); }

/* Flikar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(17,17,17,0.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px) 0; z-index: 10; }
.tabs nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tabs button { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--muted); min-height: 44px; }
.tabs button.on { color: var(--orange); }
.tabs svg { width: 24px; height: 24px; }

/* Listor */
.list { background: var(--card); border-radius: 16px; padding: 0 16px; }
.list .item { display: flex; align-items: center; gap: 10px; min-height: 50px; border-bottom: 0.5px solid #333333; padding: 8px 0; }
.list .item:last-child { border-bottom: none; }
.section-title { margin: 22px 4px 6px 4px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; display: flex; justify-content: space-between; }

/* Formulär */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select { height: 48px; border-radius: 12px; border: 1px solid #333333; background: var(--card); padding: 0 14px; font-size: 17px; }
.field input:focus, .field select:focus { outline: 2px solid var(--orange); outline-offset: 0; border-color: transparent; }
.seg { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); background: var(--card); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { height: 40px; border: none; border-radius: 9px; background: transparent; font-size: 15px; font-weight: 600; color: var(--light); }
.seg button.on { background: var(--orange); color: #111111; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.error { color: #FF8A5C; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: none; background: var(--card); border-radius: 999px; padding: 9px 13px; font-size: 13px; color: var(--light); }

/* Passvy */
.session { align-items: center; text-align: center; }
.session .topbar { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.session .topbar button { background: none; border: none; color: var(--orange); font-size: 17px; padding: 8px 0; }
.progress { width: 100%; display: grid; gap: 4px; margin-top: 6px; }
.progress span { height: 4px; border-radius: 2px; background: var(--line); }
.progress span.done { background: var(--orange); }
.progress span.now { background: var(--white); }
.exname { margin: 6px 0 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.3px; }
.number { font-size: 136px; font-weight: 300; line-height: 1; letter-spacing: -6px; margin-top: 18px; font-variant-numeric: tabular-nums; }
.number.pb { color: var(--orange); }
.unit { font-size: 17px; color: var(--muted); }
.badge { font-size: 13px; font-weight: 700; color: #111111; background: var(--orange); padding: 7px 12px; border-radius: 999px; }
.controls { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; margin-top: 26px; }
.round { width: 84px; height: 84px; border-radius: 42px; border: 3px solid var(--bg); font-size: 34px; display: flex; align-items: center; justify-content: center; }
.round.minus { background: var(--grey); outline: 2px solid var(--grey); color: var(--white); }
.round.plus { background: var(--brown); outline: 2px solid var(--brown); color: var(--orange); }
.round.done { background: var(--orange); outline: 2px solid var(--orange); color: #111111; font-size: 16px; font-weight: 700; }
.dots { display: flex; gap: 10px; margin-top: 26px; }
.dots span { width: 10px; height: 10px; border-radius: 5px; background: var(--grey); }
.dots span.done { background: var(--orange); }
.dots span.now { background: var(--white); }
.nextcard { width: 100%; background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; text-align: left; margin-top: 16px; }
.timer-ring { margin-top: 24px; }

.sumrow { display: flex; justify-content: space-between; font-size: 16px; padding: 12px 0; border-bottom: 0.5px solid #333333; }
.sumrow:last-child { border-bottom: none; }

/* Året */
.monthgrid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 14px; row-gap: 12px; justify-items: center; }
.month { display: flex; flex-direction: column; gap: 4px; }
.month .mname { font-size: 12px; font-weight: 600; color: var(--light); }
.month .cells { display: grid; grid-template-columns: repeat(7, 11px); grid-auto-rows: 11px; gap: 3px; min-height: 81px; }
.month .cells span { border-radius: 3px; }
.stats { margin-top: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 20px; font-weight: 800; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 100px); background: var(--brown); color: var(--white); padding: 12px 16px; border-radius: 14px; font-size: 15px; font-weight: 600; z-index: 20; max-width: 90vw; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .round, .chip, .seg button { transition: transform 120ms ease-out, background-color 150ms ease-out; }
  .btn:active, .round:active, .chip:active { transform: scale(0.96); }
}
