/* Vazirmatn (SIL OFL 1.1), served from this panel: no CDN, works with the internet down */
@font-face {
    font-family: Vazirmatn;
    src: url(/static/vazirmatn.woff2) format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --bg: #0b0d12;
    --bg-2: #0f1218;
    --panel: #141821;
    --panel-2: #1b2029;
    --line: rgba(255, 255, 255, .07);
    --line-2: rgba(255, 255, 255, .12);
    --text: #e9ecf2;
    --muted: #8e96a3;
    --accent: #5b8cff;
    --accent-2: #39c6f0;
    --accent-soft: rgba(91, 140, 255, .14);
    --gold: #f5c04a;
    --ok: #34d17c;
    --bad: #ff6464;
    --live: #ff4d4d;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(91, 140, 255, .10), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(57, 198, 240, .07), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 15px/1.7 Vazirmatn, Tahoma, system-ui, sans-serif;
}

[hidden] { display: none !important; }   /* classes below set display, which would beat the attribute */

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.i {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

button, input { font: inherit; color: inherit; }

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    padding: 8px 14px;
    cursor: pointer;
    touch-action: manipulation;
    transition: background .15s, border-color .15s, transform .1s, color .15s;
}
button:hover { border-color: rgba(255, 255, 255, .22); }
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.primary:hover { filter: brightness(1.08); border-color: transparent; }

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
a.icon-btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); text-decoration: none; }
.icon-btn.danger:hover { color: var(--bad); }
.icon-btn.glass {
    background: rgba(10, 12, 16, .45);
    border-color: rgba(255, 255, 255, .14);
    color: #fff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.icon-btn.glass:hover { background: rgba(10, 12, 16, .65); }
.icon-btn.glass[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

input {
    background: var(--bg-2);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    padding: 9px 12px;
    min-width: 0;
}
input::placeholder { color: #626a77; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }

/* --- top bar ------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    background: rgba(11, 13, 18, .78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; line-height: 1.3; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); direction: ltr; text-align: end; }
.logo {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 6px 18px rgba(91, 140, 255, .35);
}
.top-actions { display: flex; align-items: center; gap: 10px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok { color: var(--text); }
.pill.ok::before { background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 209, 124, .6); animation: ping 2s infinite; }
.pill.bad { color: var(--bad); border-color: rgba(255, 100, 100, .3); }
.pill.bad::before { background: var(--bad); }

@keyframes ping {
    0% { box-shadow: 0 0 0 0 rgba(52, 209, 124, .55); }
    80%, 100% { box-shadow: 0 0 0 8px rgba(52, 209, 124, 0); }
}

/* --- layout -------------------------------------------------------------------- */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "stage side" "visits side" "recordings side";
    align-items: start;
    gap: 18px;
    padding: 18px;
    max-width: 1440px;
    margin: 0 auto;
}
.stage { grid-area: stage; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 84px; }
.visits { grid-area: visits; }
.recordings { grid-area: recordings; }

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 40%), var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; flex: 1; }
.note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 0; margin: 0; list-style: none; }

/* --- player -------------------------------------------------------------------- */
.player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.player camera-view { position: absolute; inset: 0; display: block; }
.player video { object-fit: contain; background: #000; }
.player:fullscreen { border-radius: 0; box-shadow: none; }

.ov {
    position: absolute;
    inset-inline: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    z-index: 2;
    pointer-events: none;
}
.ov > * { pointer-events: auto; }
.ov-bottom { bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); padding-top: 34px; }

.live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .3px;
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 77, 77, .9);
}
.live i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.loading {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(255, 255, 255, .75);
    font-size: 14px;
    background: radial-gradient(circle, rgba(20, 24, 33, .6), #000);
    transition: opacity .3s;
}
.loading.hide { opacity: 0; pointer-events: none; }
.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .15);
    border-top-color: var(--accent-2);
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* segmented buttons */
.seg {
    display: inline-flex;
    padding: 3px;
    gap: 3px;
    border-radius: 12px;
    background: rgba(10, 12, 16, .5);
    border: 1px solid rgba(255, 255, 255, .12);
}
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 9px; font-size: 13px; color: rgba(255, 255, 255, .8); }
.seg button.on { background: #fff; color: #10131a; font-weight: 600; }
.seg.wide { display: flex; margin-top: 16px; background: var(--bg-2); border-color: var(--line); }
.seg.wide button { flex: 1; color: var(--muted); }
.seg.wide button.on { background: var(--accent-soft); color: var(--accent); }

/* --- joystick ------------------------------------------------------------------ */
.joy {
    --size: 232px;
    position: relative;
    width: var(--size);
    height: var(--size);
    margin: 4px auto 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.joy-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 50%, transparent 31%, rgba(255, 255, 255, .03) 32%, rgba(255, 255, 255, .06) 100%),
        var(--bg-2);
    border: 1px solid var(--line-2);
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, .45);
    transition: box-shadow .2s, border-color .2s;
}
.joy.moving .joy-ring { border-color: rgba(91, 140, 255, .6); box-shadow: inset 0 2px 12px rgba(0, 0, 0, .45), 0 0 0 6px var(--accent-soft); }
.dir {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 50px;
    height: 50px;
    margin: -25px;
    padding: 0;
    border-radius: 50%;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    transform: rotate(var(--a)) translateY(-84px);
}
.dir:hover { color: var(--text); background: rgba(255, 255, 255, .05); border-color: transparent; }
.dir:active, .dir.on { transform: rotate(var(--a)) translateY(-84px) scale(.94); }
.dir.on { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 16px rgba(91, 140, 255, .45); }
.dir .i { width: 24px; height: 24px; stroke-width: 2.4; }
.joy-center {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 74px;
    height: 74px;
    margin: -37px;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, #232a36, #181d26);
    border-color: var(--line-2);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.joy-center .i { width: 24px; height: 24px; }
.joy-center:hover { color: var(--gold); }

/* --- presets ------------------------------------------------------------------- */
.presets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.preset {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px 8px;
    padding-inline-start: 12px;
    border-radius: 12px;
    background: var(--bg-2);
    border: 1px solid var(--line);
}
.preset.default { border-color: rgba(245, 192, 74, .35); background: linear-gradient(90deg, rgba(245, 192, 74, .06), transparent), var(--bg-2); }
.preset .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.preset .tag { font-size: 11px; color: var(--gold); padding: 1px 8px; border-radius: 999px; background: rgba(245, 192, 74, .12); }
.preset .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.preset .star.on { color: var(--gold); }
.preset .star.on .i { fill: currentColor; }
.preset .go { color: var(--accent); }

.add { display: flex; gap: 8px; margin-top: 12px; }
.add input { flex: 1; }
.add button { padding: 8px 14px; }

/* --- visits -------------------------------------------------------------------- */
.day { margin-top: 4px; }
.day + .day { margin-top: 18px; }
.day h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 10px;
}
.day h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.visit {
    position: relative;
    display: block;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-2);
    border: 1px solid var(--line);
    text-align: start;
}
.visit img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; transition: transform .3s; }
.visit:hover img { transform: scale(1.04); }
.visit .meta {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 10px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .75));
    color: #fff;
}
.visit .time { font-weight: 700; font-size: 14px; }
.visit .count { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; opacity: .85; }
.visit .count .i { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.visit.new::after {
    content: "تازه";
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--live);
    color: #fff;
}
.more { display: flex; margin: 16px auto 0; }

/* --- photo viewer -------------------------------------------------------------- */
.viewer {
    width: min(960px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 0;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.viewer::backdrop { background: rgba(4, 6, 10, .78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.viewer-head strong { font-size: 18px; margin-inline-end: 8px; }
.viewer-body { position: relative; background: #000; }
.viewer-body img, .viewer-body video { display: block; width: 100%; max-height: calc(100vh - 220px); object-fit: contain; background: #000; }
.viewer-thumbs .vthumb { display: grid; place-items: center; width: 104px; aspect-ratio: 16 / 9; background: var(--bg-2); color: var(--text); font-size: 12px; gap: 2px; }
.viewer-thumbs .vthumb .i { width: 18px; height: 18px; fill: currentColor; stroke: none; }

/* --- 24/7 recordings ----------------------------------------------------------- */
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: thin; }
.days button { flex: none; padding: 6px 12px; font-size: 13px; border-radius: 10px; background: var(--bg-2); color: var(--muted); }
.days button.on { background: var(--accent-soft); border-color: rgba(91, 140, 255, .45); color: var(--accent); font-weight: 600; }
.hours { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.hours .empty { grid-column: 1 / -1; }
.hour {
    padding: 8px 0;
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-2);
    border-color: var(--line);
    color: #4c5361;
}
.hour.has { color: var(--text); background: linear-gradient(180deg, rgba(91, 140, 255, .22), rgba(91, 140, 255, .08)); border-color: rgba(91, 140, 255, .3); }
.hour.has:hover { border-color: var(--accent); }
.hour:disabled { opacity: 1; cursor: default; }
.storage { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.bar-track { flex: 1; height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.bar-fill.full { background: linear-gradient(90deg, var(--gold), var(--bad)); }
.parts { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.parts button { padding: 5px 12px; font-size: 13px; border-radius: 9px; background: var(--bg-2); }
.parts button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav {
    position: absolute;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border-radius: 50%;
    background: rgba(10, 12, 16, .55);
    border-color: rgba(255, 255, 255, .15);
    color: #fff;
}
.nav.prev { inset-inline-start: 12px; }
.nav.next { inset-inline-end: 12px; }
.viewer-thumbs { display: flex; gap: 8px; padding: 12px 14px; overflow-x: auto; }
.viewer-thumbs button { padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; flex: none; }
.viewer-thumbs button.on { border-color: var(--accent); }
.viewer-thumbs img { display: block; width: 104px; aspect-ratio: 16 / 9; object-fit: cover; }

/* --- toast --------------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: rgba(27, 32, 41, .95);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    padding: 10px 18px;
    box-shadow: var(--shadow);
    max-width: calc(100% - 32px);
}

/* --- login --------------------------------------------------------------------- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 30px 26px;
    text-align: center;
}
.login .logo { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; }
.login .logo .i { width: 30px; height: 30px; }
.login h1 { font-size: 21px; margin: 4px 0 0; }
.login p { margin: -8px 0 4px; color: var(--muted); font-size: 13.5px; }
.pw { position: relative; display: flex; }
.pw input { flex: 1; padding-inline-end: 46px; height: 46px; text-align: start; }
.pw button { position: absolute; inset-inline-end: 4px; top: 4px; width: 38px; height: 38px; }
.otp input {
    width: 100%;
    height: 52px;
    direction: ltr;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 8px;
}
.otp input::placeholder { font-size: 14px; font-weight: 400; letter-spacing: 0; }
.login .primary { height: 46px; font-size: 15px; }
.error { color: var(--bad); margin: 0; font-size: 13.5px; }

/* --- small screens ------------------------------------------------------------- */
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; grid-template-areas: "stage" "side" "visits" "recordings"; padding: 12px; gap: 14px; }
    .side { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (max-width: 640px) {
    .side { grid-template-columns: 1fr; }
    .brand p { display: none; }
    .card { padding: 14px; border-radius: 16px; }
    .player { border-radius: 14px; }
    .ov { padding: 10px; }
    .seg button { padding: 4px 9px; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .hours { grid-template-columns: repeat(6, 1fr); }
    .joy { --size: 216px; }
}
