/* MemPem */
:root {
  --fs: 1;
  --ink: #1A1A1A;
  --grey: #5E5E5E;
  --line: #BDBDBD;
  --bg: #F4F4F4;
  --dark: #2B2B2B;
  --btn: #4A4A4A;
  --red: #C8102E;
  --green: #2E8B3A;
  --kvall: #D3DBEC;
  --head: #333333;
  --headink: #FFFFFF;
}
* { box-sizing: border-box; }
html { font-size: calc(16px * var(--fs)); -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; background: var(--dark); }
body {
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
.muted { color: #CFCFCF; }
.light .muted, .kort .muted { color: #555; }
.small { font-size: 0.95rem; }
.msg { min-height: 1.2em; margin: 6px 0 0; font-size: 1rem; }
.msg.err { color: #FF8A80; }
.light .msg.err, .kort .msg.err { color: #B00020; }
.msg.ok { color: #1B5E20; }

/* ---------- knappar ---------- */
.btn { border: 2px solid transparent; border-radius: 14px; padding: 0 18px; min-height: 52px; font-size: 1.15rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn.big { width: 100%; min-height: 66px; font-size: 1.5rem; }
.btn.green { background: var(--green); color: #fff; }
.btn.white { background: #fff; color: var(--ink); border-color: #fff; }
.btn.ghost { background: transparent; color: #fff; border-color: #8A8A8A; }
.btn.ghostdark { background: #fff; color: var(--ink); border-color: var(--line); }
.btn:disabled { opacity: .5; }
.arr { width: 34px; height: 34px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.arr.mork { stroke: var(--ink); }

/* ---------- inloggning ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: auto; }
.dark { background: var(--dark); color: #fff; }
.login-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-logo img { border-radius: 22px; }
.login-box h1 { margin: 0; font-size: 2.6rem; letter-spacing: 1px; }
.login-box p { margin: 0; font-size: 1.1rem; }
#loginForm { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 10px; }
#loginForm label { font-weight: 700; font-size: 1.1rem; }
#loginForm input { height: 60px; border-radius: 14px; border: 2px solid #8A8A8A; font: inherit; font-size: 1.3rem; padding: 0 16px; user-select: text; -webkit-user-select: text; }

/* ---------- appens ram ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: #fff; }
#top { background: var(--head); color: var(--headink); padding: calc(12px + env(safe-area-inset-top)) 14px 14px; display: flex; flex-direction: column; gap: 10px; transition: background .2s; }
.row1, .row2 { display: flex; align-items: center; gap: 12px; }
.schema { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; background: #fff; color: var(--ink); border: 3px solid #D7D7D7; border-radius: 15px; padding: 5px 13px 5px 5px; min-height: 63px; }
.schema img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.schema img:not([src]) { display: none; }
.schema span { font-size: 1.93rem; font-weight: 700; letter-spacing: 1px; }
.schema small { font-size: 1rem; font-weight: 700; color: var(--grey); margin-left: auto; text-align: right; line-height: 1.15; }
.klocka { width: 74px; height: 74px; flex: none; padding: 0; border: 0; background: none; touch-action: manipulation; }
.klocka svg { width: 74px; height: 74px; }
.datum { flex: 1; line-height: 1.1; }
.r1 { font-size: 1.75rem; font-weight: 700; }
.r2 { font-size: 1.38rem; }
.idag { width: 59px; height: 59px; flex: none; border-radius: 16px; border: 2px solid #8E0E1E; background: var(--red); display: flex; align-items: center; justify-content: center; }
.idag svg { width: 31px; height: 31px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.idag.av { visibility: hidden; }

.heldag { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; background: #FFF7D6; border-bottom: 2px solid #E8D27A; }
.hd { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 6px 12px 6px 6px; font-size: 1.25rem; font-weight: 700; }
.hd img { width: 40px; height: 40px; }
.hd.varit { background: #E3E3E3; color: var(--grey); }

#main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative; background: var(--bg); touch-action: pan-y; }

#nav { background: var(--dark); padding: 12px 10px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.nb { flex: 1; height: 68px; border-radius: 14px; border: 2px solid #6A6A6A; background: var(--btn); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 1.1rem; font-weight: 700; padding: 0; max-width: 160px; }
#nav { justify-content: center; }
.nb .ic { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nb .alt { width: 36px; height: 36px; }
.nb.on { background: #fff; color: var(--ink); border-color: #fff; }
.nb.on .ic { stroke: var(--ink); }
.nb:disabled { opacity: .4; background: #3A3A3A; border-color: #4A4A4A; }

.offline { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); background: #333; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: .95rem; font-weight: 700; z-index: 5; }

/* ---------- dagvy: lista ---------- */
.lista { padding: 14px; display: flex; flex-direction: column; gap: 12px; max-width: 820px; margin: 0 auto; }
.kortH { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 18px; border: 3px solid var(--line); background: #fff; text-align: left; width: 100%; }
.kortH .bild { position: relative; width: 80px; height: 80px; flex: none; }
.kortH .bild img { width: 80px; height: 80px; object-fit: contain; border-radius: 10px; }
.kortH .txt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.kortH .t { font-size: 1.65rem; font-weight: 700; overflow-wrap: anywhere; }
.kortH .s { font-size: 1.4rem; }
.kortH .tag { position: absolute; top: 10px; right: 12px; display: flex; gap: 6px; align-items: center; }
.nu { background: var(--red); color: #fff; font-size: .95rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.klock { width: 26px; height: 26px; fill: none; stroke: var(--grey); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kortH.pagar { border: 4px solid var(--red); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.varit { background: #E3E3E3 !important; border-color: #C4C4C4 !important; color: var(--grey); }
.varit .bild img, .varit img.ik { opacity: .5; }
.kryss { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.kryss path { stroke: #4A4A4A; stroke-width: 3; }
.tom { padding: 40px 20px; text-align: center; font-size: 1.4rem; color: var(--grey); }

/* ---------- dagvy: prickar (tidslinje) ---------- */
.tl { position: relative; background: #fff; }
.band { position: absolute; left: 0; right: 0; }
.band.kvall { background: var(--kvall); }
.band.natt { background: #000; }
.bandtxt { position: absolute; right: 8px; max-width: 84px; font-size: .85rem; font-weight: 700; text-align: right; line-height: 1.25; z-index: 1; }
.timme { position: absolute; left: 0; width: 84px; border-top: 2px solid #B8B8B8; padding: 2px 0 0 12px; font-size: 1.65rem; font-weight: 700; line-height: 1.2; }
.timme.n { color: #fff; border-color: #555; }
.prick { position: absolute; left: 66px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ink); }
.prick.v { background: #fff; }
.prick.n { background: #1E88E5; border-color: #1E88E5; }
.prick.nu { background: var(--red); border-color: var(--red); }
.tlh { position: absolute; border-radius: 16px; border: 3px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; overflow: hidden; z-index: 2; }
.tlh .t { font-size: 1.2rem; font-weight: 700; text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tlh .bild { position: relative; width: 72px; height: 72px; flex: none; }
.tlh { justify-content: flex-start; }
.tlh .bild img { width: 100%; height: 100%; object-fit: contain; }
.tlh.pagar { border: 4px solid var(--red); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.stapel { position: absolute; width: 8px; border-radius: 4px; background: #6E6E6E; z-index: 2; }
.stapel.pagar { background: var(--green); }
.nulinje { position: absolute; left: 0; right: 0; height: 3px; background: var(--red); z-index: 3; pointer-events: none; }
.nutid { position: absolute; right: 10px; background: var(--red); color: #fff; font-size: .95rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; z-index: 3; }

/* ---------- veckovy ---------- */
.vecka { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 8px 6px; min-height: 100%; background: #fff; }
.vd { display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; min-width: 0; }
.vd.today { outline: 3px solid var(--ink); outline-offset: -3px; }
.vd.ons { box-shadow: inset 0 0 0 1px #C4C4C4; }
.vdh { text-align: center; padding: 6px 0; line-height: 1.05; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vdh .n { font-size: 1.3rem; font-weight: 700; }
.vdh .w { font-size: 1rem; font-weight: 700; }
.vdh img { width: 36px; height: 36px; border-radius: 8px; border: 2px solid #fff; object-fit: cover; }
.vdh .sch { font-size: .8rem; font-weight: 700; }
.vdi { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 12px; }
.vb { position: relative; width: min(48px, 92%); aspect-ratio: 1; padding: 3px; border-radius: 9px; border: 2px solid #9E9E9E; background: #fff; }
.vb img { width: 100%; height: 100%; object-fit: contain; }
@media (min-width: 700px) { .vb { width: min(76px, 92%); } .vdh img { width: 52px; height: 52px; } }

/* ---------- mat ---------- */
.mat { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 100%; max-width: 820px; margin: 0 auto; }
.mr { flex: 1; min-height: 92px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 10px 16px; border-radius: 16px; }
.mr.today { outline: 3px solid var(--ink); outline-offset: -3px; }
.mr .d { align-self: flex-start; font-size: 1.05rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.mr .f { font-size: 1.75rem; font-weight: 700; overflow-wrap: anywhere; }

/* ---------- detalj och inställningar ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: #fff; }
.overlay.dark { background: var(--dark); align-items: center; justify-content: center; padding: 24px; }
#dHead { padding: calc(18px + env(safe-area-inset-top)) 20px 18px; }
.dbody { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 28px 24px 20px; }
.dbody h1 { margin: 0; font-size: 2.5rem; text-align: center; overflow-wrap: anywhere; }
.dbild { width: min(280px, 70vw); aspect-ratio: 1; border-radius: 28px; border: 4px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.dbild img { width: 82%; height: 82%; object-fit: contain; }
.dtider { display: flex; gap: 12px; width: 100%; max-width: 520px; }
.dtid { flex: 1; background: #fff; border: 2px solid #D0D0D0; border-radius: 16px; padding: 10px 12px; text-align: center; }
.dtid .lbl { font-size: 1rem; font-weight: 700; color: #555; }
.dtid .val { font-size: 2.1rem; font-weight: 700; }
.dtext { margin: 0; font-size: 1.4rem; line-height: 1.4; text-align: center; white-space: pre-line; max-width: 600px; overflow-wrap: anywhere; }
.foot { background: var(--dark); padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }

.light { background: var(--bg); }
.insthead { background: var(--head); color: #fff; padding: calc(20px + env(safe-area-inset-top)) 20px 18px; }
.insthead h1 { margin: 0; font-size: 1.9rem; }
.instbody { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; width: 100%; margin: 0 auto; }
.kort { background: #fff; border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.kort h2 { margin: 0; font-size: 1.25rem; }
.kort p { margin: 0; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg button { height: 56px; border-radius: 14px; border: 3px solid var(--line); background: #fff; font-size: 1.35rem; font-weight: 700; }
.seg button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.fsrow { display: flex; align-items: center; gap: 10px; }
.fsb { width: 60px; height: 60px; border-radius: 14px; border: 3px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; }
.fsb.big { font-size: 28px; }
.fssteg { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.fssteg span { height: 12px; border-radius: 6px; background: #D0D0D0; }
.fssteg span.on { background: var(--ink); }
.fsprov { border: 2px dashed #C4C4C4; border-radius: 14px; padding: 10px 14px; }
.fsprov .t { font-size: 1.65rem; font-weight: 700; }
.fsprov .s { font-size: 1.4rem; }
.swrow { display: flex; align-items: center; gap: 14px; }
.swrow > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch { width: 72px; height: 42px; border-radius: 999px; border: 0; background: #9E9E9E; position: relative; flex: none; }
.switch span { position: absolute; left: 4px; top: 4px; width: 34px; height: 34px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"] span { left: 34px; }
.tidrow { display: flex; align-items: center; gap: 10px; }
.tidrow label { flex: 1; font-size: 1.15rem; font-weight: 700; }
.tidrow select { width: 130px; height: 50px; border-radius: 12px; border: 2px solid var(--line); font: inherit; font-size: 1.35rem; font-weight: 700; padding: 0 10px; background: #fff; color: var(--ink); }
.knapprad { display: flex; flex-wrap: wrap; gap: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + env(safe-area-inset-bottom)); background: #111; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 40; }

/* 0.2 */
#top.matvy .row1 { display: none; }
.band.morgon { background: #F4C7CC; }
.vd { position: relative; }
.vdh { position: relative; border: 0; width: 100%; font: inherit; cursor: pointer; }
.vd.bred .vb { width: min(76px, 80%); }
.vd.bred .vdh img { width: 48px; height: 48px; }
.vd.bred .vdh .n { font-size: 1.6rem; }
.dagkryss { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dagkryss path { stroke: #7A7A7A; stroke-width: 2.5; }
.dagkryss path { stroke: #4A4A4A; }

/* 0.4: utan Sover-kalender (ingen PEM/MEM-ruta) står klockan på datumraden, Idag till vänster om den */
#top.utanSover .row1 { display: none; }
#top.utanSover .row2 .klocka { width: 66px; height: 66px; }
#top.utanSover .row2 .klocka svg { width: 66px; height: 66px; }
#top.matvy.utanSover .row2 .klocka { display: none; }
.mr .d small { font-weight: 700; opacity: .8; margin-left: 6px; }
#loginForm input[type=email] { text-transform: none; }

/* 0.3 */
.kortH .tag { position: static; align-self: flex-start; flex: none; }
.kortH .t, .tlh .t, .dbody h1 { text-wrap: balance; }
.tlh .t { flex: none; }
.tlh .bild { flex: 0 1 auto; min-height: 0; }
.vhel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; background: #FFF7D6; border-bottom: 2px solid #E8D27A; }
.dnotis { margin: -8px 0 0; display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 700; color: #444; }
.dnotis svg { width: 28px; height: 28px; fill: none; stroke: #444; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
