/* ============ Material 3 – mörkt tema ============ */
:root {
    color-scheme: dark;
    --md-primary: #a8c8ff;
    --md-on-primary: #05305f;
    --md-primary-container: #244777;
    --md-on-primary-container: #d6e3ff;
    --md-secondary: #bdc7dc;
    --md-secondary-container: #3e4759;
    --md-on-secondary-container: #d9e3f8;
    --md-tertiary: #dcbce1;
    --md-tertiary-container: #573e5c;
    --md-on-tertiary-container: #f9d8fe;
    --md-error: #ffb4ab;
    --md-on-error: #690005;
    --md-error-container: #93000a;
    --md-on-error-container: #ffdad6;
    --md-rec: #ff5449;
    --md-surface: #111318;
    --md-surface-container-lowest: #0c0e13;
    --md-surface-container-low: #191c20;
    --md-surface-container: #1d2024;
    --md-surface-container-high: #282a2f;
    --md-surface-container-highest: #33353a;
    --md-on-surface: #e2e2e9;
    --md-on-surface-variant: #c4c6d0;
    --md-outline: #8e9099;
    --md-outline-variant: #44474e;
    --md-inverse-surface: #e2e2e9;
    --md-inverse-on-surface: #2e3036;
    --md-inverse-primary: #3d5f90;

    --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 28px; --r-full: 999px;
    --elev-1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
    --elev-2: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px 2px rgba(0,0,0,.15);
    --elev-3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.3);
    --ease: cubic-bezier(.2, 0, 0, 1);
    --ease-decel: cubic-bezier(.05, .7, .1, 1);
    --font: 'Roboto Flex', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Roboto Mono', ui-monospace, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--md-surface);
    color: var(--md-on-surface);
    font: 400 14px/20px var(--font);
    letter-spacing: .25px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--md-primary); }
[hidden] { display: none !important; }
::selection { background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* Typografi */
.headline-medium { font-size: 28px; line-height: 36px; font-weight: 400; margin: 0; }
.headline-small { font-size: 24px; line-height: 32px; font-weight: 400; margin: 0; }
.title-large { font-size: 22px; line-height: 28px; font-weight: 400; }
.title-medium { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; }
.title-small { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; }
.body-medium { font-size: 14px; line-height: 20px; margin: 0; }
.body-small { font-size: 12px; line-height: 16px; letter-spacing: .4px; }
.label-large { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; }
.label-medium { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .5px; }
.muted { color: var(--md-on-surface-variant); }
.accent { color: var(--md-primary); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.ms {
    font-family: 'Material Symbols Rounded';
    font-weight: normal; font-style: normal;
    font-size: 24px; line-height: 1;
    display: inline-block; white-space: nowrap; direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
    user-select: none;
    transition: font-variation-settings .2s var(--ease);
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* State layer + ripple */
.sl { position: relative; overflow: hidden; isolation: isolate; }
.sl::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    background: currentColor; opacity: 0; pointer-events: none;
    transition: opacity .15s linear; z-index: -1;
}
.sl:hover::before { opacity: .08; }
.sl:focus-visible::before, .sl:active::before { opacity: .12; }
.sl:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
.ripple {
    position: absolute; border-radius: 50%; pointer-events: none;
    background: currentColor; opacity: .16; transform: scale(0);
    animation: ripple .55s var(--ease-decel) forwards; z-index: -1;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Knappar */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 24px 0 16px; border-radius: var(--r-full);
    font-weight: 500; font-size: 14px; letter-spacing: .1px; text-decoration: none;
    transition: box-shadow .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
    white-space: nowrap;
}
.btn .ms { font-size: 18px; }
.btn.filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn.filled:hover { box-shadow: var(--elev-1); }
.btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn[aria-disabled="true"] { opacity: .38; pointer-events: none; }
.btn.big { height: 56px; border-radius: var(--r-lg); font-size: 16px; padding: 0 24px; width: 100%; }
.btn.big .ms { font-size: 22px; transition: transform .3s var(--ease); }
.btn.big:hover .ms { transform: translateX(4px); }
.btn.loading { pointer-events: none; }
.btn.loading .ms { animation: spin 1s linear infinite; transform: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
    width: 40px; height: 40px; border-radius: var(--r-full);
    display: inline-grid; place-items: center; color: var(--md-on-surface-variant);
    transition: background .2s var(--ease), color .2s var(--ease), opacity .2s;
    flex: none;
}
.icon-btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.icon-btn:disabled { opacity: .38; cursor: default; }
.icon-btn:disabled::before { display: none; }

/* ============ Inloggning ============ */
body.login {
    display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px;
    overflow: hidden; position: relative;
}
.aurora { position: fixed; inset: 0; z-index: 0; filter: blur(90px) saturate(130%); opacity: .55; }
.aurora i { position: absolute; border-radius: 50%; display: block; }
.aurora i:nth-child(1) { width: 52vmax; height: 52vmax; left: -14vmax; top: -18vmax; background: #244777; animation: drift1 22s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 42vmax; height: 42vmax; right: -12vmax; bottom: -16vmax; background: #573e5c; animation: drift2 26s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { width: 26vmax; height: 26vmax; left: 45%; top: 55%; background: #1c5a61; opacity: .7; animation: drift3 18s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(14vmax, 10vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-12vmax, -8vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(-20vmax, -24vmax) scale(1.25); } }
.grid-overlay {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
.login-card {
    position: relative; z-index: 1; width: min(440px, 100%);
    background: color-mix(in srgb, var(--md-surface-container) 82%, transparent);
    backdrop-filter: blur(24px) saturate(140%); -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid color-mix(in srgb, var(--md-outline-variant) 60%, transparent);
    border-radius: var(--r-xl); padding: 36px 32px 24px;
    box-shadow: 0 24px 64px rgba(0,0,0,.45), var(--elev-3);
    animation: rise .6s var(--ease-decel) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.login-brand { display: flex; gap: 16px; align-items: center; margin-bottom: 28px; }
.login-brand p { margin-top: 2px; }
.brand-mark {
    position: relative; width: 56px; height: 56px; border-radius: var(--r-lg); flex: none;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--md-primary-container), #1b3a63);
    color: var(--md-on-primary-container); box-shadow: var(--elev-2);
}
.brand-mark .ms { font-size: 30px; }
.brand-mark.small { width: 40px; height: 40px; border-radius: var(--r-md); }
.brand-mark.small .ms { font-size: 22px; }
.rec-dot {
    position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--md-rec); box-shadow: 0 0 0 0 rgba(255,84,73,.6);
    animation: pulse 2s infinite;
}
.brand-mark.small .rec-dot { top: 5px; right: 5px; width: 6px; height: 6px; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,84,73,.6); }
    70% { box-shadow: 0 0 0 8px rgba(255,84,73,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,84,73,0); }
}
form { display: grid; gap: 16px; }
.banner {
    display: flex; gap: 12px; align-items: center; padding: 12px 16px; margin-bottom: 16px;
    border-radius: var(--r-md); animation: shake .4s var(--ease);
}
.banner.error { background: var(--md-error-container); color: var(--md-on-error-container); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* Filled text field med flytande etikett */
.field {
    position: relative; display: flex; align-items: center; height: 56px;
    background: var(--md-surface-container-highest);
    border-radius: var(--r-xs) var(--r-xs) 0 0; cursor: text;
    transition: background .2s var(--ease);
}
.field::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
    background: var(--md-on-surface-variant); transition: height .2s var(--ease), background .2s var(--ease);
}
.field:hover { background: color-mix(in srgb, var(--md-surface-container-highest) 92%, #fff); }
.field:focus-within::after { height: 2px; background: var(--md-primary); }
.field .lead { margin: 0 4px 0 12px; color: var(--md-on-surface-variant); transition: color .2s; }
.field:focus-within .lead { color: var(--md-primary); }
.field input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
    padding: 22px 12px 6px 8px; font-size: 16px; letter-spacing: .5px; caret-color: var(--md-primary);
}
.field .label {
    position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
    color: var(--md-on-surface-variant); font-size: 16px; pointer-events: none;
    transform-origin: left center; transition: all .2s var(--ease);
}
.field input:focus + .label,
.field input:not(:placeholder-shown) + .label { top: 15px; font-size: 12px; letter-spacing: .4px; }
.field input:focus + .label { color: var(--md-primary); }
.field .trail { margin-right: 4px; }
.field input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px var(--md-surface-container-highest) inset;
    -webkit-text-fill-color: var(--md-on-surface);
}
.login form .btn { margin-top: 8px; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; }
.login-foot .ms { font-size: 16px; }


/* ============ Fler knappvarianter ============ */
.btn.text { color: var(--md-primary); padding: 0 12px; }
.btn.filled.danger, .btn.danger.filled { background: var(--md-error); color: var(--md-on-error); }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.icon-btn.danger { color: var(--md-error); }
.icon-btn.tonal.danger { background: color-mix(in srgb, var(--md-error-container) 55%, transparent); color: var(--md-on-error-container); }
.icon-btn.on { background: var(--md-primary); color: var(--md-on-primary); }
.danger-text { color: var(--md-error); }
.center { text-align: center; }
.spin { animation: spin .8s linear infinite; }
.tag {
    display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--r-sm);
    background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag .ms { font-size: 15px; }
.tag.primary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.tag.danger { background: var(--md-error-container); color: var(--md-on-error-container); }
.banner.info { background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); margin: 0; animation: none; }
.banner.info .ms { color: var(--md-primary); }

/* ============ App-layout ============ */
body.app {
    display: grid; height: 100dvh; overflow: hidden;
    grid-template-columns: 88px minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
    grid-template-areas: "top top" "rail views";
}
.top-bar {
    grid-area: top; display: flex; align-items: center; gap: 4px; padding: 0 16px 0 24px; min-width: 0;
    background: var(--md-surface);
}
.brand { display: flex; align-items: center; gap: 14px; }
.spacer { flex: 1; }
.clock {
    font-variant-numeric: tabular-nums; color: var(--md-on-surface-variant);
    padding: 6px 14px; border-radius: var(--r-full); background: var(--md-surface-container); margin-right: 8px;
}
.account { position: relative; margin-left: 8px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: linear-gradient(135deg, var(--md-tertiary-container), var(--md-primary-container));
    color: var(--md-on-tertiary-container); font-weight: 500; font-size: 16px;
}
.avatar.static { width: 40px; height: 40px; }
.menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 50;
    background: var(--md-surface-container); border-radius: var(--r-sm); box-shadow: var(--elev-2);
    padding: 8px 0; transform-origin: top right; animation: menuIn .2s var(--ease-decel);
}
@keyframes menuIn { from { opacity: 0; transform: scale(.9) translateY(-6px); } }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 8px 16px 12px; border-bottom: 1px solid var(--md-outline-variant); margin-bottom: 8px; }
.menu form { display: block; }
.menu-item { display: flex; gap: 12px; align-items: center; width: 100%; height: 48px; padding: 0 16px; text-align: left; white-space: nowrap; }
.menu-item .ms { color: var(--md-on-surface-variant); }

/* Navigation rail */
.rail {
    grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 8px 0 16px; background: var(--md-surface); overflow-y: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-sep { width: 40px; height: 1px; background: var(--md-outline-variant); margin: 2px 0; flex: none; }
.rail-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px; width: 80px; flex: none;
    color: var(--md-on-surface-variant); font-size: 12px; font-weight: 500; letter-spacing: .5px; text-decoration: none;
}
.rail-label { max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .ind {
    position: relative; width: 56px; height: 32px; border-radius: var(--r-full);
    display: grid; place-items: center; transition: background .25s var(--ease); overflow: visible;
}
.rail-item .ind.sl::before { z-index: 0; }
.rail-item .ind .ms { position: relative; z-index: 1; }
.rail-item.active { color: var(--md-on-surface); }
.rail-item.active .ind { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.rail-item.active .ms { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.rail-item:hover .ind::before { opacity: .08; }
.rail-fav.active .ind { background: #5c4a00; color: #ffe08a; }
.badge {
    position: absolute; z-index: 2; top: -2px; left: 32px; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: var(--r-full); background: var(--md-error); color: var(--md-on-error);
    font-size: 11px; line-height: 16px; font-weight: 500; text-align: center;
    animation: pop .3s var(--ease-decel);
}
@keyframes pop { from { transform: scale(0); } }

/* Vyer */
.views { grid-area: views; min-height: 0; min-width: 0; position: relative; }
.view { height: 100%; overflow-y: auto; animation: viewIn .35s var(--ease-decel); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
.page { max-width: 1400px; margin: 0 auto; padding: 8px 24px 48px 12px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; padding: 8px 0 20px; }
.section-title { margin: 28px 0 12px; }
.card { background: var(--md-surface-container-low); border-radius: var(--r-xl); padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ============ Kameravy ============ */
.camera-view { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); overflow: hidden; }
.theater .camera-view { grid-template-columns: 0 minmax(0, 1fr); }
.theater .list-pane { visibility: hidden; margin: 0; }
.theater .stage { max-height: calc(100dvh - 180px); }

.list-pane {
    display: flex; flex-direction: column; min-height: 0; position: relative;
    background: var(--md-surface-container-low);
    border-radius: var(--r-xl) var(--r-xl) 0 0; margin-right: 12px; overflow: hidden;
    transition: margin .3s var(--ease);
}
.list-head { display: flex; align-items: flex-start; gap: 4px; padding: 20px 12px 8px 24px; }
.list-title { flex: 1; min-width: 0; }
.list-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-head #camSub { margin-top: 2px; }
.list-tools { display: flex; position: relative; margin-top: -2px; }
.list-tools .menu { top: 44px; }
.select-bar {
    display: flex; align-items: center; gap: 2px; padding: 14px 8px 10px 12px; min-height: 76px;
    background: var(--md-secondary-container); color: var(--md-on-secondary-container);
    animation: viewIn .25s var(--ease-decel);
}
.select-bar .icon-btn { color: inherit; }
.select-bar .icon-btn.danger { color: var(--md-error); }
.select-bar .title-medium { margin-left: 4px; }

.search {
    display: flex; align-items: center; gap: 4px; height: 48px; margin: 4px 16px 12px; padding: 0 4px 0 16px;
    background: var(--md-surface-container-high); border-radius: var(--r-full);
    transition: background .2s var(--ease), box-shadow .2s var(--ease);
}
.search.inline { margin: 0 0 16px; max-width: 480px; }
.search:focus-within { background: var(--md-surface-container-highest); box-shadow: inset 0 0 0 2px var(--md-primary); }
.search > .ms { color: var(--md-on-surface-variant); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0 8px; font-size: 16px; }
.search input::placeholder { color: var(--md-on-surface-variant); }
.search input::-webkit-search-cancel-button { display: none; }

.chips { display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chips.wrap { flex-wrap: wrap; padding: 8px 0 0; overflow: visible; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; height: 32px; padding: 0 16px; gap: 0; flex: none;
    border-radius: var(--r-sm); border: 1px solid var(--md-outline-variant);
    color: var(--md-on-surface-variant); font-weight: 500; white-space: nowrap;
    transition: background .2s var(--ease), padding .2s var(--ease), border-color .2s;
}
.chip .ms { font-size: 18px; width: 0; opacity: 0; transition: width .2s var(--ease), opacity .2s, margin .2s; }
.chip.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; padding-left: 8px; }
.chip.on .ms { width: 18px; opacity: 1; margin-right: 8px; }
.chip .count { margin-left: 6px; opacity: .7; font-variant-numeric: tabular-nums; }
.chip.date { background: var(--md-primary-container); color: var(--md-on-primary-container); padding-right: 6px; }
.chip.date .ms.close { margin: 0 0 0 6px; width: 18px; opacity: .8; }

.list {
    flex: 1; overflow-y: auto; min-height: 0; padding: 0 12px 24px; outline: none;
    scrollbar-width: thin; scrollbar-color: var(--md-outline-variant) transparent;
    overscroll-behavior: contain;
}
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 8px; border: 2px solid var(--md-surface-container-low); }
.group { content-visibility: auto; contain-intrinsic-size: auto 600px; }
.subheader {
    position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: baseline;
    padding: 14px 12px 8px; background: var(--md-surface-container-low);
    color: var(--md-primary); font-weight: 500; letter-spacing: .1px;
}
.subheader span:first-letter { text-transform: uppercase; }
.item {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 76px; padding: 8px 12px 8px 8px;
    border-radius: var(--r-lg); text-align: left; margin-bottom: 2px; cursor: pointer; user-select: none;
    transition: background .2s var(--ease);
    animation: itemIn .35s var(--ease-decel) both;
}
@keyframes itemIn { from { opacity: 0; transform: translateY(6px); } }
.item.sel { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.item.checked { background: color-mix(in srgb, var(--md-primary-container) 70%, transparent); }
.check {
    width: 0; height: 22px; flex: none; border-radius: 6px; display: grid; place-items: center; overflow: hidden;
    border: 2px solid var(--md-outline); opacity: 0; margin-right: -14px;
    transition: width .2s var(--ease), opacity .2s, margin .2s var(--ease), background .15s;
}
.check .ms { font-size: 16px; color: var(--md-on-primary); transform: scale(0); transition: transform .15s var(--ease); }
.selecting .check { width: 22px; opacity: 1; margin-right: 0; margin-left: 6px; }
.item.checked .check { background: var(--md-primary); border-color: var(--md-primary); }
.item.checked .check .ms { transform: scale(1); }
.thumb {
    position: relative; width: 96px; height: 60px; border-radius: var(--r-md); flex: none;
    display: grid; place-items: center; overflow: hidden;
    background: linear-gradient(145deg, var(--md-surface-container-highest), var(--md-surface-container-high));
    font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--md-on-surface);
    transition: background .25s var(--ease);
}
.thumb::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fadeIn .4s; }
@keyframes fadeIn { from { opacity: 0; } }
.thumb.has-img::after { background: linear-gradient(transparent 50%, rgba(0,0,0,.55)); }
.thumb.has-img .t { display: none; }
.thumb .dur {
    position: absolute; right: 4px; bottom: 4px; z-index: 1; padding: 1px 5px; border-radius: 4px;
    background: rgba(0,0,0,.7); color: #fff; font-size: 11px; line-height: 15px;
}
.item.sel .thumb:not(.has-img) { background: linear-gradient(145deg, var(--md-primary), #7fa6e6); color: var(--md-on-primary); }
.item.sel .thumb .t { opacity: 0; transform: scale(.6); }
.item.sel .thumb.has-img { box-shadow: 0 0 0 2px var(--md-primary); }
.thumb .t { transition: opacity .2s, transform .25s var(--ease); }
.thumb .eq { position: absolute; z-index: 2; display: flex; gap: 3px; align-items: flex-end; height: 18px; opacity: 0; transition: opacity .2s; }
.thumb.has-img .eq { color: #fff; filter: drop-shadow(0 1px 2px #000); }
.item.sel .thumb .eq { opacity: 1; }
.eq i { width: 4px; background: currentColor; border-radius: 2px; height: 30%; }
.playing .item.sel .eq i { animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s !important; height: 70%; }
.eq i:nth-child(3) { animation-delay: -.6s !important; height: 50%; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
.txt { flex: 1; min-width: 0; }
.txt .headline { display: flex; align-items: center; gap: 8px; font-size: 16px; line-height: 24px; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.txt .supporting { color: var(--md-on-surface-variant); font-size: 14px; line-height: 20px; }
.item.sel .txt .supporting, .item.sel .fname, .item.sel .note-line { color: inherit; opacity: .8; }
.fname { font-family: var(--mono); font-size: 11px; line-height: 16px; color: var(--md-outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-line { display: flex; gap: 4px; align-items: center; font-size: 12px; line-height: 16px; color: #ffe08a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-line .ms { font-size: 14px; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--md-primary); flex: none; box-shadow: 0 0 8px var(--md-primary); }
.fav-ic { font-size: 18px; color: #ffcf40; }
.item .trail { color: var(--md-on-surface-variant); opacity: 0; transition: opacity .2s, transform .2s var(--ease); transform: translateX(-4px); }
.item:hover .trail { opacity: 1; transform: none; }
.item.sel .trail, .selecting .item .trail { opacity: 0; }

.skeleton .item { pointer-events: none; animation: none; }
.skeleton .thumb, .skeleton .bar {
    background: linear-gradient(90deg, var(--md-surface-container-high) 0%, var(--md-surface-container-highest) 50%, var(--md-surface-container-high) 100%);
    background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.skeleton .thumb::after { display: none; }
.skeleton .bar { height: 12px; border-radius: 6px; margin: 6px 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty-state { display: grid; place-items: center; text-align: center; gap: 8px; padding: 64px 24px; color: var(--md-on-surface-variant); grid-column: 1 / -1; }
.empty-state .ms { font-size: 56px; color: var(--md-outline); margin-bottom: 8px; }
.empty-state.small { padding: 24px; }
.empty-state.small .ms { font-size: 32px; margin: 0; }

/* Kalender */
.calendar-pop {
    position: absolute; z-index: 20; top: 64px; right: 12px; width: 320px; padding: 12px;
    background: var(--md-surface-container-high); border-radius: var(--r-xl); box-shadow: var(--elev-3);
    transform-origin: top right; animation: menuIn .2s var(--ease-decel);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd span { text-align: center; font-size: 12px; color: var(--md-on-surface-variant); padding: 4px 0; }
.cal-day {
    position: relative; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.cal-day:disabled { opacity: .35; cursor: default; }
.cal-day:disabled::before { display: none; }
.cal-day i { position: absolute; bottom: 3px; font-style: normal; font-size: 9px; line-height: 10px; color: var(--md-on-surface-variant); }
.cal-day.lvl1 { background: rgba(57,135,229,.16); }
.cal-day.lvl2 { background: rgba(57,135,229,.30); }
.cal-day.lvl3 { background: rgba(57,135,229,.46); }
.cal-day.lvl4 { background: rgba(57,135,229,.64); }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--md-primary); }
.cal-day.on { background: var(--md-primary); color: var(--md-on-primary); }
.cal-day.on i { color: var(--md-on-primary); }
.cal-foot { display: flex; justify-content: flex-end; gap: 4px; padding-top: 8px; }

/* ============ Spelare ============ */
.player-pane { overflow-y: auto; min-height: 0; padding: 0 24px 24px 12px; }
.player-card { max-width: 1280px; margin: 0 auto; display: grid; gap: 16px; }
.stage {
    position: relative; aspect-ratio: 16 / 9; width: 100%; background: #000; outline: none;
    border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--elev-2);
    max-height: calc(100dvh - 300px); min-height: 200px; touch-action: none;
}
.stage:fullscreen { border-radius: 0; max-height: none; }
.zoom-layer { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.stage.zoomed { cursor: grab; }
.stage.panning { cursor: grabbing; }
.stage.idle { cursor: none; }
.stage video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; outline: none; }
.stage video:not([src]) { visibility: hidden; }
.stage-empty {
    position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center;
    background: radial-gradient(ellipse at center, #1a2230 0%, #07090c 70%);
}
.stage-empty .ms { font-size: 64px; color: var(--md-primary); opacity: .7; margin-bottom: 8px; }
.stage-chip {
    position: absolute; top: 16px; display: inline-flex; align-items: center; gap: 8px;
    height: 32px; padding: 0 12px; border-radius: var(--r-sm);
    background: rgba(17,19,24,.62); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    font-size: 13px; font-weight: 500; color: #fff; pointer-events: none;
    transition: opacity .3s var(--ease);
}
.stage-chip.left { left: 16px; }
.stage-chip.right { right: 16px; }
.stage.idle .stage-chip { opacity: 0; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--md-rec); animation: pulse 2s infinite; }
.zoom-chip {
    position: absolute; top: 60px; right: 16px; display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 4px 0 10px; border-radius: var(--r-full); color: #fff; font-size: 13px; font-weight: 500;
    background: rgba(36,71,119,.85); backdrop-filter: blur(12px);
}
.zoom-chip .ms { font-size: 18px; }
.zoom-chip button { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.flash {
    position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%;
    display: grid; place-items: center; background: rgba(0,0,0,.5); color: #fff; pointer-events: none; opacity: 0;
}
.flash .ms { font-size: 40px; }
.flash.show { animation: flash .6s var(--ease-decel); }
@keyframes flash { 0% { opacity: .9; transform: scale(.7); } 100% { opacity: 0; transform: scale(1.4); } }
.spinner {
    position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,.2); border-top-color: var(--md-primary); animation: spin .8s linear infinite; pointer-events: none;
}
.stage.shutter::after { content: ''; position: absolute; inset: 0; background: #fff; animation: shutter .35s ease-out forwards; pointer-events: none; }
@keyframes shutter { from { opacity: .7; } to { opacity: 0; } }

/* Kontroller */
.controls {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 32px 12px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,.75));
    color: #fff; transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.stage.idle .controls { opacity: 0; transform: translateY(12px); pointer-events: none; }
.seek { position: relative; height: 20px; cursor: pointer; touch-action: none; margin: 0 6px; }
.seek-track { position: absolute; left: 0; right: 0; top: 8px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; transition: height .15s, top .15s; }
.seek:hover .seek-track, .seek.active .seek-track { top: 7px; height: 6px; }
.seek-buffer { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.35); }
.seek-fill { position: absolute; inset: 0 auto 0 0; background: var(--md-primary); }
.seek-thumb {
    position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
    background: var(--md-primary); transform: scale(0); transition: transform .15s var(--ease);
}
.seek:hover .seek-thumb, .seek.active .seek-thumb { transform: scale(1.2); }
.seek-tip {
    position: absolute; bottom: 24px; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
    padding: 4px 8px; border-radius: 6px; background: rgba(17,19,24,.9); font-size: 12px;
}
.ctrl-row { display: flex; align-items: center; gap: 2px; }
.cbtn {
    min-width: 40px; height: 40px; border-radius: var(--r-full); display: inline-grid; place-items: center; color: #fff;
    font-size: 13px; font-weight: 500; padding: 0 6px; font-variant-numeric: tabular-nums;
}
.cbtn.on { color: var(--md-primary); }
.cbtn#cPlay .ms { font-size: 30px; }
.ctime { font-size: 13px; margin: 0 10px; white-space: nowrap; opacity: .9; }
.vol { display: flex; align-items: center; }
.vol input {
    -webkit-appearance: none; appearance: none; width: 0; height: 4px; border-radius: 2px; opacity: 0; cursor: pointer;
    background: linear-gradient(90deg, #fff var(--v, 100%), rgba(255,255,255,.3) var(--v, 100%));
    transition: width .2s var(--ease), opacity .2s, margin .2s;
}
.vol:hover input, .vol input:focus { width: 72px; opacity: 1; margin: 0 8px 0 2px; }
.vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.vol input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }

.player-info { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 4px 4px 0; flex-wrap: wrap; }
.meta { min-width: 0; flex: 1; }
.meta h1 { margin: 2px 0 10px; }
.info-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.info-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px;
    border-radius: var(--r-sm); background: var(--md-surface-container-high); color: var(--md-on-surface-variant);
    font-size: 13px; font-weight: 500; max-width: 100%;
}
.info-chip .ms { font-size: 18px; color: var(--md-primary); }
.info-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#favBtn.on { background: #5c4a00; color: #ffcf40; }

.note-card {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg);
    background: color-mix(in srgb, #5c4a00 35%, var(--md-surface-container-low)); animation: viewIn .3s var(--ease-decel);
}
.note-card > .ms { color: #ffcf40; margin-top: 2px; }
.note-card textarea {
    flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--md-on-surface);
    font: 400 15px/24px var(--font); min-height: 24px; overflow: hidden;
}
.note-card textarea::placeholder { color: var(--md-on-surface-variant); }
.note-card .body-small { margin-top: 5px; white-space: nowrap; }

.controls-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 12px 16px; border-radius: var(--r-xl); background: var(--md-surface-container-low);
}
.segmented { display: inline-flex; border: 1px solid var(--md-outline); border-radius: var(--r-full); overflow: hidden; }
.segmented.full { display: flex; }
.segmented.full button { flex: 1; }
.segmented button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; min-width: 44px; padding: 0 12px; font-weight: 500; font-size: 14px;
    border-right: 1px solid var(--md-outline); font-variant-numeric: tabular-nums;
    transition: background .2s var(--ease);
}
.segmented button .ms { font-size: 18px; }
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.switch-row { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.switch-row.spread { justify-content: space-between; }
.switch {
    appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer; flex: none;
    position: relative; width: 52px; height: 32px; border-radius: var(--r-full);
    background: var(--md-surface-container-highest); border: 2px solid var(--md-outline);
    transition: background .25s var(--ease), border-color .25s;
}
.switch::after {
    content: ''; position: absolute; top: 50%; left: 6px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--md-outline); transform: translateY(-50%);
    transition: all .25s var(--ease);
}
.switch:checked { background: var(--md-primary); border-color: var(--md-primary); }
.switch:checked::after { left: 22px; width: 24px; height: 24px; background: var(--md-on-primary); }
.switch:active::after { width: 28px; height: 28px; }
.switch:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }

.timeline-card { padding: 16px 20px 12px; border-radius: var(--r-xl); background: var(--md-surface-container-low); }
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.timeline {
    position: relative; height: 44px; border-radius: var(--r-sm);
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(100% / 24 - 1px), rgba(255,255,255,.05) calc(100% / 24 - 1px) calc(100% / 24)),
        var(--md-surface-container-high);
}
.tick {
    position: absolute; top: 8px; bottom: 8px; width: max(4px, var(--w, 4px)); border-radius: 2px;
    background: var(--md-outline); transition: transform .15s var(--ease), background .2s;
}
.tick.new { background: var(--md-primary); }
.tick.fav { background: #ffcf40; }
.tick:hover { transform: scaleY(1.25); background: var(--md-on-surface); z-index: 2; }
.tick.on { background: var(--md-rec); top: 3px; bottom: 3px; box-shadow: 0 0 10px rgba(255,84,73,.6); z-index: 1; }
.tick::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    white-space: nowrap; padding: 4px 8px; border-radius: 6px; font: 500 12px/16px var(--mono);
    background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); opacity: 0; pointer-events: none; transition: opacity .15s;
}
.tick:hover::after { opacity: 1; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--md-error); opacity: .8; }
.now-line::before { content: ''; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--md-error); }
.timeline-scale { display: flex; justify-content: space-between; margin-top: 6px; font-variant-numeric: tabular-nums; }

kbd {
    display: inline-block; min-width: 22px; padding: 1px 6px; margin-right: 3px; text-align: center;
    border-radius: 6px; background: var(--md-surface-container-high); border: 1px solid var(--md-outline-variant);
    border-bottom-width: 2px; font: 500 11px/16px var(--mono); color: var(--md-on-surface);
}

/* ============ Översikt ============ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi {
    position: relative; padding: 18px 20px; border-radius: var(--r-xl); background: var(--md-surface-container-low); overflow: hidden;
}
.kpi-icon {
    position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: var(--r-md);
    display: grid; place-items: center; background: var(--md-surface-container-high); color: var(--md-primary);
}
.kpi.accent { background: linear-gradient(135deg, var(--md-primary-container), #1b3a63); color: var(--md-on-primary-container); }
.kpi.accent .kpi-icon { background: rgba(255,255,255,.12); color: inherit; }
.kpi-label { color: var(--md-on-surface-variant); }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: inherit; opacity: .85; }
.kpi-value { font-size: 36px; line-height: 44px; font-weight: 400; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--md-on-surface-variant); }

.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cam-card {
    display: block; border-radius: var(--r-xl); background: var(--md-surface-container-low); color: inherit; text-decoration: none;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.cam-card:hover { transform: translateY(-3px); box-shadow: var(--elev-3); }
.cam-media { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-xl) var(--r-xl) 0 0; overflow: hidden; }
.cam-media video, .cam-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, #1a2230, #07090c 75%); }
.cam-placeholder .ms { font-size: 56px; color: var(--md-outline); }
.cam-name, .cam-when, .cam-warn {
    position: absolute; display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: var(--r-sm);
    background: rgba(17,19,24,.65); backdrop-filter: blur(10px); color: #fff; font-size: 13px; font-weight: 500;
}
.cam-name { left: 12px; top: 12px; }
.cam-name i { width: 10px; height: 10px; border-radius: 50%; }
.cam-when { right: 12px; top: 12px; }
.cam-warn { left: 12px; bottom: 12px; background: var(--md-error-container); color: var(--md-on-error-container); }
.cam-warn .ms { font-size: 16px; }
.cam-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 16px; }
.cam-stats { display: flex; gap: 12px; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.cam-stats span { display: inline-flex; align-items: center; gap: 4px; }
.cam-stats .ms { font-size: 18px; }
.cam-stats .accent { color: var(--md-primary); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
.chart-card.wide { grid-column: 1 / -1; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; color: var(--md-on-surface-variant); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.chart .axis { stroke: var(--md-outline-variant); stroke-width: 1; }
.chart .tick-label { fill: var(--md-on-surface-variant); font-size: 11px; font-family: var(--font); }
.chart .tick-label.strong { fill: var(--md-on-surface); font-weight: 500; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.on { fill: rgba(255,255,255,.05); }
.chart-table { overflow-x: auto; }
.chart-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--md-outline-variant); }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table th { color: var(--md-on-surface-variant); font-weight: 500; font-size: 12px; }

.heat-grid { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--md-surface-container-high); cursor: default; transition: transform .1s; }
.heat-cell:hover { transform: scale(1.3); box-shadow: 0 0 0 2px var(--md-surface-container-low); position: relative; z-index: 1; }
.heat-wd { font-size: 11px; }
.heat-hr { font-size: 10px; text-align: left; white-space: nowrap; }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 12px; }
.heat-legend i { width: 16px; height: 10px; border-radius: 2px; }
.heat-legend span:first-child { margin-right: 4px; }
.heat-legend span:nth-child(7) { margin-left: 4px; }

.storage { display: grid; gap: 16px; }
.st-row { display: grid; gap: 6px; }
.st-row.disk { padding-top: 12px; border-top: 1px solid var(--md-outline-variant); }
.st-top { display: flex; justify-content: space-between; align-items: center; }
.st-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.st-name i { width: 10px; height: 10px; border-radius: 50%; }
.st-name .ms { font-size: 18px; color: var(--md-on-surface-variant); }
.st-bar { height: 8px; border-radius: 4px; background: var(--md-surface-container-high); overflow: hidden; }
.st-bar.big { height: 12px; border-radius: 6px; margin: 10px 0 6px; }
.st-bar span { display: block; height: 100%; border-radius: inherit; background: var(--md-primary); transition: width .6s var(--ease-decel); }
.st-bar span.warn { background: var(--md-error); }

.tooltip {
    position: fixed; z-index: 200; min-width: 160px; padding: 10px 12px; border-radius: var(--r-sm); pointer-events: none;
    background: var(--md-surface-container-highest); color: var(--md-on-surface); box-shadow: var(--elev-3); font-size: 13px;
}
.tt-title { font-weight: 500; margin-bottom: 6px; }
.tt-row { display: flex; align-items: center; gap: 8px; line-height: 22px; color: var(--md-on-surface-variant); }
.tt-row i { width: 10px; height: 10px; border-radius: 3px; }
.tt-row b { margin-left: auto; color: var(--md-on-surface); font-weight: 500; font-variant-numeric: tabular-nums; }
.tt-row.total { border-top: 1px solid var(--md-outline-variant); margin-top: 4px; padding-top: 4px; }

/* Favoriter */
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.fav-card { display: block; border-radius: var(--r-xl); background: var(--md-surface-container-low); color: inherit; text-decoration: none; transition: transform .25s var(--ease), box-shadow .25s; }
.fav-card:hover { transform: translateY(-3px); box-shadow: var(--elev-3); }
.fav-media { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-xl) var(--r-xl) 0 0; overflow: hidden; display: grid; place-items: center; background: radial-gradient(ellipse at center, #1a2230, #07090c 75%); }
.fav-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fav-media > .ms { font-size: 48px; color: var(--md-outline); }
.fav-media .dur { position: absolute; right: 10px; bottom: 10px; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; }
.fav-star { position: absolute; left: 10px; top: 10px; color: #ffcf40; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.fav-body { padding: 14px 18px 18px; display: grid; gap: 4px; }
.fav-note { color: #ffe08a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ============ Admin ============ */
.tabs { position: relative; display: flex; gap: 0; border-bottom: 1px solid var(--md-outline-variant); overflow-x: auto; scrollbar-width: none; }
.tab {
    display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 20px; flex: none;
    color: var(--md-on-surface-variant); font-weight: 500; white-space: nowrap;
}
.tab .ms { font-size: 20px; }
.tab.on { color: var(--md-primary); }
.tab.on .ms { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.tab-ind { position: absolute; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--md-primary); transition: left .3s var(--ease), width .3s var(--ease); }
.admin-body { padding-top: 24px; }
.admin-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.rows { display: grid; gap: 8px; }
.row-card {
    display: flex; align-items: center; gap: 16px; padding: 12px 12px 12px 16px; border-radius: var(--r-lg);
    background: var(--md-surface-container-low); transition: background .2s;
}
.row-card:hover { background: var(--md-surface-container); }
.row-card.dim { opacity: .6; }
.row-main { flex: 1; min-width: 0; }
.row-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions { display: flex; gap: 2px; }
.cam-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--md-secondary-container); color: var(--md-on-secondary-container); flex: none; }
.log { display: grid; }
.log-row { display: flex; gap: 14px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--md-outline-variant); }
.log-ic { color: var(--md-primary); font-size: 22px; }
.log-main { flex: 1; min-width: 0; }
.log-main .body-small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-meta { text-align: right; white-space: nowrap; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.sys-item { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--r-lg); background: var(--md-surface-container-low); }
.sys-item > .ms { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--md-surface-container-high); color: var(--md-primary); }
.disk-card { margin-bottom: 16px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ============ Dialoger ============ */
.dialog {
    border: 0; padding: 0; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
    border-radius: var(--r-xl); background: var(--md-surface-container-high); color: var(--md-on-surface);
    box-shadow: var(--elev-3); overflow: auto;
}
.dialog.wide { width: min(620px, calc(100vw - 32px)); }
.dialog[open] { animation: dialogIn .3s var(--ease-decel); }
@keyframes dialogIn { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
.dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); animation: fadeIn .25s; }
.dialog-form { padding: 24px; gap: 16px; }
.dialog-icon { color: var(--md-secondary); justify-self: center; }
.dialog-title.center { text-align: center; }
.dialog-body { display: grid; gap: 12px; }
.dialog-body p { margin: 0; }
.dialog-error { padding: 10px 14px; border-radius: var(--r-md); background: var(--md-error-container); color: var(--md-on-error-container); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; }
.form-label { margin-bottom: -6px; }
.field.outlined {
    background: transparent; border-radius: var(--r-xs); box-shadow: inset 0 0 0 1px var(--md-outline);
    transition: box-shadow .2s var(--ease);
}
.field.outlined::after { display: none; }
.field.outlined:hover { background: transparent; box-shadow: inset 0 0 0 1px var(--md-on-surface); }
.field.outlined:focus-within { box-shadow: inset 0 0 0 2px var(--md-primary); }
.field.outlined input { padding: 0 12px 0 8px; }
.field.outlined input.no-icon { padding-left: 16px; }
.field.outlined .label { background: var(--md-surface-container-high); padding: 0 4px; left: 44px; }
.field.outlined .label.no-icon { left: 12px; }
.field.outlined input:focus + .label,
.field.outlined input:not(:placeholder-shown) + .label { top: 0; }
.field.outlined input[type=number] { -moz-appearance: textfield; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px; transition: opacity .2s; }
.check-grid.dim { opacity: .4; pointer-events: none; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.check-row:hover { background: rgba(255,255,255,.05); }
.check-row .ms { font-size: 20px; color: var(--md-on-surface-variant); }
.cb { width: 18px; height: 18px; accent-color: var(--md-primary); margin: 0; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }
.icon-pick button.on { background: var(--md-primary); color: var(--md-on-primary); }
.share-result { display: flex; gap: 8px; align-items: center; animation: viewIn .3s var(--ease-decel); }
.share-result input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--md-outline); background: var(--md-surface-container); color: var(--md-on-surface); font-size: 12px; outline: none; }
.settings { display: grid; gap: 24px; }
.settings-section { display: grid; gap: 14px; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; }
.key-row { display: grid; gap: 2px; padding: 6px 0; }

/* Snackbar */
.snackbar {
    position: fixed; left: 50%; bottom: 24px; z-index: 300; transform: translate(-50%, 24px);
    display: flex; align-items: center; gap: 16px;
    min-width: 280px; max-width: calc(100vw - 32px); padding: 6px 8px 6px 16px; min-height: 48px; border-radius: var(--r-xs);
    background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); box-shadow: var(--elev-3);
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--ease-decel);
}
.snackbar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#snackText { flex: 1; }
.snack-action { color: var(--md-inverse-primary); font-weight: 500; padding: 8px 12px; border-radius: var(--r-full); }
.snack-action:hover { background: rgba(61,95,144,.12); }

/* Delad länk */
.share-page { overflow: auto; }
.share-card {
    position: relative; z-index: 1; width: min(1100px, 100%); padding: 16px;
    background: color-mix(in srgb, var(--md-surface-container) 85%, transparent); backdrop-filter: blur(24px);
    border-radius: var(--r-xl); box-shadow: 0 24px 64px rgba(0,0,0,.45); display: grid; gap: 14px;
    animation: rise .6s var(--ease-decel) both;
}
.share-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.share-video { width: 100%; max-height: 75dvh; border-radius: var(--r-lg); background: #000; display: block; }
.share-foot { display: flex; align-items: center; gap: 6px; justify-content: center; }
.share-foot .ms { font-size: 16px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ Livebild ============ */
.live-pill {
    display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 4px;
    background: var(--md-rec); color: #fff; font: 700 11px/20px var(--font); letter-spacing: 1px;
}
.live-pill.big { height: 26px; line-height: 26px; font-size: 13px; vertical-align: 3px; margin-right: 6px; }
.live-btn.on { background: var(--md-rec); color: #fff; }
.live-btn.on .ms { animation: pulse 2s infinite; border-radius: 50%; }
.rail-item.has-live .ind::after {
    content: ''; position: absolute; left: 12px; bottom: 2px; width: 6px; height: 6px; border-radius: 50%;
    background: var(--md-rec); box-shadow: 0 0 0 2px var(--md-surface);
}
.stage.live .seek, .stage.live #cBack, .stage.live #cFwd, .stage.live #cFrameB, .stage.live #cFrameF,
.stage.live #cSpeed, .stage.live #cLoop { display: none; }
.stage.live .stage-chip.left { background: rgba(147,0,10,.75); }
.live-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.live-status {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - 48px);
    display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: var(--r-lg);
    background: rgba(17,19,24,.85); color: #fff; backdrop-filter: blur(10px); text-align: left;
}
.live-status .ms { color: var(--md-primary); flex: none; }
.cam-live {
    position: absolute; right: 12px; top: 12px; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
    border-radius: var(--r-sm); background: rgba(147,0,10,.8); color: #fff; font: 700 12px/28px var(--font); letter-spacing: 1px;
}
.tag.live { background: rgba(147,0,10,.45); color: #ffdad6; }
.rtsp-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.rtsp-preview { display: grid; gap: 8px; }
.rtsp-preview img { width: 100%; border-radius: var(--r-md); }
.rtsp-preview .ms { font-size: 16px; vertical-align: -3px; }
.ok-text { color: #7fd99a; }

/* ============ Tema-variabler som skiljer mellan mörkt och ljust ============ */
:root {
    --md-overlay: 255 255 255;
    --fav-bg: #5c4a00; --fav-fg: #ffcf40; --fav-text: #ffe08a;
    --ok: #7fd99a;
    --nav-h: 80px;
    --top-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="light"] {
    color-scheme: light;
    --md-primary: hsl(218 48% 40%); --md-on-primary: #fff; --md-primary-container: hsl(218 100% 92%); --md-on-primary-container: hsl(218 90% 18%);
    --md-secondary: hsl(218 14% 40%); --md-secondary-container: hsl(218 40% 90%); --md-on-secondary-container: hsl(218 30% 18%);
    --md-tertiary: hsl(278 25% 40%); --md-tertiary-container: hsl(278 80% 92%); --md-on-tertiary-container: hsl(278 60% 16%);
    --md-error: #ba1a1a; --md-on-error: #fff; --md-error-container: #ffdad6; --md-on-error-container: #410002;
    --md-surface: hsl(218 40% 98%); --md-surface-container-lowest: #fff; --md-surface-container-low: hsl(218 30% 96%);
    --md-surface-container: hsl(218 24% 94%); --md-surface-container-high: hsl(218 18% 92%); --md-surface-container-highest: hsl(218 14% 89%);
    --md-on-surface: hsl(218 12% 11%); --md-on-surface-variant: hsl(218 9% 30%); --md-outline: hsl(218 6% 46%); --md-outline-variant: hsl(218 10% 78%);
    --md-inverse-surface: hsl(218 8% 18%); --md-inverse-on-surface: hsl(218 12% 94%); --md-inverse-primary: hsl(218 100% 83%);
    --md-overlay: 0 0 0;
    --fav-bg: #ffe08a; --fav-fg: #5c4a00; --fav-text: #7a5900;
    --ok: #1e7a3a;
}
[data-theme="light"] .elev-shadow, [data-theme="light"] .cam-card:hover, [data-theme="light"] .fav-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08); }
[data-theme="light"] .login-card { background: color-mix(in srgb, var(--md-surface-container-lowest) 88%, transparent); }
[data-theme="light"] .tooltip { box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.timeline {
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(100% / 24 - 1px), rgb(var(--md-overlay) / .06) calc(100% / 24 - 1px) calc(100% / 24)),
        var(--md-surface-container-high);
}
.chart .grid { stroke: rgb(var(--md-overlay) / .08); }
.chart .hit.on { fill: rgb(var(--md-overlay) / .05); }
.check-row:hover { background: rgb(var(--md-overlay) / .05); }
#favBtn.on, .rail-fav.active .ind { background: var(--fav-bg); color: var(--fav-fg); }
.note-line, .fav-note { color: var(--fav-text); }
.note-card { background: color-mix(in srgb, var(--fav-bg) 30%, var(--md-surface-container-low)); }
.note-card > .ms, .fav-ic { color: var(--fav-fg); }
[data-theme="dark"] .fav-ic { color: #ffcf40; }
.ok-text { color: var(--ok); }
[data-theme="light"] .tag.live { color: #93000a; background: #ffdad6; }

/* Täthet: kompakt */
.dense .item { min-height: 56px; padding-top: 4px; padding-bottom: 4px; gap: 10px; }
.dense .thumb { width: 72px; height: 44px; font-size: 13px; }
.dense .fname, .dense .note-line { display: none; }
.dense .subheader { padding-top: 10px; padding-bottom: 4px; }

/* ============ Toppfält, sök, offline ============ */
.top-bar { height: var(--top-h); padding-top: var(--safe-t); gap: 6px; padding-left: 12px; }
@media (display-mode: window-controls-overlay) {
    .top-bar { -webkit-app-region: drag; app-region: drag; padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 8px); }
    .top-bar button, .top-bar a, .top-bar .account { -webkit-app-region: no-drag; app-region: no-drag; }
}
.brand { color: inherit; text-decoration: none; margin-right: 8px; }
.drawer-toggle { margin-right: 2px; }
.search-pill {
    display: flex; align-items: center; gap: 10px; height: 44px; flex: 0 1 440px; min-width: 0; margin-left: 16px; padding: 0 8px 0 14px;
    border-radius: var(--r-full); background: var(--md-surface-container-high); color: var(--md-on-surface-variant); text-align: left;
}
.search-pill .sp-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-pill kbd { margin: 0; white-space: nowrap; }
.menu-item .menu-trail { margin-left: auto; }
.offline-bar {
    position: fixed; z-index: 400; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%);
    display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--r-full);
    background: var(--md-error-container); color: var(--md-on-error-container); font-weight: 500; box-shadow: var(--elev-2);
}
.offline-bar .ms { font-size: 20px; }

/* ============ Navigationslåda (stora skärmar) och modal låda ============ */
.rail-head, .rail-sub, .rail-count { display: none; }
.drawer-open body.app { grid-template-columns: 280px minmax(0, 1fr); }
.drawer-open .rail, .drawer-modal .rail {
    align-items: stretch; gap: 2px; padding: 8px 12px 16px;
}
.drawer-open .rail-item, .drawer-modal .rail-item {
    flex-direction: row; width: auto; height: 56px; gap: 0; padding: 0 16px 0 0; border-radius: var(--r-full);
    font-size: 14px; letter-spacing: .1px; position: relative;
}
.drawer-open .rail-item .ind, .drawer-modal .rail-item .ind { width: 56px; height: 56px; background: none !important; flex: none; }
.drawer-open .rail-item.active, .drawer-modal .rail-item.active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.drawer-open .rail-fav.active, .drawer-modal .rail-fav.active { background: var(--fav-bg); color: var(--fav-fg); }
.drawer-open .rail-item:hover:not(.active), .drawer-modal .rail-item:hover:not(.active) { background: rgb(var(--md-overlay) / .06); }
.drawer-open .rail-label, .drawer-modal .rail-label { max-width: none; flex: 1; text-align: left; }
.drawer-open .rail-count, .drawer-modal .rail-count { display: block; font-size: 12px; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.drawer-open .badge, .drawer-modal .badge { display: none; }
.drawer-open .rail-sub, .drawer-modal .rail-sub { display: block; padding: 14px 16px 6px; color: var(--md-on-surface-variant); }
.drawer-open .rail-sep, .drawer-modal .rail-sep { width: auto; margin: 6px 16px; }
.drawer-open .rail-item.has-live .ind::after, .drawer-modal .rail-item.has-live .ind::after { left: 16px; bottom: 14px; }
.drawer-modal .rail-head { display: block; padding: 18px 16px 10px; font-size: 16px; }
.drawer-modal .rail {
    position: fixed; z-index: 95; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); flex-direction: column; justify-content: flex-start;
    overflow-y: auto; background: var(--md-surface-container-low); border-radius: 0 var(--r-lg) var(--r-lg) 0;
    padding-top: calc(8px + var(--safe-t)); box-shadow: var(--elev-3); animation: drawerIn .3s var(--ease-decel);
}
@keyframes drawerIn { from { transform: translateX(-100%); } }
.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.4); animation: fadeIn .2s; }

/* ============ Kameravägg ============ */
.wall-view { display: flex; flex-direction: column; overflow: hidden; background: var(--md-surface); }
.wall-view:fullscreen { background: #000; }
.wall-view:fullscreen .wall-bar { position: absolute; z-index: 5; left: 0; right: 0; top: 0; opacity: 0; transition: opacity .3s; background: linear-gradient(rgba(0,0,0,.7), transparent); color: #fff; }
.wall-view:fullscreen .wall-bar:hover { opacity: 1; }
.wall-view:fullscreen .wall-grid { padding: 0; gap: 2px; }
.wall-view:fullscreen .wall-tile { border-radius: 0; }
.wall-bar { display: flex; align-items: center; gap: 12px; padding: 4px 24px 12px 12px; flex-wrap: wrap; }
.wall-title { display: flex; align-items: baseline; gap: 12px; }
.wall-clock { color: var(--md-on-surface-variant); font-size: 15px; }
.segmented.small button { height: 36px; min-width: 40px; padding: 0 10px; }
.switch-row.compact { gap: 8px; }
.switch-row.compact .switch { transform: scale(.85); }
.wall-grid {
    --cols: 2;
    flex: 1; min-height: 0; display: grid; gap: 8px; padding: 0 24px 24px 12px;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: stretch;
}
.wall-tile {
    position: relative; min-height: 0; background: #000; border-radius: var(--r-lg); overflow: hidden; outline: none;
    transition: box-shadow .2s;
}
.wall-tile:focus-visible { box-shadow: 0 0 0 3px var(--md-primary); }
.wall-tile video, .wall-tile iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; }
.wall-grid.focused .wall-tile:not(.is-focus) { display: none; }
.wall-empty { position: absolute; inset: 0; display: none; place-items: center; background: radial-gradient(ellipse at center, #1a2230, #07090c 75%); }
.wall-empty .ms { font-size: 56px; color: #8e9099; }
.wall-tile.no-media .wall-empty { display: grid; }
.wall-label {
    position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
    border-radius: var(--r-sm); background: rgba(17,19,24,.62); backdrop-filter: blur(10px); color: #fff; font-size: 13px;
}
.wall-when { opacity: .75; }
.wall-dot { width: 8px; height: 8px; border-radius: 50%; background: #8e9099; }
.wall-tile.is-live .wall-dot { background: var(--md-rec); animation: pulse 2s infinite; }
.wall-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.wall-tile:hover .wall-actions, .wall-tile:focus-within .wall-actions { opacity: 1; }
.wall-actions .icon-btn { background: rgba(17,19,24,.62); color: #fff; backdrop-filter: blur(10px); text-decoration: none; }
@media (hover: none) { .wall-actions { opacity: 1; } }

/* ============ Kommandopalett ============ */
.palette {
    position: fixed; inset: 0; z-index: 250; display: flex; justify-content: center; align-items: flex-start;
    padding: calc(10vh + var(--safe-t)) 16px 16px; background: rgba(0,0,0,.45); backdrop-filter: blur(3px); animation: fadeIn .15s;
}
.palette-box {
    width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden;
    border-radius: var(--r-xl); background: var(--md-surface-container-high); box-shadow: var(--elev-3); animation: dialogIn .25s var(--ease-decel);
}
.palette-search { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--md-outline-variant); }
.palette-search .ms { color: var(--md-on-surface-variant); }
.palette-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--md-on-surface); }
.palette-list { overflow-y: auto; padding: 6px 8px 10px; overscroll-behavior: contain; }
.palette-group { padding: 12px 12px 4px; color: var(--md-primary); text-transform: uppercase; letter-spacing: .8px; }
.palette-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 6px 12px; border-radius: var(--r-md); text-align: left; }
.palette-item > .ms:first-child { color: var(--md-on-surface-variant); }
.palette-item.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.palette-item.on > .ms:first-child { color: inherit; }
.pi-text { flex: 1; min-width: 0; display: grid; }
.pi-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.body-large { font-size: 16px; line-height: 24px; letter-spacing: .5px; }
.pi-go { opacity: 0; font-size: 18px; }
.palette-item.on .pi-go { opacity: .7; }
.palette-empty { padding: 28px 20px; text-align: center; }

/* Inställningar: färgrutor */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; position: relative;
    background: conic-gradient(hsl(var(--h) 100% 83%) 0 50%, hsl(var(--h) 53% 30%) 50% 100%);
    box-shadow: inset 0 0 0 1px rgb(var(--md-overlay) / .15);
}
.swatch .ms { font-size: 20px; color: #fff; opacity: 0; transform: scale(.5); transition: all .2s var(--ease); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.swatch.on { box-shadow: 0 0 0 3px var(--md-surface-container-high), 0 0 0 5px var(--md-primary); }
.swatch.on .ms { opacity: 1; transform: none; }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch.custom .ms { opacity: 1; transform: none; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ============ Layouter per skärmstorlek ============ */
/* Stora skärmar: sidopanel med detaljer bredvid spelaren */
@media (min-width: 1600px) {
    .camera-view { grid-template-columns: 400px minmax(0, 1fr); }
    .player-pane { padding-right: 24px; }

    .page { max-width: 1680px; }
    .kpis { grid-template-columns: repeat(4, 1fr); }
    .cam-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
}
/* Mycket stora skärmar / TV */
@media (min-width: 2200px) {
    html { font-size: 17px; }
    .camera-view { grid-template-columns: 460px minmax(0, 1fr); }

    .cam-grid { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
}
/* Mellanstor: rail + staplad kameravy (surfplatta stående) */
@media (max-width: 1100px) {
    .search-pill .sp-text { display: none; }
    .search-pill { flex: none; width: 44px; padding: 0; justify-content: center; margin-left: 4px; }
    .search-pill kbd { display: none; }
    .clock { display: none; }
}
@media (max-width: 1100px) and (min-width: 861px) {
    .camera-view { grid-template-columns: 320px minmax(0, 1fr); }
    .controls-row { flex-direction: column; align-items: stretch; }
}
@media (max-width: 860px) and (min-width: 600px) {
    body.app { grid-template-columns: 80px minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr); grid-template-areas: "top top" "rail views"; }
    .rail { flex-direction: column; padding: 8px 0 16px; background: var(--md-surface); }
    .rail-item { flex: none; width: 76px; }
    .rail-sep { display: block; }
    .camera-view { display: flex; flex-direction: column; overflow-y: auto; }
    .player-pane { order: -1; flex: none; overflow: visible; padding: 0 16px 12px 4px; }
    .stage { max-height: 50dvh; }
    .list-pane { margin: 0 16px 0 4px; flex: 1; min-height: 60dvh; overflow: visible; }
    .list { overflow: visible; }
    .controls-row, .timeline-card { display: flex; }
    .timeline-card { display: block; }
    .page { padding: 4px 16px 32px 4px; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .wall-grid { padding: 0 16px 16px 4px; }
}
/* Kompakt (mobil stående): bottenmeny */
@media (max-width: 599px) {
    :root { --top-h: 56px; }
    body.app {
        grid-template-columns: 100%;
        grid-template-rows: calc(var(--top-h) + var(--safe-t)) minmax(0, 1fr) auto;
        grid-template-areas: "top" "views" "rail";
    }
    .top-bar { padding: var(--safe-t) 4px 0 8px; }
    .brand-name { font-size: 20px; }
    .brand { margin-right: 0; }
    .brand-mark.small { display: none; }
    .hide-compact { display: none !important; }
    .rail {
        flex-direction: row; justify-content: flex-start; gap: 0; padding: 12px 4px calc(12px + var(--safe-b)); overflow-x: auto; overflow-y: hidden;
        background: var(--md-surface-container); scroll-snap-type: x proximity;
    }
    .rail-item { flex: 1 0 68px; width: auto; scroll-snap-align: start; }
    .rail-sep, .rail-admin { display: none; }
    .rail-label { font-size: 11px; max-width: 64px; }
    .camera-view { display: flex; flex-direction: column; overflow-y: auto; }
    .player-pane { order: -1; padding: 0 0 8px; overflow: visible; flex: none; position: sticky; top: 0; z-index: 6; background: var(--md-surface); }
    .player-card { gap: 8px; }
    .stage { border-radius: 0; max-height: 34dvh; min-height: 0; box-shadow: none; }
    .player-info { padding: 0 12px; flex-wrap: nowrap; align-items: center; }
    .meta h1 { font-size: 17px; line-height: 22px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .meta .label-large, .info-chips { display: none; }
    .actions { flex-wrap: nowrap; gap: 4px; }
    .actions .icon-btn { width: 36px; height: 36px; }
    .actions .btn { width: 36px; height: 36px; padding: 0; }
    .actions .btn span:last-child, #shareBtn, #deleteBtn { display: none; }
    .note-card { margin: 0 12px; }
    .controls-row, .timeline-card { display: none; }
    .list-pane { margin: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; flex: 1; min-height: 70dvh; overflow: visible; }
    .list-head { padding: 16px 8px 4px 20px; }
    .list { overflow: visible; padding: 0 8px 24px; }
    .item { min-height: 68px; }
    .thumb { width: 84px; height: 52px; }
    .ctime { margin: 0 4px; font-size: 12px; }
    .hide-sm { display: none !important; }
    .page { padding: 4px 16px 32px; }
    .page-head { padding-bottom: 12px; }
    .headline-medium { font-size: 24px; line-height: 32px; }
    .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 26px; line-height: 32px; }
    .kpi-icon { width: 32px; height: 32px; right: 10px; top: 10px; font-size: 18px; }
    .cam-grid, .fav-grid { grid-template-columns: 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .heat-grid { grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 2px; }
    .calendar-pop { right: 8px; left: 8px; width: auto; }
    .snackbar { bottom: calc(var(--nav-h) + 16px + var(--safe-b)); }
    .row-card { flex-wrap: wrap; }
    .row-tags { order: 3; width: 100%; justify-content: flex-start; padding-left: 56px; }
    .form-row { grid-template-columns: 1fr; }
    .log-meta { display: none; }
    .dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
    .dialog.wide { width: 100vw; }
    .dialog[open] { animation: sheetIn .3s var(--ease-decel); }
    @keyframes sheetIn { from { transform: translateY(100%); } }
    .dialog-form { padding: 20px 20px calc(20px + var(--safe-b)); }
    .wall-bar { padding: 4px 12px 8px; gap: 8px; }
    .wall-bar .wall-title .title-large { font-size: 18px; }
    .wall-grid { padding: 0 8px 8px; gap: 6px; grid-auto-rows: minmax(160px, 1fr); overflow-y: auto; }
    .switch-row.compact .body-medium { display: none; }
    .palette { padding: calc(8px + var(--safe-t)) 8px 8px; }
    .palette-box { max-height: 80dvh; }
    .tabs .tab { padding: 0 14px; }
}
/* Mobil liggande: spelaren fyller höjden, listan bredvid */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 1000px) {
    :root { --top-h: 48px; }
    body.app { grid-template-columns: 72px minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr); grid-template-areas: "top top" "rail views"; }
    .rail { flex-direction: column; padding: 4px 0; gap: 2px; overflow-y: auto; background: var(--md-surface); }
    .rail-item { flex: none; width: 68px; }
    .rail-label { display: none; }
    .rail-sep, .rail-admin { display: none; }
    .camera-view { display: grid; grid-template-columns: minmax(0, 1fr) 300px; overflow: hidden; }
    .player-pane { order: 1; position: static; overflow-y: auto; padding: 0 8px 8px 0; background: none; }
    .list-pane { order: 2; border-radius: var(--r-lg) 0 0 0; }
    .stage { max-height: calc(100dvh - var(--top-h) - 64px); border-radius: var(--r-md); }
    .list-pane { min-height: 0; overflow: hidden; margin: 0; }
    .list { overflow-y: auto; }
    .list-head, .chips { display: none; }
    .search { margin-top: 8px; height: 40px; }
    .controls-row, .timeline-card { display: none; }
    .snackbar { bottom: 16px; }
}
/* Pekskärmar: större träffytor */
@media (pointer: coarse) {
    .cbtn { min-width: 44px; height: 44px; }
    .seek { height: 28px; }
    .seek-track { top: 12px; }
    .seek:hover .seek-track, .seek.active .seek-track { top: 11px; }
    .seek-thumb { top: 8px; transform: scale(1); }
    .item .trail { display: none; }
}
/* Installerad app */
.standalone .top-bar { -webkit-user-select: none; user-select: none; }

/* Spelaren: sidopanel med kontroller och tidslinje när panelen själv är bred (oberoende av meny/låda) */
.player-pane { container-type: inline-size; container-name: player; }
@container player (min-width: 1080px) {
    .player-card {
        max-width: none; grid-template-columns: minmax(0, 1fr) 340px; align-items: start;
        grid-template-areas: "stage controls" "stage timeline" "info timeline" "note timeline";
    }
    .stage { grid-area: stage; max-height: calc(100dvh - 220px); }
    .player-info { grid-area: info; }
    .note-card { grid-area: note; }
    .controls-row { grid-area: controls; flex-direction: column; align-items: stretch; }
    .controls-row .segmented { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: var(--r-lg); }
    .controls-row .segmented button { border-bottom: 1px solid var(--md-outline); }
    .timeline-card { grid-area: timeline; }
}
@container player (min-width: 1500px) {
    .player-card { grid-template-columns: minmax(0, 1fr) 400px; }
}
@container player (max-width: 560px) {
    .controls-row { flex-direction: column; align-items: stretch; }
    .player-info { flex-direction: column; align-items: stretch; gap: 8px; }
    .meta h1 { font-size: 18px; line-height: 24px; }
    .controls-row .segmented { overflow-x: auto; }
}