:root {
    color-scheme: dark;
    --bg: #0a0d12;
    --surface: #111722;
    --surface-2: #18202d;
    --line: #273142;
    --text: #f6f8fb;
    --muted: #94a1b3;
    --accent: #36a9ff;
    --accent-2: #157ed0;
    --danger: #ff5c70;
    --success: #36d399;
    --radius: 18px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% -10%, rgba(54, 169, 255, .16), transparent 32rem),
        var(--bg);
    color: var(--text);
}

.gallery-page, .gallery-page *,
.login-page, .login-page * { letter-spacing: normal; }

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 3px solid rgba(54, 169, 255, .45);
    outline-offset: 2px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 4vw;
    border-bottom: 1px solid rgba(255,255,255,.06);
    background: rgba(10, 13, 18, .86);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 750;
    text-decoration: none;
    letter-spacing: -.02em;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 17px;
    background: linear-gradient(145deg, #55bdff, #1686dc);
    color: white;
    font-size: 28px;
    font-weight: 850;
    box-shadow: 0 12px 35px rgba(29, 143, 224, .25);
}

.brand-mark-small { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }
.brand-mark-logo { overflow: hidden; background: none; box-shadow: none; }
.brand-mark-logo img { display: block; width: 36px; height: 36px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}
.live-indicator > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(54, 211, 153, .1);
}
.live-indicator.is-paused > span { background: var(--danger); box-shadow: none; }

.page-shell { width: min(1500px, 92vw); margin: 0 auto; padding: 56px 0 40px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.hero-copy { display: flex; align-items: flex-start; flex-direction: column; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: 12px; font-weight: 800; line-height: 1.2; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 72px); letter-spacing: -.055em; line-height: .98; }
.muted { color: var(--muted); line-height: 1.6; }
.hero-copy .muted { max-width: 650px; margin: 18px 0 0; line-height: 1.5; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
    font-weight: 700;
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.button-quiet { border-color: var(--line); background: transparent; }
.button-danger { background: var(--danger); color: #180307; }
.button-danger-outline { border-color: rgba(255,92,112,.5); color: #ff9eaa; background: rgba(255,92,112,.08); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17,23,34,.76); }
.stat-card > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 16px; font-weight: 650; }
.stat-card strong { font-size: 23px; letter-spacing: -.03em; }
.stat-card small { display: block; margin-top: 4px; color: var(--accent); font-size: 12px; }
.stat-values .storage-capacity {
    display: block;
    margin: 0;
    color: var(--muted);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -.03em;
}
.stat-values { display: flex; align-items: baseline; column-gap: 12px; }
.stat-values > * { white-space: nowrap; }
.stat-values .new-count {
    display: block;
    margin: 0;
    color: var(--muted);
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -.03em;
}
.stat-values .new-count.has-new { color: var(--accent); }
.stat-values .new-count span { display: inline; margin: 0; color: inherit; font-size: inherit; }
.status-online { color: var(--success); }
.status-offline { color: var(--muted); }

.settings-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}
.retention-form { display: flex; align-items: center; gap: 10px; }
.retention-form label { margin: 0 4px; color: var(--muted); font-size: 14px; font-weight: 700; }
.retention-form select {
    min-height: 42px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface-2);
    font: inherit;
    cursor: pointer;
}
.retention-form select:focus-visible { outline: 3px solid rgba(54,169,255,.45); outline-offset: 2px; }

.gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    margin-bottom: 16px;
    padding: 8px 10px 8px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}
.select-all { display: flex; align-items: center; gap: 10px; color: var(--muted); cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.screenshot-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    animation: card-in .28s ease both;
}
.screenshot-card.is-unviewed { border-color: rgba(54,169,255,.72); box-shadow: 0 0 0 1px rgba(54,169,255,.18); }
.new-badge { position: absolute; z-index: 3; top: 13px; right: 13px; padding: 6px 9px; border-radius: 999px; background: var(--accent); color: #03111d; font-size: 11px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; box-shadow: 0 8px 24px rgba(54,169,255,.28); }
@keyframes card-in { from { opacity: 0; transform: translateY(-8px); } }
.card-select { position: absolute; z-index: 3; top: 12px; left: 12px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: rgba(5,8,12,.8); backdrop-filter: blur(8px); }
.image-button { display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in; background: #07090d; aspect-ratio: 16 / 10; }
.image-button img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .25s ease; }
.image-button:hover img { transform: scale(1.025); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; }
.card-meta time, .card-meta span { display: block; }
.card-meta time { font-size: 13px; font-weight: 700; }
.card-meta span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--text); background: transparent; }
.delete-one { display: grid; place-items: center; padding: 0; }
.close-icon { display: block; width: 18px; height: 18px; pointer-events: none; }
.delete-one:hover { border-color: var(--danger); color: var(--danger); background: rgba(255,92,112,.08); }

.empty-state { padding: 80px 24px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin: 12px 0 6px; }
.empty-state p { margin: 0; }
.empty-icon { font-size: 44px; color: var(--accent); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 28px; color: var(--muted); }
.retention-note { margin: 26px 0 0; color: var(--muted); text-align: center; font-size: 13px; }

.site-footer {
    display: grid;
    width: min(1500px, 92vw);
    margin: 8px auto 0;
    padding: 28px 0 38px;
    border-top: 1px solid var(--line);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.footer-link {
    display: flex;
    min-width: 0;
    min-height: 76px;
    padding: 14px 16px;
    align-items: center;
    gap: 13px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    background: rgba(17,23,34,.72);
    text-decoration: none;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.footer-link:hover {
    border-color: rgba(57,174,255,.55);
    background: rgba(21,31,46,.9);
    transform: translateY(-2px);
}
.footer-link-icon {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(135deg, #55bdff, #1686dc);
}
.footer-link-icon-github { background: #202938; }
.footer-link-icon img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.footer-link-icon-github img { width: 24px; height: 24px; }
.footer-link-copy { display: grid; min-width: 0; gap: 3px; }
.footer-link-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-link-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.flash { margin: 0 0 18px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); }
.flash-error { border-color: rgba(255,92,112,.45); background: rgba(255,92,112,.1); }
.flash-success { border-color: rgba(54,211,153,.4); background: rgba(54,211,153,.08); }
.toast-container {
    position: fixed;
    z-index: 1000;
    top: 84px;
    right: 18px;
    display: grid;
    width: min(400px, calc(100vw - 36px));
    gap: 10px;
    pointer-events: none;
}
.login-page .toast-container { top: 18px; }
.toast-container #live-notifications { display: contents; }
.toast-container .flash {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    min-height: 58px;
    box-shadow: 0 16px 50px rgba(0,0,0,.35);
    backdrop-filter: blur(12px);
    pointer-events: auto;
    animation: toast-enter .4s cubic-bezier(.4,0,.2,1) both;
}
.toast-container .flash.is-leaving { animation: toast-leave .4s cubic-bezier(.4,0,.2,1) both; }
.toast-timer { width: 24px; height: 24px; margin-left: auto; flex: 0 0 24px; }
.toast-timer svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.toast-timer circle { fill: none; stroke-width: 2.5; }
.toast-timer-track { stroke: rgba(169,182,200,.22); }
.toast-timer-progress {
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
    animation: toast-countdown 10s linear forwards;
}
.flash-success .toast-timer-progress { stroke: var(--success); }
.flash-error .toast-timer-progress { stroke: var(--danger); }
@keyframes toast-enter {
    from { opacity: 0; transform: translateX(28px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-leave {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(28px); }
}
@keyframes toast-countdown {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 100; }
}

dialog { color: var(--text); border: 1px solid var(--line); background: #0d121b; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(8px); }
.viewer-dialog { width: min(96vw, 1500px); max-height: 94vh; padding: 0; border-radius: 20px; overflow: hidden; }
.viewer-dialog img { display: block; max-width: 100%; max-height: calc(94vh - 58px); margin: auto; object-fit: contain; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.viewer-close { display: grid; place-items: center; padding: 0; }
.confirm-dialog { width: min(92vw, 480px); padding: 26px; border-radius: 20px; }
.confirm-dialog h2 { margin-top: 0; }
.confirm-dialog label, .login-form label { display: block; margin: 20px 0 8px; font-size: 13px; font-weight: 700; }
.confirm-dialog input, .login-form input { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: #080b10; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 20px; }
.action-dialog[open] { animation: dialog-enter .2s ease-out both; }
.action-dialog h2 { margin-bottom: 10px; font-size: 24px; line-height: 1.2; }
.action-dialog p { margin: 0; line-height: 1.55; }
.dialog-symbol {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 20px;
    place-items: center;
    border: 1px solid rgba(255,92,112,.45);
    border-radius: 50%;
    color: var(--danger);
    background: rgba(255,92,112,.1);
    font-size: 22px;
    font-weight: 800;
}
@keyframes dialog-enter {
    from { opacity: 0; transform: translateY(-10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-page { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(17,23,34,.9); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.login-card .brand-mark { margin-bottom: 30px; }
.login-card h1 { max-width: 100%; font-size: clamp(34px, 4vw, 46px); line-height: 1.02; letter-spacing: -.025em; white-space: nowrap; }
.brand-mark-eye { overflow: visible; background: none; box-shadow: none; }
.eye-symbol {
    display: block;
    width: 64px;
    height: 64px;
}
.login-author { margin: 14px 0 0; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.login-form .button { width: 100%; margin-top: 18px; }

@media (max-width: 1050px) {
    .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .page-shell { width: min(94vw, 650px); padding-top: 36px; }
    .hero-row { align-items: flex-start; flex-direction: column; }
    .hero-copy .muted { margin-top: 16px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .live-indicator { display: none; }
    .settings-bar { align-items: stretch; flex-direction: column; }
    .retention-form { flex-wrap: wrap; }
    #stop-client { width: 100%; }
    .site-footer { width: min(94vw, 650px); grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .topbar { padding: 0 3vw; }
    .gallery-grid { grid-template-columns: 1fr; }
    .gallery-toolbar { align-items: stretch; flex-direction: column; padding: 13px; }
    .gallery-toolbar .button { width: 100%; }
    .retention-form { align-items: stretch; flex-direction: column; }
    .retention-form label { margin: 0; }
    .retention-form .button { width: 100%; }
    .stat-card { padding: 15px; }
    .stat-card strong,
    .stat-values .new-count,
    .stat-values .storage-capacity { font-size: 19px; }
    .login-card { padding: 26px; }
    .login-card h1 { font-size: clamp(30px, 9vw, 40px); }
}
