:root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #202e25;
    background: #f4f6f0;
    color-scheme: light;
    --page: #f4f6f0;
    --surface: #fbfcf8;
    --text: #202e25;
    --muted: #52655a;
    --green: #245843;
    --soft: #e0ebdf;
    --line: #d5dfd3;
    --gutter: clamp(14px, 4vw, 26px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
button, a, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #58916e; outline-offset: 3px; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button {
    border: 0; border-radius: 12px; padding: 12px 16px;
    background: var(--green); color: #fff; cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
button:enabled:active { filter: brightness(.94); }
button svg { flex: none; }
.icon-button svg, #address-toggle svg, .camera-play svg, .outputs svg, .camera-placeholder svg {
    width: 24px; height: 24px; fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
#login, #apply {
    width: min(100%, 420px); min-height: 100dvh; margin: auto;
    padding: calc(36px + env(safe-area-inset-top)) var(--gutter) 24px;
    display: grid; align-content: center;
}
#login h1 { font-size: 34px; margin: 0 0 24px; }
#login label, #apply label { display: block; margin: 0 0 14px; font-size: 14px; }
#login input, #apply input, .archive-body input {
    display: block; width: 100%; margin-top: 6px; padding: 12px;
    border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
#apply label.check { display: flex; align-items: center; gap: 10px; }
#apply .check input { width: auto; margin: 0; }
#login form > button, #apply form > button { width: 100%; }
#suggestions {
    list-style: none; margin: -6px 0 14px; padding: 0; background: #fff;
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
#suggestions button { width: 100%; border-radius: 0; background: #fff; color: var(--text); text-align: left; }
#suggestions li+li { border-top: 1px solid var(--line); }
#login-status, #apply-status { margin-top: 12px; }
#login-status, #apply-status, #profile-status { color: #873e36; }
#shell {
    position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
    max-width: 760px; height: 100dvh; margin: auto; background: var(--page);
}
#topbar {
    display: flex; align-items: center; gap: 5px;
    padding: calc(9px + env(safe-area-inset-top)) var(--gutter) 9px;
    min-height: 64px; border-bottom: 1px solid var(--line); background: var(--surface);
}
#screen-title { flex: 1; font-size: clamp(20px, 5.5vw, 26px); letter-spacing: -.027em; font-weight: 680; }
#topbar .icon-button { width: 44px; height: 44px; background: transparent; color: var(--green); border-radius: 50%; }
#topbar .icon-button[aria-pressed=true] { background: var(--soft); }
#back { margin-inline-start: -8px; }
#stage { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
#live-view, #watch, #calls { padding: 18px var(--gutter) 22px; }
.cameras { display: grid; gap: 22px; }
.camera-card { min-width: 0; }
.camera-address { margin-bottom: 8px; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.camera-preview {
    position: relative; display: block; width: 100%; padding: 0;
    overflow: hidden; border-radius: 18px; text-align: left; color: #fff; background: #dfe9df;
}
.camera-preview img { display: block; width: 100%; height: auto; }
.camera-placeholder {
    display: grid; justify-items: center; align-content: center; gap: 6px;
    min-height: 114px; aspect-ratio: 16 / 9; padding: 12px 54px 42px;
    background: linear-gradient(135deg, #d9e6d9, #e7eee3);
    color: #3d5948; font-size: 14px; text-align: center;
}
.camera-placeholder svg { width: 28px; height: 28px; }
.camera-overlay {
    display: flex; position: absolute; inset: auto 0 0; gap: 8px; align-items: end;
    justify-content: space-between; padding: 20px 12px 10px 14px;
    background: linear-gradient(transparent, rgb(12 27 20 / 82%));
}
.camera-name { margin-bottom: 7px; font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.camera-play {
    flex: none; width: 36px; height: 36px; display: grid; place-items: center;
    background: rgb(21 42 32 / 78%); border: 1px solid rgb(255 255 255 / 50%); border-radius: 50%;
}
.camera-play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.watch-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 14px; }
.watch-heading h2 { font-size: 19px; overflow-wrap: anywhere; }
#watch-address { margin-top: 4px; font-size: 14px; color: var(--muted); }
#archive-toggle { flex: none; background: var(--soft); color: var(--green); font-weight: 650; }
#player { width: 100%; height: auto; max-height: 70dvh; object-fit: contain; border-radius: 16px; background: #111b15; display: block; }
#home-status { margin: 8px 0; color: var(--muted); }
#home-status:empty { display: none; }
.empty { padding: 30px 0; color: var(--muted); text-align: center; }

#archive{margin:0;color:#f3f6f8;color-scheme:dark}
.archive-body{margin:8px 0 0;padding:14px;background:#1a222b;border-radius:16px}
#archive[hidden]{display:none}
.archive-head,.archive-jump{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.archive-head output{margin-inline-end:auto;font-variant-numeric:tabular-nums;font-weight:650}
.archive-head select,.archive-jump input,.archive-jump button,.nudge button{width:auto;margin:0;padding:8px 10px;background:#12181c;color:#f3f6f8;border:1px solid #3d4c5c;border-radius:10px}
.icon-button{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0}
#player-pause{background:#24303a;color:#f3f6f8;border:1px solid #3d4c5c}
#player-pause svg{display:block;width:22px;height:22px;stroke:none;fill:currentColor}
.nudge{display:flex;gap:6px;margin-top:10px}
.nudge button{font-variant-numeric:tabular-nums}
.scrub{position:relative;height:36px;margin-top:14px;border-radius:10px;background:#3d4c5c;overflow:hidden}
#recordings{position:absolute;inset:0}
#recordings span{position:absolute;top:0;bottom:0;background:#d6ff4a}
#time-range{position:absolute;inset:0;width:100%;height:36px;margin:0;background:transparent;appearance:none}
#time-range::-webkit-slider-runnable-track{height:36px;background:transparent}
#time-range::-webkit-slider-thumb{appearance:none;width:16px;height:36px;border-radius:6px;background:#fff;box-shadow:0 0 0 2px #12181c}
#time-range::-moz-range-track{height:36px;background:transparent;border:0}
#time-range::-moz-range-thumb{width:16px;height:36px;border:0;border-radius:6px;background:#fff}
#time-ticks{display:flex;justify-content:space-between;margin-top:8px;font-size:12px;color:#c5d0d8;font-variant-numeric:tabular-nums}
.archive-jump{margin-top:12px}
.archive-jump input[type=date]{width:9.2rem}
.archive-jump input[type=text]{width:7.2rem}
.clip{display:grid;gap:8px;margin-top:12px}
.clip button{width:auto;justify-self:start}
.clip select,.clip input{width:auto;justify-self:start;background:#12181c;color:#f3f6f8;border:1px solid #3d4c5c}
#clip-menu{display:grid;gap:8px}
#clip-menu[hidden]{display:none}
#clip-menu label{display:grid;gap:4px;margin:0;color:#c5d0d8;font-size:13px}
#clip-seconds{width:6rem}
#clip-progress{width:100%;height:8px;accent-color:#d6ff4a}

#dock {
    position: relative; z-index: 2;
    display: grid; gap: 10px;
    padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: 0;
    background: var(--surface); box-shadow: 0 -7px 26px rgb(32 59 42 / 9%);
}
#address-picker { position: relative; min-width: 0; }
#address-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 49px;
    border: 1px solid var(--line); border-radius: 13px; background: var(--page);
    color: var(--green); font-weight: 660; text-align: left; padding: 9px 12px;
}
#selected-address { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#address-toggle svg { width: 21px; height: 21px; }
#address-toggle[aria-expanded=true] .chevron { transform: rotate(180deg); }
#entrance-nav {
    position: absolute; inset: auto 0 calc(100% + 8px); z-index: 1; list-style: none;
    max-height: min(40dvh, 360px); overflow-y: auto; overscroll-behavior: contain;
    margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); box-shadow: 0 10px 30px rgb(28 65 45 / 18%);
}
#entrance-nav button {
    width: 100%; min-height: 56px; background: transparent; color: var(--text);
    text-align: left; padding: 11px 13px; overflow-wrap: anywhere;
}
#entrance-nav button[aria-current=true] { background: var(--soft); color: var(--green); font-weight: 680; }
#open-status {
    position: absolute; left: var(--gutter); right: var(--gutter); bottom: calc(100% + 8px);
    margin: 0; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px;
    color: var(--text); background: var(--surface); overflow-wrap: anywhere;
}
#open-status:empty, #outputs:empty { display: none; }
.outputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.outputs button {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    min-height: 53px; min-width: 0; padding: 9px; text-align: left;
    font-size: 14px; font-weight: 670; overflow-wrap: anywhere;
    color: #224a36; background: #deebde; border: 1px solid #d0e0d0;
}
.outputs .primary { color: #fff; background: var(--green); border-color: var(--green); }
.outputs [data-position="1"] { grid-column: 2; grid-row: 1; }
.outputs [data-position="2"] { grid-column: 1; grid-row: 1; }
.outputs [data-position="3"] { grid-column: 2; grid-row: 1; }
.outputs [data-position="4"] { grid-column: 1; grid-row: 1; }
.outputs.two-rows { grid-template-rows: auto auto; }
.outputs.two-rows :is([data-position="1"], [data-position="2"]) { grid-row: 2; }
#incoming {
    position: absolute; z-index: 3; left: var(--gutter); right: var(--gutter); top: calc(72px + env(safe-area-inset-top));
    padding: 16px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; box-shadow: 0 9px 26px rgb(32 59 42 / 18%);
}
#incoming-title { margin-bottom: 12px; font-weight: 680; }
.incoming-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.incoming-actions button { flex: 1; padding-inline: 8px; }
#incoming-decline { color: var(--green); background: var(--soft); }
#incoming-status:not(:empty) { margin-top: 9px; }
#call-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#call-list li {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    padding: 13px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px;
}
#call-list .missed { color: #873e36; }
#profile {
    display: flex; flex-direction: column; gap: 20px; justify-content: space-between;
    min-height: 100%; padding: 18px var(--gutter) calc(18px + env(safe-area-inset-bottom));
}
.profile-settings { padding: 4px 15px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
#profile-address { padding: 10px 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
#profile .check {
    display: flex; align-items: center; gap: 12px;
    min-height: 55px; padding: 8px 0; border-top: 1px solid var(--line);
}
#profile .check input { width: 21px; height: 21px; flex: none; margin: 0; accent-color: var(--green); }
.setting-note, #profile-status { font-size: 14px; color: var(--muted); }
#profile-status:not(:empty) { color: #873e36; margin-top: 9px; overflow-wrap: anywhere; }
#guest-pass { margin-top: 14px; }
#logout { min-height: 49px; border: 1px solid #decfca; background: var(--surface); color: #843c34; font-weight: 650; }

