body {
    cursor: crosshair;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin: 0px;
    text-align: center;
}

/* Hidden until door + camera status polls both return (revealed by app.js). */
body.loading {
    visibility: hidden;
}

/* Hidden by default; shown by app.js once camera error is confirmed. */
#status-image {
    display: none;
}

#video-wrapper {
    display: block;
    border: 7px solid transparent;
    border-radius: 10px;
    transition: border-color 0.3s ease;
    margin-bottom: 20px;
    text-align: center;
}

#video-wrapper.green {
    border-color: #2a9a2a;
}

#video-wrapper.orange {
    border-color: #e89000;
}

#video-wrapper.red {
    border-color: #d42020;
}

a:link {
    font-family: Arial;
    font-size: 9pt;
    font-weight: bold;
    color: #1D1D1D;
    text-decoration: none
}

a:visited {
    font-family: Arial;
    font-size: 9pt;
    font-weight: bold;
    color: #1D1D1D;
    text-decoration: none
}

a:active {
    font-family: Arial;
    font-size: 9pt;
    font-weight: bold;
    color: #1D1D1D;
    text-decoration: none
}

a:hover {
    font-family: Arial;
    font-size: 9pt;
    font-weight: bold;
    color: #6E6E6E;
    text-decoration: none;
    cursor: hand
}


.door-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
    align-items: center;
}

#normalOpenButton,
#longOpenButton,
#closeButton {
    font-size: 18px;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 12px 24px;
    min-width: 120px;
    transition: opacity 0.2s ease;
}

#normalOpenButton {
    background-color: #2a7a2a;
    color: #fff;
}

#normalOpenButton:not(:disabled):hover {
    background-color: #1e5c1e;
}

#longOpenButton {
    background-color: #1a5fa8;
    color: #fff;
}

#longOpenButton:not(:disabled):hover {
    background-color: #144980;
}

#closeButton {
    background-color: #b52a2a;
    color: #fff;
}

#closeButton:not(:disabled):hover {
    background-color: #8c1e1e;
}

#normalOpenButton:disabled,
#longOpenButton:disabled,
#closeButton:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.nav-links {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 12px 0 16px;
}

.nav-link,
.nav-link:link,
.nav-link:visited {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 6px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #bbb;
    font-size: 14px;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
    font-weight: normal;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-link:hover {
    background: #3a3a3a;
    border-color: #666;
    color: #fff;
    font-size: 14px;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
    font-weight: normal;
    cursor: pointer;
}

#loginform input[type=text],
#loginform input[type=password] {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    box-sizing: border-box;
    font-size: 22px;
    padding: 8px;
    border: 1px solid #ccc;
    background-color: white;
    text-align: left;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
}

.error {
    display: none;
    color: white;
    background-color: #b00;
    padding: 8px;
    margin-bottom: 12px;
}

.container {
    padding: 15px;
    max-width: 390px;
    margin: auto;
}

.logout-btn {
    display: inline-block;
    font-family: Arial, sans-serif;
    font-size: 9pt;
    font-weight: bold;
    color: #1D1D1D;
    text-decoration: none;
    opacity: 0.5;
}

.logout-btn:hover {
    opacity: 1;
    color: #1D1D1D;
}

.app-version {
    display: block;
    text-align: center;
    font-size: 8pt;
    font-family: Arial, sans-serif;
    color: #888;
    opacity: 0.5;
    margin-top: 2px;
}

#camera-feed,
#status-image {
    text-align: center;
}

#camera-feed {
    position: relative;
    display: inline-block;
    width: 100%;
}

#motion-dot {
    display: none;
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

#motion-dot.motion-dot--idle {
    display: block;
    background: rgba(255, 255, 255, 0.5);
}

#motion-dot.motion-dot--active {
    display: block;
    background: #ff6600;
    animation: motion-pulse 1s ease-in-out infinite;
}

@keyframes motion-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

#camera-feed img,
#status-image img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

#camera-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    /* overridden by data-aspect-ratio attribute */
    cursor: zoom-in;
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.25);
}

#camera-thumb[data-aspect-ratio],
#status-image[data-aspect-ratio],
#feed-dialog-img[data-aspect-ratio] {
    aspect-ratio: var(--aspect-ratio);
}


#status-image img {
    width: 100%;
    object-fit: contain;
    border-radius: 4px;
}

/* ── Video feed dialog ─────────────────────────────────────── */

#feed-dialog {
    border: none;
    padding: 0;
    background: #000;
    width: fit-content;
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 4px;
    position: relative;
}

#feed-dialog::backdrop {
    background: rgba(0, 0, 0, 0.9);
}

#feed-dialog-img {
    display: block;
    max-width: 95vw;
    max-height: 95vh;
}

.feed-dialog-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.feed-dialog-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Gallery ─────────────────────────────────────────────────── */

.gallery-body {
    background-color: #1a1a1a;
    color: #eee;
    cursor: default;
    text-align: left;
}

.gallery-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background-color: #111;
    border-bottom: 1px solid #333;
}

.gallery-title {
    margin: 0;
    font-size: 20px;
    flex: 1;
}

.gallery-back {
    color: #aaa;
    font-size: 14px;
    white-space: nowrap;
}

.gallery-back:link,
.gallery-back:visited,
.gallery-back:hover {
    color: #ccc;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 4px;
    padding: 4px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    background: #111;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s;
}

.gallery-item:hover img {
    opacity: 0.8;
}

.gallery-ts {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: orange;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.event-item {
    outline: 2px solid orange;
    outline-offset: -2px;
}

.gallery-empty {
    display: none;
    color: #888;
    text-align: center;
    padding: 60px 20px;
    font-size: 16px;
}

/* ── Lightbox ────────────────────────────────────────────────── */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.open {
    display: flex;
}

.lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.lb-img-wrap {
    position: relative;
    z-index: 1;
    max-width: calc(100vw - 120px);
    max-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-img {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    display: block;
}

.lb-nav {
    position: relative;
    z-index: 1;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.lb-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lb-close {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 2;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.lb-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lb-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #ddd;
    font-size: 13px;
}

.lb-badge {
    background: orange;
    color: #111;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
}

.lb-badge:empty {
    display: none;
}

.lb-count {
    margin-left: auto;
    color: #888;
}

/* ── Gallery dialog ───────────────────────────────────────── */

#gallery-dialog {
    border: none;
    padding: 0;
    width: 95vw;
    height: 90vh;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    border-radius: 4px;
}

#gallery-dialog[open] {
    display: flex;
    flex-direction: column;
}

#gallery-dialog::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

.gallery-dialog-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 6px 12px;
    background: #111;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.gallery-dialog-newwin:link,
.gallery-dialog-newwin:visited,
.gallery-dialog-newwin:hover {
    color: #aaa;
    font-size: 13px;
    font-family: Arial, sans-serif;
    font-weight: normal;
    text-decoration: none;
}

.gallery-dialog-close {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.gallery-dialog-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

#gallery-iframe {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 0;
}

/* ── Log dialog ───────────────────────────────────────────── */

#log-dialog {
    border: none;
    padding: 0;
    width: 95vw;
    height: 90vh;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    border-radius: 4px;
}

#log-dialog[open] {
    display: flex;
    flex-direction: column;
}

#log-dialog::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

.log-dialog-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 6px 12px;
    background: #111;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.log-dialog-newwin:link,
.log-dialog-newwin:visited,
.log-dialog-newwin:hover {
    color: #aaa;
    font-size: 13px;
    font-family: Arial, sans-serif;
    font-weight: normal;
    text-decoration: none;
}

.log-dialog-close {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.log-dialog-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

#log-iframe {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 0;
}

/* ── Log page ─────────────────────────────────────────────── */

.log-body {
    font-family: monospace;
    font-size: 13px;
    background: #1a1a1a;
    color: #ddd;
    cursor: default;
    text-align: left;
}

.log-header {
    padding: 10px 16px;
    background: #111;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 16px;
}

.log-title {
    margin: 0;
    font-size: 18px;
    flex: 1;
}

.log-back {
    color: #aaa;
    font-size: 14px;
    text-decoration: none;
}

.log-back:hover {
    color: #fff;
}

.log-refresh-btn {
    padding: 5px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
}

.log-refresh-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table th {
    position: sticky;
    top: 0;
    background: #222;
    color: #aaa;
    font-weight: normal;
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid #444;
}

.log-table td {
    padding: 4px 12px;
    border-bottom: 1px solid #2a2a2a;
    vertical-align: top;
    white-space: nowrap;
}

.log-table td:last-child {
    white-space: normal;
    word-break: break-word;
}

.log-table tr:hover td {
    background: #252525;
}

.log-empty {
    display: none;
    padding: 40px;
    text-align: center;
    color: #555;
}

.log-table tr.log-row-camera td {
    background: #0d1f0d;
    color: #7fba7f;
}

.log-table tr.log-row-camera:hover td {
    background: #162816;
}

.log-nav {
    display: flex;
    gap: 8px;
}

.log-nav-btn {
    padding: 5px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    font-family: Trebuchet MS, Verdana, Arial, Helvetica, sans-serif;
}

.log-nav-btn:hover:not(:disabled) {
    background: #3a3a3a;
    color: #fff;
}

.log-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.log-window {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

/* ── Gallery / lightbox throbbers ────────────────────────── */

/* Spinning placeholder shown over a grid item while its thumbnail loads. */
.gallery-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #2a2a2a;
    border-top-color: #888;
    border-radius: 50%;
    animation: log-spin 0.75s linear infinite;
    pointer-events: none;
}

/* Hide the thumbnail image itself while loading so only the throbber shows. */
.gallery-item.loading img {
    opacity: 0;
}

/* Spinner div inside .lb-img-wrap; shown while the full-size image loads. */
.lb-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: log-spin 0.75s linear infinite;
    z-index: 2;
    pointer-events: none;
}

.lb-img-wrap.loading .lb-spinner {
    display: block;
}

.lb-img-wrap.loading .lb-img {
    opacity: 0;
}

/* ── Log throbber ─────────────────────────────────────────── */

.log-throbber {
    display: none;
    width: 28px;
    height: 28px;
    margin: 48px auto;
    border: 3px solid #333;
    border-top-color: #888;
    border-radius: 50%;
    animation: log-spin 0.75s linear infinite;
}

.log-throbber.active {
    display: block;
}

@keyframes log-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Background polling banner ───────────────────────────── */

.bg-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(24, 24, 24, 0.96);
    color: #ccc;
    font-family: Arial, sans-serif;
    font-size: 13px;
    flex-wrap: wrap;
    transform: translateY(-100%);
    transition: transform 0.25s ease;
    z-index: 500;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.bg-banner--visible {
    transform: translateY(0);
}

.bg-banner__text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bg-banner__btn {
    flex-shrink: 0;
    padding: 5px 14px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #ddd;
    cursor: pointer;
    font-size: 13px;
    font-family: Arial, sans-serif;
    white-space: nowrap;
    transition: background 0.15s;
}

.bg-banner__btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.bg-banner__dismiss {
    flex-shrink: 0;
    border: none;
    background: none;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s;
}

.bg-banner__dismiss:hover {
    color: #fff;
}

/* ── Language selector ───────────────────────────────────────── */

.lang-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 8px 5px;
    border: 1px solid #555;
    border-radius: 4px;
    color: #aaa;
    font-size: 12px;
    font-family: Arial, sans-serif;
    padding: 3px 22px 3px 8px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.lang-select:hover {
    border-color: #888;
    color: #ccc;
}

.lang-select:focus {
    border-color: #888;
    color: #ccc;
    outline: none;
}

.lang-select option {
    background: #222;
    color: #ccc;
}