[hidden] { display: none !important; }
:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7684;
  --line: #e2e6ec;
  --brand: #1f3a5f;
  --brand-2: #2f6fb0;
  --ok: #2e9d62;
  --warn: #d98a1c;
  --bad: #c8463d;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --card: #1a212b; --ink: #e8edf3; --muted: #93a0b0; --line: #2a3340; --brand: #0f2238; --brand-2: #5a9ad8; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.topbar h1 { font-size: 1.1rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 1.8rem; line-height: 1; padding: 0 6px; cursor: pointer; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: #8a96a5; }
.conn.on { background: #4cd38a; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1rem; margin: 22px 4px 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h2:first-child { margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.space { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }

.device { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; border-top: 1px solid var(--line); }
.device:first-of-type { border-top: 0; }
.device .ico { font-size: 1.6rem; width: 36px; text-align: center; }
.device .info { flex: 1; min-width: 0; }
.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 1.4rem; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b3; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.badge.locked { background: #fde7e5; color: var(--bad); }
.badge.pending { background: #fff1db; color: #a26206; }
@media (prefers-color-scheme: dark) { .badge.locked { background: #3d1f1d; } .badge.pending { background: #3a2c14; color: #f2b45a; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }

.big-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big-toggle .label { font-weight: 700; font-size: 1.05rem; }

.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c3cad3; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--bad); }
.switch.green input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(22px); }

label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input.code { font-size: 1.6rem; letter-spacing: .2em; text-align: center; text-transform: uppercase; font-family: ui-monospace, monospace; }

.app { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.app:first-child { border-top: 0; }
.app .info { flex: 1; min-width: 0; }
.app .pkg { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.request { border-left: 4px solid var(--warn); }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tab { flex: 1; background: none; border: 0; padding: 8px 0 10px; font-size: .72rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 1.2rem; }
.tab.active { color: var(--brand-2); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222b36; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.tabs-inline { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs-inline button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.tabs-inline button.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }

video.scan { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 1; object-fit: cover; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.log-item { padding: 8px 0; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; }

/* ---------- Etapp 2 ---------- */
.today { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.today .big { font-size: 1.35rem; font-weight: 700; }
.today .left { font-size: .9rem; color: var(--muted); }
.bonus-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.bonus-btns .btn { padding: 7px 10px; font-size: .85rem; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.meter > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.meter.warn > i { background: var(--warn); }
.meter.over > i { background: var(--bad); }
table.week { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.week th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 2px; font-size: .78rem; }
table.week td { padding: 5px 2px; border-top: 1px solid var(--line); vertical-align: middle; }
table.week input[type=time], table.week input[type=number] { width: 100%; padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: .85rem; }
table.week .day { font-weight: 700; width: 40px; }
.bars { display: flex; gap: 6px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bars .area { flex: 1; width: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; }
.bars .bar { width: 100%; max-width: 34px; background: var(--brand-2); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .bar.over { background: var(--bad); }
.bars .lim { position: absolute; left: 8%; right: 8%; border-top: 2px dashed var(--warn); }
.bars .lbl { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.bars .val { font-size: .68rem; color: var(--muted); }
.app-bar { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.app-bar .name { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.app-bar .track { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.app-bar .track i { display: block; height: 100%; background: var(--brand-2); }
.app-bar .min { width: 64px; text-align: right; font-size: .82rem; color: var(--muted); }
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; font-size: .85rem; cursor: pointer; background: var(--card); }
.chip.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }

.dayrow { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.dayrow:first-child { border-top: 0; padding-top: 0; }
.dayrow .dname { font-weight: 700; width: 36px; padding-top: 8px; }
.dayrow .dgrid { flex: 1; display: grid; grid-template-columns: 88px 1fr; gap: 6px 8px; align-items: center; }
.dayrow .dgrid > span { font-size: .8rem; color: var(--muted); }
.dayrow .pair { display: flex; align-items: center; gap: 6px; }
.dayrow .pair b { font-weight: 400; color: var(--muted); font-size: .85rem; }
.dayrow input { flex: 1; min-width: 0; padding: 7px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: .9rem; }
.bars .val { white-space: nowrap; height: 16px; }
.dayrow .dgrid { grid-template-columns: 74px minmax(0, 1fr); }
.dayrow .dgrid > *, .dayrow .pair { min-width: 0; }
.dayrow input { width: 0; flex: 1 1 0; font-size: .85rem; padding: 7px 4px; }
.dayrow input[type=time]::-webkit-calendar-picker-indicator { margin-left: 0; padding: 0; }

.dayrow .win { margin-bottom: 8px; }
.dayrow .winmax { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.dayrow .winmax > span { font-size: .75rem; color: var(--muted); flex: none; }
.dayrow .hm input { max-width: 64px; }
.dayrow .dgrid { align-items: start; }
.dayrow .dgrid > span { padding-top: 9px; }
.dayrow .winmax .pair { flex: 1; }
.dayrow .hm input { min-width: 44px; max-width: 70px; flex: 1 1 0; }

/* Mobil: rubrik ovanför fälten så att tiderna får plats (t.ex. 19:30) */
.dayrow { flex-direction: column; gap: 4px; }
.dayrow .dname { width: auto; padding-top: 0; font-size: 1.05rem; }
.dayrow .dgrid { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.dayrow .dgrid > span { padding-top: 8px; font-weight: 600; }
.dayrow input[type=time] { min-width: 96px; font-size: .95rem; padding: 8px 6px; }
.dayrow .win { padding: 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; }
.dayrow .winmax > span { font-size: .72rem; line-height: 1.15; width: 84px; }

details.lockall > summary { list-style: none; cursor: pointer; }
details.lockall > summary::-webkit-details-marker { display: none; }
details.lockall[open] > summary { margin-bottom: 8px; }

.dayrow .dhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dayrow .copybox { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 6px 0; }

.modal { position: fixed; inset: 0; background: rgba(10, 16, 24, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }

/* ---------- Smidigare ---------- */
.tab em { font-style: normal; }
#view.enter { animation: viewIn .2s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.busy-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: #7cc4ff; z-index: 60; opacity: 0; pointer-events: none; }
.busy-bar.on { opacity: 1; width: 75%; transition: width 2.5s cubic-bezier(.1,.7,.3,1); }
.busy-bar.done { width: 100%; opacity: 0; transition: width .2s, opacity .3s .15s; }
.btn, .chip, .device, .tab, .profile-card { -webkit-tap-highlight-color: transparent; transition: transform .08s ease, background .15s, opacity .15s; }
.btn:active:not(:disabled), .chip:active, .device:active, .tab:active, .profile-card:active { transform: scale(.97); }
.toast.show { animation: toastIn .2s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.modal { animation: fadeIn .15s ease-out; }
.modal-box { animation: popIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } }
.modal-box input[type=text] { width: 100%; }
.fading { opacity: .4; pointer-events: none; }
.skeleton { min-height: 90px; background: linear-gradient(90deg, var(--card) 25%, var(--line) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton.tall { min-height: 220px; }
.skeleton-line { height: 14px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, var(--bg) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.badge.open { background: #e3f5ea; color: #1f7a47; }
@media (prefers-color-scheme: dark) { .badge.open { background: #173826; color: #6fd39b; } }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.invite-code { font-size: 1.6rem; font-family: ui-monospace, monospace; letter-spacing: .15em; margin: 6px 0; }
.lang-pick { margin: 18px auto 0; max-width: 220px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.hero { text-align: center; margin: 10px 0 18px; }
.hero-logo { font-size: 2.2rem; }
.hero-tag { color: var(--muted); font-size: .95rem; margin-top: 4px; }
.steps > div { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; font-size: .92rem; }
.steps b { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-2); color: #fff; font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Schemat ---------- */
.wk { display: flex; flex-direction: column; gap: 2px; }
.wk-row { display: grid; grid-template-columns: 40px 1fr 62px; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 8px; cursor: pointer; }
.wk-row.sel { background: color-mix(in srgb, var(--brand-2) 14%, transparent); }
.wk-day { font-weight: 700; font-size: .85rem; }
.wk-bar { position: relative; height: 18px; background: var(--line); border-radius: 6px; overflow: hidden; }
.wk-bar i { position: absolute; top: 0; bottom: 0; background: var(--ok); border-radius: 4px; min-width: 2px; }
.wk-bar i.school { background: var(--warn); top: auto; height: 6px; bottom: 0; opacity: .95; }
.wk-lim { font-size: .8rem; color: var(--muted); text-align: right; white-space: nowrap; }
.wk-axis { display: grid; grid-template-columns: 40px 1fr 62px; gap: 8px; padding: 0 4px; font-size: .68rem; color: var(--muted); }
.wk-axis div:nth-child(2) { display: flex; justify-content: space-between; }
.wk-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .76rem; color: var(--muted); margin-top: 8px; }
.wk-legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.wk.compact { margin-top: 8px; gap: 3px; }
.wk.compact .wk-row { grid-template-columns: 28px 1fr; padding: 0; cursor: inherit; }
.wk.compact .wk-day { font-size: .66rem; font-weight: 600; color: var(--muted); }
.wk.compact .wk-bar { height: 7px; border-radius: 4px; }
.wk.compact .wk-lim { display: none; }
.profile-card { cursor: pointer; }
.profile-card .name { font-weight: 700; }
.profile-card .meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.daypick { margin-bottom: 10px; }
.daypick .chip { min-width: 46px; text-align: center; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain:disabled .chip, fieldset.plain:disabled .btn { opacity: .55; pointer-events: none; }
.ed-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 4px; }
.note { background: #fff6e5; color: #8a5300; border-radius: 10px; padding: 8px 10px; font-size: .85rem; margin: 6px 0; }
@media (prefers-color-scheme: dark) { .note { background: #3a2c14; color: #f2c27a; } }
.ed-sec { padding: 14px 0 4px; border-top: 1px solid var(--line); margin-top: 10px; }
.ed-h { font-weight: 700; margin-bottom: 8px; }
.chip small { opacity: .7; margin-left: 3px; }
.presets { margin-bottom: 10px; }
.win-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.win-row input[type=time] { flex: 1; min-width: 0; padding: 11px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 1.05rem; text-align: center; }
.win-row.bad input { border-color: var(--bad); color: var(--bad); }
.win-row .dash { color: var(--muted); }
.btn.icon { padding: 9px 12px; flex: none; }
.win-max { margin: 0 0 12px 2px; font-size: .85rem; }
.win-max summary { color: var(--brand-2); cursor: pointer; padding: 4px 0; }
.win-max .chips { margin-top: 6px; }
.add-win { width: 100%; border-style: dashed; color: var(--brand-2); }
.locked-day { padding: 8px 0 10px; }
.hm-inline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.hm-inline input { width: 76px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 1rem; }
details.copy summary { cursor: pointer; color: var(--brand-2); font-weight: 600; }
input[type=time], input[type=number] { font: inherit; color: inherit; }

/* Internet */
.badge.net { background: #e6eefb; color: #2f6fb0; }
@media (prefers-color-scheme: dark) { .badge.net { background: #1b2c44; color: #8cb8ea; } }
.wk-bar i.net { background: var(--brand-2); top: 0; bottom: auto; height: 4px; border-radius: 2px; }
.wk-bar i.net.none { left: 0; width: 100%; background: repeating-linear-gradient(90deg, var(--bad) 0 6px, transparent 6px 10px); opacity: .6; }
