:root {
    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-strong: #eef3f1;
    --text: #17201d;
    --muted: #61706b;
    --line: #d7dfdc;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --warning: #f59e0b;
    --shadow: 0 16px 40px rgba(23, 32, 29, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input {
    font: inherit;
}

.app-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 22px clamp(14px, 4vw, 36px) 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.header-copy {
    max-width: 760px;
}

.eyebrow,
.summary,
.section-heading p,
.modal-topbar p,
.modal-topbar span,
.modal-footer {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.12;
}

h1 {
    margin-top: 4px;
    font-size: clamp(1.7rem, 5vw, 3rem);
}

.summary {
    margin-top: 8px;
    font-size: clamp(0.95rem, 2.4vw, 1.05rem);
}

.header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--accent-strong);
    font-weight: 700;
    white-space: nowrap;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.pause-button {
    min-height: 42px;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

.pause-button[aria-pressed="true"] {
    border-color: var(--line);
    background: var(--surface);
    color: var(--accent-strong);
}

.app-header.is-paused .status-dot {
    background: var(--muted);
    box-shadow: 0 0 0 4px rgba(97, 112, 107, 0.16);
}

.app-shell {
    width: min(100%, 1480px);
    margin: 0 auto;
    padding: 18px clamp(10px, 3vw, 28px) 32px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.road-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tab-button,
.icon-button,
.gallery-button {
    border: 0;
    cursor: pointer;
}

.tab-button {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
}

.tab-button[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.search-field {
    flex: 0 1 340px;
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.search-field input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--surface);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 12px;
}

.section-heading h2 {
    font-size: clamp(1.25rem, 3vw, 1.65rem);
}

.section-heading p {
    margin-top: 4px;
}

.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.camera-card {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(23, 32, 29, 0.06);
}

.camera-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #dce4e1;
    cursor: pointer;
}

.camera-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.camera-frame img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.camera-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent-strong);
    font-size: 0.76rem;
    font-weight: 700;
}

.camera-info {
    display: grid;
    gap: 4px;
    padding: 10px 12px 12px;
}

.camera-info h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
}

.camera-info p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.empty-state {
    margin: 28px 0 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    padding: 12px;
}

.modal.is-open {
    display: grid;
    place-items: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 13, 12, 0.82);
}

.modal-panel {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: min(100%, 1180px);
    max-height: calc(100svh - 24px);
    overflow: hidden;
    border-radius: 8px;
    background: #0b1110;
    box-shadow: var(--shadow);
}

.modal-topbar,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.modal-topbar {
    color: #ffffff;
}

.modal-topbar h2 {
    margin-top: 2px;
    font-size: clamp(1.1rem, 4vw, 1.45rem);
}

.modal-topbar p,
.modal-topbar span,
.modal-footer {
    color: #b8c4c0;
}

.icon-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 1.35rem;
    line-height: 1;
}

.modal-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 220px;
    background: #050807;
    touch-action: pan-y;
}

.modal-stage img {
    width: 100%;
    max-height: calc(100svh - 160px);
    display: block;
    object-fit: contain;
}

.gallery-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 46px;
    height: 64px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 2.6rem;
    line-height: 1;
}

.gallery-button.previous {
    left: 10px;
}

.gallery-button.next {
    right: 10px;
}

.modal-footer {
    font-size: 0.9rem;
}

@media (max-width: 820px) {
    .app-header,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions,
    .live-status,
    .search-field {
        width: 100%;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .pause-button {
        width: 100%;
    }

    .road-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }

    .camera-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 0;
    }

    .modal-panel {
        width: 100%;
        height: 100svh;
        max-height: none;
        border-radius: 0;
    }

    .modal-topbar,
    .modal-footer {
        padding: 10px;
    }

    .modal-stage img {
        max-height: calc(100svh - 150px);
    }

    .gallery-button {
        width: 42px;
        height: 56px;
        font-size: 2.2rem;
    }
}

@media (max-width: 420px) {
    .app-shell {
        padding-left: 8px;
        padding-right: 8px;
    }

    .tab-button {
        padding-left: 10px;
        padding-right: 10px;
    }

    .camera-info {
        padding: 9px 10px 10px;
    }
}
