/* Syrian National Day / Liberation Day — frame editor
   Palette and type follow the official identity guide (cream, green, red accent, charcoal; Readex Pro). */

:root {
    --cream: #F7F6F2;
    --green: #165C48;
    --green-deep: #134A3A;
    --green-mid: #185D49;
    --green-darkest: #114133;
    --red: #C74848;
    --charcoal: #24282A;

    --bg: var(--cream);
    --surface: #FCFCFB;
    --well: #EFECE7;
    --line: #E3DFDB;
    --line-strong: #C6C5C2;
    --text: #24282A;
    --muted: #505455;
    --primary: #165C48;
    --primary-hover: #134A3A;
    --on-primary: #F7F6F2;
    --accent-text: #165C48;
    --accent-tint: rgba(22, 92, 72, .09);
    --accent-ring: rgba(22, 92, 72, .22);
    --danger-text: #B13B3B;
    --danger-tint: rgba(199, 72, 72, .1);
    --focus: #165C48;
    --shadow: 0 1px 2px rgba(36, 40, 42, .06), 0 8px 24px rgba(36, 40, 42, .06);
    --toast-bg: #24282A;
    --toast-text: #F7F6F2;
    /* chart marks (validated with the dataviz palette checks against --surface) */
    --chart-bar: #22805F;
    --chart-bar-hover: #165C48;
    --chart-grid: #E3DFDB;
    --chart-track: rgba(22, 92, 72, .12);

    --panel-gradient: linear-gradient(135deg, #134A3A 0%, #185D49 100%);
    --r-lg: 24px;
    --r-md: 18px;
    --r-sm: 14px;
    --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --safe-b: env(safe-area-inset-bottom, 0px);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #191B1D;
    --surface: #202426;
    --well: #24282A;
    --line: #3A3E3F;
    --line-strong: #505455;
    --text: #F7F6F2;
    --muted: #C6C5C2;
    --primary: #185D49;
    --primary-hover: #2F6D5B;
    --on-primary: #F7F6F2;
    --accent-text: #8DB5A9;
    --accent-tint: rgba(93, 142, 128, .16);
    --accent-ring: rgba(141, 181, 169, .35);
    --danger-text: #E77F80;
    --danger-tint: rgba(227, 109, 109, .14);
    --focus: #8DB5A9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --toast-bg: #F7F6F2;
    --toast-text: #24282A;
    --chart-bar: #3FA37F;
    --chart-bar-hover: #6DBE9F;
    --chart-grid: #33383A;
    --chart-track: rgba(63, 163, 127, .16);
    --panel-gradient: linear-gradient(135deg, #114133 0%, #175442 100%);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
img, canvas, svg { display: block; }
a { color: var(--accent-text); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
.view__title:focus { outline: none; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------------ motif */
.motif {
    position: absolute;
    pointer-events: none;
    opacity: .075;
    top: -60px;
    left: -60px;
    width: 520px;
    height: 420px;
    -webkit-mask-image: radial-gradient(circle at 0 0, #000 30%, transparent 72%);
    mask-image: radial-gradient(circle at 0 0, #000 30%, transparent 72%);
}

/* ------------------------------------------------------------------ masthead */
.masthead {
    position: relative;
    overflow: hidden;
    flex: none;
    background: var(--panel-gradient);
    color: #F7F6F2;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.masthead__inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 1360px;
    margin: 0 auto;
}
.masthead__logo {
    height: 50px;
    width: auto;
    flex: none;
    margin: 4px 0;
}
.masthead__text { min-width: 0; border-inline-start: 1px solid rgba(247, 246, 242, .28); padding-inline-start: 14px; }
.masthead__slogan { font-size: 16px; font-weight: 600; line-height: 1.35; white-space: nowrap; }
.masthead__en { font-size: 11.5px; font-weight: 400; letter-spacing: .16em; opacity: .78; text-align: right; margin-top: 1px; }
.masthead__links { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.pill-link {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px;
    border-radius: 999px;
    color: #F7F6F2; text-decoration: none; font-size: 14px; font-weight: 500;
    background: rgba(247, 246, 242, .1);
    border: 1px solid rgba(247, 246, 242, .22);
    white-space: nowrap;
}
.pill-link:hover { background: rgba(247, 246, 242, .18); }
.pill-link svg { width: 18px; height: 18px; }
.pill-link:focus-visible { outline-color: #F7F6F2; }

@media (max-width: 399px) {
    .masthead__inner { gap: 10px; }
    .masthead__logo { height: 42px; }
    .masthead__text { padding-inline-start: 10px; }
    .masthead__slogan { font-size: 14.5px; }
    .masthead__en { font-size: 10.5px; letter-spacing: .12em; }
}
@media (max-width: 559px) {
    .pill-link { padding: 0 12px; }
    .pill-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #adminLink { display: none; }
}

/* Telegram: space is precious, keep the brand as a slim strip */
[data-tg] .masthead { padding-top: 6px; padding-bottom: 6px; }
[data-tg] .masthead__logo { height: 32px; margin: 2px 0; }
[data-tg] .masthead__slogan { font-size: 14px; font-weight: 500; }
[data-tg] .masthead__en, [data-tg] #botLink { display: none; }
[data-tg] .masthead .motif { opacity: .06; height: 140px; }

/* ------------------------------------------------------------------ app shell */
.page-editor { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}
.panel { display: contents; }

/* stepper */
.stepper {
    order: 0;
    list-style: none;
    margin: 0;
    padding: 12px 16px 6px;
    display: flex;
    gap: 6px;
    flex: none;
}
.stepper li { flex: 1; min-width: 0; position: relative; }
.stepper__btn {
    width: 100%;
    display: flex; align-items: center; gap: 6px;
    min-height: 44px;
    padding: 4px 0 8px;
    border: 0; background: none; cursor: pointer;
    text-align: start;
    color: var(--muted);
    border-bottom: 3px solid var(--line);
    border-radius: 0;
    transition: color .2s, border-color .2s;
}
.stepper__btn:disabled { cursor: default; opacity: .6; }
.stepper__num {
    flex: none;
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    font-size: 13px; font-weight: 600;
    border: 1.5px solid currentColor;
}
.stepper__label { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper__btn.is-current { color: var(--text); border-bottom-color: var(--primary); }
.stepper__btn.is-current .stepper__num { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.stepper__btn.is-done { color: var(--accent-text); border-bottom-color: var(--accent-ring); opacity: 1; }
.stepper__btn.is-done .stepper__num { background: var(--accent-tint); border-color: transparent; }

/* views */
.view {
    order: 2;
    padding: 10px 16px 16px;
    min-height: 0;
}
.view__head { margin-bottom: 14px; }
.view__head--compact { display: none; }
.view__title { font-size: 21px; font-weight: 600; line-height: 1.35; letter-spacing: -.005em; }
.view__lead { color: var(--muted); font-size: 14px; margin-top: 2px; }

.app[data-step="1"] .view[data-view="1"],
.app[data-step="2"] .view[data-view="2"] { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.view[data-view="2"]:not([hidden]) { display: flex; flex-direction: column; }
.view[data-view="2"] .dropzone { flex: 1 1 auto; max-height: 440px; }

/* frame cards */
.frame-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 12px;
}
.frame-card {
    position: relative;
    display: flex; flex-direction: column; gap: 8px;
    padding: 8px 8px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    text-align: start;
    transition: border-color .18s, box-shadow .18s, transform .18s;
}
.frame-card:hover { border-color: var(--line-strong); }
.frame-card:active { transform: scale(.985); }
.frame-card:focus-visible { outline-offset: 3px; border-radius: var(--r-md); }
.frame-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-ring); }
.frame-card__media {
    position: relative;
    display: grid; place-items: center;
    aspect-ratio: 1;
    border-radius: 12px;
    background: var(--well);
    overflow: hidden;
    padding: 10px;
}
.frame-card__img {
    position: absolute; inset: 10px;
    width: calc(100% - 20px); height: calc(100% - 20px);
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(36, 40, 42, .18));
}
.frame-card__media .badge { position: absolute; bottom: 8px; inset-inline-end: 8px; background: var(--surface); box-shadow: 0 1px 3px rgba(36, 40, 42, .15); }
.frame-card__media .badge--text { top: 8px; bottom: auto; color: var(--text); } /* top end corner: the check mark sits at top start */
.frame-card__check {
    position: absolute; top: 8px; inset-inline-start: 8px;
    width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary);
    transform: scale(.5); opacity: 0;
    transition: transform .2s, opacity .2s;
}
.frame-card__check svg { width: 18px; height: 18px; }
.frame-card.is-selected .frame-card__check { transform: none; opacity: 1; }
.frame-card__name {
    padding: 0 4px; min-width: 0;
    font-size: 15px; font-weight: 500; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.badge {
    flex: none;
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
    background: var(--accent-tint);
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}
.badge--muted { background: var(--well); color: var(--muted); }
.badge--danger { background: var(--danger-tint); color: var(--danger-text); }
.frame-card.is-skeleton { min-height: 200px; cursor: default; background: var(--well); border-color: transparent; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.empty {
    grid-column: 1 / -1;
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    padding: 20px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    color: var(--muted);
}
.empty strong { color: var(--text); font-weight: 600; }
.empty .btn { margin-top: 8px; }

/* step 2 */
.chosen-frame {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 8px 8px 12px;
    padding-inline-start: 8px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--line);
    margin-bottom: 12px;
}
.chosen-frame__thumb { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: var(--well); padding: 4px; }
.chosen-frame__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chosen-frame__label { font-size: 12.5px; color: var(--muted); }
.chosen-frame__name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dropzone {
    width: 100%;
    min-height: 220px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 28px 20px;
    border: 2px dashed color-mix(in srgb, var(--primary) 45%, transparent);
    border-radius: var(--r-lg);
    background: var(--surface);
    cursor: pointer;
    text-align: center;
    transition: background-color .2s, border-color .2s;
}
.dropzone:hover, .is-dragging .dropzone { background: var(--accent-tint); border-color: var(--primary); border-style: solid; }
.dropzone:focus-visible { border-radius: var(--r-lg); }
.dropzone__icon {
    width: 68px; height: 68px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent-tint); color: var(--accent-text);
    margin-bottom: 4px;
}
.dropzone__icon svg { width: 34px; height: 34px; }
.dropzone__title { font-size: 18px; font-weight: 600; }
.dropzone__hint { font-size: 14px; color: var(--muted); max-width: 30ch; }
/* Loading state while the chosen photo is being read/decoded */
.dropzone__loading { display: none; flex-direction: column; align-items: center; gap: 14px; font-size: 16px; font-weight: 600; color: var(--accent-text); }
.dropzone.is-loading { cursor: progress; border-style: solid; border-color: var(--primary); background: var(--accent-tint); }
.dropzone.is-loading > :not(.dropzone__loading) { display: none; }
.dropzone.is-loading .dropzone__loading { display: flex; }
.dropzone .spinner--accent { width: 44px; height: 44px; border-width: 4px; border-color: color-mix(in srgb, var(--primary) 22%, transparent); border-top-color: var(--primary); }
/* Spinner over the frame until the photo is placed in the editor */
.stage__loading { position: absolute; inset: 0; z-index: 4; display: none; place-items: center; pointer-events: none; }
.stage.is-loading-photo .stage__loading { display: grid; }
.stage__disc { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: rgba(25, 27, 29, .62); }
.stage__disc .spinner { width: 40px; height: 40px; border-width: 4px; }
.privacy { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.privacy svg { width: 18px; height: 18px; flex: none; color: var(--accent-text); }

/* step 3 tools */
.tools { display: flex; flex-direction: column; gap: 10px; }
.zoom { display: flex; align-items: center; gap: 6px; }
.icon-btn {
    flex: none;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 0; background: transparent; cursor: pointer;
    color: var(--text);
}
.icon-btn:hover { background: var(--well); }
.icon-btn svg { width: 22px; height: 22px; }
.zoom input[type=range] {
    flex: 1; min-width: 0;
    -webkit-appearance: none; appearance: none;
    height: 44px; background: transparent; cursor: pointer;
    --fill: 0%;
}
.zoom input[type=range]::-webkit-slider-runnable-track {
    height: 6px; border-radius: 999px;
    background: linear-gradient(to right, var(--primary) var(--fill), var(--line) var(--fill));
}
.zoom input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
.zoom input[type=range]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--primary); }
.zoom input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.zoom input[type=range]::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--primary);
}
.tool-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool {
    min-height: 58px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 6px 4px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    font-size: 12.5px; font-weight: 500;
}
.tool:hover { border-color: var(--line-strong); }
.tool svg { width: 22px; height: 22px; color: var(--accent-text); }
#tgSaveEditBtn { margin-top: 10px; }

/* step 3: text fields defined by the frame */
.app[data-step="3"] .view[data-view="3"] { overflow-y: auto; overscroll-behavior: contain; }
.text-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.text-form__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.text-form__title { font-size: 15px; font-weight: 600; }
.text-form__sub { font-size: 12.5px; color: var(--muted); }
.text-form__fields { display: grid; gap: 10px; }
.text-field { display: grid; gap: 5px; }
.text-field__top { display: flex; align-items: baseline; gap: 8px; min-height: 20px; }
.text-field__top label { font-size: 13.5px; font-weight: 500; }
.text-field__count { margin-inline-start: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.text-field__count.is-limit { color: var(--danger-text); font-weight: 500; }
.req { color: var(--danger-text); font-weight: 600; }
.text-field .input { min-height: 46px; padding: 9px 14px; }
.text-field .input::placeholder { color: var(--muted); opacity: .75; }
.text-field .input[aria-invalid] { border-color: rgba(199, 72, 72, .55); }
.text-form__hint {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 12px;
    background: var(--danger-tint); color: var(--danger-text);
    font-size: 13px; font-weight: 500; line-height: 1.5;
}
.text-form__hint svg { width: 18px; height: 18px; flex: none; }
@media (min-width: 960px) {
    .text-form { margin-top: 18px; padding-top: 16px; }
    .text-field .input { background: var(--bg); }
}
.edit-meta { display: none; }
@media (min-width: 960px) {
    .edit-meta {
        display: flex; align-items: center; gap: 12px;
        margin-top: 18px; padding: 12px 14px;
        border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line);
    }
    .edit-meta dl { flex: 1; margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
    .edit-meta dt { color: var(--muted); }
    .edit-meta dd { margin: 0; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* result */
.result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.result-head__badge {
    flex: none; width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary);
}
.result-head__badge svg { width: 24px; height: 24px; }
.result-actions { display: grid; gap: 8px; }
.result-actions .btn svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px;
    padding: 0 20px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: 16px; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, transform .1s;
    white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn--secondary:hover:not(:disabled) { border-color: var(--accent-text); }
.btn--ghost { background: transparent; color: var(--accent-text); }
.btn--ghost:hover:not(:disabled) { background: var(--accent-tint); }
.btn--danger { background: transparent; color: var(--danger-text); }
.btn--danger:hover:not(:disabled) { background: var(--danger-tint); }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 14px; font-weight: 500; }
.btn--block { width: 100%; }
.btn--grow { flex: 1; min-width: 0; }
.btn--back { padding: 0 12px 0 16px; }
.btn--back svg { width: 20px; height: 20px; }

/* sticky action bar */
.actionbar {
    order: 3;
    flex: none;
    display: flex; gap: 10px;
    padding: 10px 16px calc(10px + var(--safe-b));
    background: var(--bg);
    border-top: 1px solid var(--line);
}
[data-tg] .actionbar { display: none; }
[data-tg] .app { padding-bottom: var(--safe-b); }

/* ------------------------------------------------------------------ stage */
.stage-col {
    order: 1;
    position: relative;
    overflow: hidden;
    display: none;
    place-items: center;
    margin: 4px 16px 6px;
    padding: 14px;
    border-radius: var(--r-lg);
    background: var(--panel-gradient);
    container-type: size;
}
.stage-col .motif { top: auto; bottom: -80px; left: auto; right: -80px; width: 460px; height: 460px;
    -webkit-mask-image: radial-gradient(circle at 100% 100%, #000 25%, transparent 70%);
    mask-image: radial-gradient(circle at 100% 100%, #000 25%, transparent 70%); }
.app[data-step="3"] .stage-col,
.app[data-step="4"] .stage-col { display: grid; flex: 1 1 0; min-height: 220px; }

.stage {
    --ar: 1;
    position: relative;
    direction: ltr;
    width: min(100%, calc(56vh * var(--ar)));
    width: min(100cqw, calc(100cqh * var(--ar)));
    aspect-ratio: var(--ar);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 18px 48px rgba(0, 0, 0, .32);
}
.stage.is-empty { background: rgba(247, 246, 242, .08); box-shadow: none; }
.stage__window { position: absolute; inset: 0; overflow: hidden; }
.stage__sample, .stage__crop { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage__crop { visibility: hidden; }
.stage__crop:focus-visible { outline: none; }
.stage:has(.stage__crop:focus-visible) { outline: 3px solid #F7F6F2; outline-offset: 3px; }
.stage__crop img { display: block; max-width: 100%; }
.stage.has-photo .stage__crop { visibility: visible; }
.stage.has-photo .stage__sample { visibility: hidden; }
.stage__frame {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none;
    user-select: none; -webkit-user-select: none;
}
.stage__text { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage__result { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.show-result .stage__window, .stage.show-result .stage__frame, .stage.show-result .stage__text { visibility: hidden; }
.stage.is-empty .stage__frame, .stage.is-empty .stage__window, .stage.is-empty .stage__text { visibility: hidden; }
.stage__busy {
    position: absolute; inset: 0; z-index: 5;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: rgba(25, 27, 29, .6);
    color: #F7F6F2; font-size: 15px; font-weight: 500;
    direction: rtl;
}
.spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(247, 246, 242, .3); border-top-color: #F7F6F2;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage-note { display: none; }
.app[data-step="3"] .stage-col { padding-bottom: 36px; }
.app[data-step="3"] .stage-note {
    display: block;
    position: absolute; bottom: 9px; left: 12px; right: 12px;
    text-align: center;
    color: rgba(247, 246, 242, .85);
    font-size: 12.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 399px) {
    .stepper { gap: 4px; padding-inline: 12px; }
    .stepper__label { font-size: 12.5px; }
    .stepper__num { width: 24px; height: 24px; font-size: 12px; }
}

/* Cropper: the crop box is the fixed photo window, so hide all of its chrome
   and let drags fall through to the drag box (which moves the photo). */
.stage .cropper-container { touch-action: none; }
.stage .cropper-crop-box { pointer-events: none; }
.stage .cropper-view-box { outline: 0; }
.stage .cropper-face { background: transparent; }
.stage .cropper-drag-box { cursor: grab; }
.stage .cropper-drag-box:active { cursor: grabbing; }

/* ------------------------------------------------------------------ toasts */
.toasts {
    position: fixed; z-index: 50;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 50%; transform: translateX(-50%);
    width: min(440px, calc(100% - 32px));
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px 10px 14px;
    padding-inline-start: 14px;
    border-radius: var(--r-sm);
    background: var(--toast-bg); color: var(--toast-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    font-size: 14px;
    animation: toast-in .22s ease-out;
}
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.toast__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #5D8E80; }
.toast--error .toast__dot { background: #E36D6D; }
.toast--success .toast__dot { background: #467D6D; }
.toast__text { flex: 1; }
.toast__close {
    flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px;
    background: transparent; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; opacity: .7;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.noscript { padding: 24px; text-align: center; }

/* ------------------------------------------------------------------ desktop */
@media (min-width: 960px) {
    .masthead { padding-inline: 24px; }
    .masthead__logo { height: 60px; }
    .masthead__slogan { font-size: 18px; }

    .app {
        display: grid;
        grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
        gap: 20px;
        padding: 20px 24px 24px;
        max-width: 1360px;
        margin: 0 auto;
    }
    .panel {
        display: flex; flex-direction: column;
        min-height: 0;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--r-lg);
        overflow: hidden;
    }
    .stepper { padding: 16px 20px 4px; }
    .view { padding: 14px 20px 20px; flex: 1; overflow-y: auto; }
    .view__head--compact { display: block; }
    .view__title { font-size: 23px; }
    .frame-card, .chosen-frame, .dropzone, .tool { background: var(--bg); }
    .frame-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .actionbar { background: var(--surface); padding: 14px 20px; }

    .stage-col,
    .app[data-step] .stage-col {
        display: grid;
        margin: 0;
        padding: 48px 48px 64px;
        border-radius: 28px;
        min-height: 0;
    }
    .stage-col .motif { width: 720px; height: 720px; bottom: -140px; right: -140px; }
    .stage-note {
        display: block;
        position: absolute; bottom: 20px; left: 0; right: 0;
        text-align: center;
        color: rgba(247, 246, 242, .82);
        font-size: 13.5px;
    }
    .dropzone { min-height: 260px; }
}

@media (min-width: 960px) and (max-height: 700px) {
    .masthead__logo { height: 44px; }
    .stage-col, .app[data-step] .stage-col { padding: 28px 28px 48px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ================================================================== admin */
.page-admin { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.admin-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16px calc(32px + var(--safe-b)); }
.admin-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-bar h1 { font-size: 22px; font-weight: 600; flex: 1; min-width: 0; }
.admin-bar .btn { min-height: 44px; }

.login {
    max-width: 420px; margin: 24px auto 0;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); overflow: hidden;
    box-shadow: var(--shadow);
}
.login__brand { position: relative; overflow: hidden; background: var(--panel-gradient); padding: 28px 24px; color: #F7F6F2; }
.login__brand img { height: 84px; width: auto; }
.login__brand p { margin-top: 14px; font-size: 14px; opacity: .9; }
.login__form { padding: 22px 24px 24px; display: grid; gap: 14px; }
.login__form h1 { font-size: 20px; font-weight: 600; }
.form-error { color: var(--danger-text); font-size: 14px; min-height: 1.5em; }

.field { display: grid; gap: 6px; }
.field > span, .field-label { font-size: 14px; font-weight: 500; }
.field small, .hint { font-size: 13px; color: var(--muted); }
.input, .field input[type=text], .field input[type=number], .field input[type=password] {
    width: 100%; min-height: 48px; padding: 10px 14px;
    border-radius: 12px; border: 1px solid var(--line-strong);
    background: var(--bg); color: var(--text);
}
.input:focus-visible, .field input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.field input[type=file] { font-size: 14px; padding: 10px 0; }
.field input[type=color] { width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 4px; background: var(--bg); cursor: pointer; }
.field input[type=range] { width: 100%; accent-color: var(--primary); min-height: 44px; }

.admin-grid { display: grid; gap: 20px; align-items: start; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.admin-item {
    display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center;
    padding: 10px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.admin-item.is-off .admin-item__thumb { opacity: .5; }
.admin-item__thumb { position: relative; width: 72px; height: 72px; border-radius: 12px; background: var(--well); }
.admin-item__thumb canvas { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); object-fit: contain; }
.admin-item__body { min-width: 0; }
.admin-item__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item__badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.admin-item__actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.admin-item__actions .switch { margin-inline-end: auto; }

.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background-color .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 21px; }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.editor-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 18px; display: grid; gap: 16px;
}
.editor-card h2 { font-size: 18px; font-weight: 600; }
.editor-preview { position: relative; overflow: hidden; border-radius: var(--r-md); background: var(--panel-gradient); padding: 20px; display: grid; place-items: center; }
.preview-stage { position: relative; z-index: 1; direction: ltr; width: 240px; height: 240px; max-width: 100%; }
.preview-stage canvas { width: 100%; height: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.editor-preview .motif { width: 360px; height: 360px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    min-height: 40px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; font-size: 14px;
}
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.ratio-inputs { direction: ltr; display: flex; align-items: center; gap: 8px; max-width: 220px; }
.ratio-inputs span { flex: none; }

@media (min-width: 960px) {
    .admin-main { padding: 28px 24px 48px; }
    .admin-grid { grid-template-columns: minmax(0, 1fr) 500px; }
    .admin-grid--solo { grid-template-columns: minmax(0, 720px); }
    /* the form is long (text fields): keep the preview in view while editing */
    .editor-preview { position: sticky; top: 12px; z-index: 3; }
}
button.pill-link { cursor: pointer; font-family: inherit; }
.page-admin .masthead__slogan { font-size: 15px; }
@media (max-width: 459px) {
    .page-admin .masthead__text { display: none; }
}
.file-field { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.file-field__name { font-size: 14px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-field:focus-within .btn { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ admin: text fields */
.tf-boxes { position: absolute; inset: 0; }
.tf-box {
    position: absolute;
    border: 1.5px dashed rgba(247, 246, 242, .9);
    box-shadow: 0 0 0 1px rgba(36, 40, 42, .45), inset 0 0 0 1px rgba(36, 40, 42, .25);
    border-radius: 3px;
    cursor: move;
    touch-action: none;
    user-select: none; -webkit-user-select: none;
}
.tf-box:hover { background: rgba(247, 246, 242, .08); }
.tf-box.is-selected {
    border: 1.5px solid #F7F6F2;
    background: rgba(22, 92, 72, .14);
    box-shadow: 0 0 0 1.5px #165C48, 0 0 0 4px rgba(247, 246, 242, .35);
}
.tf-box.is-dragging { background: rgba(22, 92, 72, .22); }
.tf-box__label {
    position: absolute; bottom: 100%; right: -1.5px; margin-bottom: 4px;
    max-width: 180px; padding: 0 7px;
    border-radius: 6px;
    background: rgba(36, 40, 42, .85); color: #F7F6F2;
    font-size: 11px; font-weight: 500; line-height: 1.75;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    direction: rtl; pointer-events: none;
}
.tf-box:not(.is-selected) .tf-box__label { min-width: 18px; padding: 0 5px; text-align: center; font-weight: 600; }
.tf-box.is-selected { z-index: 1; }
.tf-box.is-selected .tf-box__label { background: #165C48; }
.tf-box__handle {
    display: none;
    position: absolute; right: -9px; bottom: -9px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #F7F6F2; border: 2.5px solid #165C48;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
    cursor: nwse-resize;
}
.tf-box__handle::after { content: ""; position: absolute; inset: -12px; } /* comfortable touch target */
.tf-box.is-selected .tf-box__handle { display: block; }

.tf-section { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.tf-section__head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.tf-section__head h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tf-section > .hint { margin-top: -4px; line-height: 1.6; }
.tf-section__head .btn { flex: none; gap: 6px; }
.tf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tf-empty { font-size: 13.5px; color: var(--muted); padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.tf-item {
    display: flex; align-items: center; gap: 2px;
    padding: 3px;
    border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
.tf-item.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--accent-ring); }
.tf-item__main {
    flex: 1; min-width: 0; min-height: 44px;
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px; border: 0; background: none; cursor: pointer; text-align: start; border-radius: 11px;
}
.tf-item__num {
    flex: none; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12.5px; font-weight: 600;
    background: var(--accent-tint); color: var(--accent-text);
}
.tf-item.is-selected .tf-item__num { background: var(--primary); color: var(--on-primary); }
.tf-item__text { min-width: 0; display: grid; line-height: 1.4; }
.tf-item__text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-item__text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-item__actions { flex: none; display: flex; }
.icon-btn--sm { width: 40px; height: 40px; }
.icon-btn--sm svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.icon-btn--danger { color: var(--danger-text); }
.icon-btn--danger:hover:not(:disabled) { background: var(--danger-tint); }

.tf-editor {
    display: grid; gap: 14px;
    padding: 14px;
    border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line);
}
.tf-editor .input, .tf-editor .field input[type=text], .tf-editor .field input[type=number], .tf-editor .field input[type=color] { background: var(--surface); }
.field > span small, .field > label small { font-weight: 400; color: var(--muted); font-size: 12px; }
.tf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.tf-span2 { grid-column: 1 / -1; }
.tf-switch { min-height: 48px; }
.tf-box-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tf-box-inputs label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.tf-box-inputs .input { min-height: 44px; padding: 8px 4px; text-align: center; font-variant-numeric: tabular-nums; }
select.input { min-height: 48px; padding-block: 0; cursor: pointer; }
.seg {
    display: flex; overflow: hidden;
    border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
}
.seg button {
    flex: 1; min-width: 0; min-height: 44px;
    border: 0; border-inline-start: 1px solid var(--line); background: none; cursor: pointer;
    font-size: 14px;
}
.seg button:first-child { border-inline-start: 0; }
.seg button.is-active { background: var(--primary); color: var(--on-primary); }
.seg button:focus-visible { outline-offset: -3px; }
.tf-extra { display: grid; gap: 6px; }
.tf-extra .switch { min-height: 40px; }
.tf-extra__body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.tf-id { font-size: 12.5px; }
.tf-id bdi { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
@media (max-width: 380px) {
    .tf-grid, .tf-extra__body { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ admin: tabs */
.admin-tabs {
    display: flex; gap: 4px;
    margin: -4px 0 20px;
    border-bottom: 1px solid var(--line);
}
.admin-tab {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 48px; padding: 0 16px;
    margin-bottom: -1px;
    border: 0; border-bottom: 2.5px solid transparent;
    background: none; cursor: pointer;
    font-size: 15px; font-weight: 500; color: var(--muted);
    border-radius: 10px 10px 0 0;
}
.admin-tab svg { width: 20px; height: 20px; }
.admin-tab:hover { color: var(--text); background: var(--accent-tint); }
.admin-tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.admin-tab[aria-selected="true"] svg { color: var(--accent-text); }
.admin-tab:focus-visible { outline-offset: -3px; }
[data-theme="dark"] .admin-tab[aria-selected="true"] { border-bottom-color: var(--accent-text); }

/* ------------------------------------------------------------------ admin: operations log */
.ops-section-title { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .01em; margin-bottom: 10px; }
.ops-summary { margin-bottom: 28px; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi {
    position: relative;
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0; padding: 14px 16px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.kpi__label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi__value { font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; color: var(--text); }
.kpi__sub { font-size: 12px; color: var(--muted); min-height: 1.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi[data-kpi="todayImages"]::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 16px; bottom: 16px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--chart-bar);
}
.kpi.has-alert .kpi__sub { color: var(--danger-text); font-weight: 500; }
.kpis[aria-busy="true"] .kpi__value { color: transparent; width: 56px; border-radius: 8px; background: var(--well); animation: pulse 1.4s ease-in-out infinite; }

.ops-charts { display: grid; gap: 12px; }
.ops-card {
    position: relative; margin: 0; min-width: 0;
    padding: 14px 16px 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.ops-card__title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.ops-card__title span { font-weight: 400; color: var(--muted); font-size: 13px; }
.ops-chart__plot { min-height: 170px; }
.chart { overflow: visible; touch-action: pan-y; }
.chart:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 8px; }
.chart__grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart__grid line.chart__base { stroke: var(--line-strong); }
.chart__tick { font-size: 11px; fill: var(--muted); font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart__label { font-size: 12px; font-weight: 600; fill: var(--text); font-family: var(--font); }
.chart__note { font-size: 13px; fill: var(--muted); font-family: var(--font); }
.chart__bar { fill: var(--chart-bar); transition: fill .12s; }
.chart__bar.is-active { fill: var(--chart-bar-hover); }
.ops-tooltip {
    position: absolute; z-index: 2; pointer-events: none;
    display: grid; gap: 0; padding: 6px 10px;
    background: var(--toast-bg); color: var(--toast-text);
    border-radius: 10px; box-shadow: var(--shadow);
    font-size: 12px; line-height: 1.45; white-space: nowrap; text-align: center;
}
.ops-tooltip b { font-size: 14px; font-weight: 600; }
.ops-tooltip span { opacity: .8; }

.meter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.meter__name {
    min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; text-align: start;
    font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meter__name:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.meter__value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter__track { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--chart-track); overflow: hidden; }
.meter__fill { display: block; height: 100%; border-radius: 999px; background: var(--chart-bar); }
.meter-list__empty { font-size: 13.5px; color: var(--muted); }

.ops-filters {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; align-items: end;
    margin-bottom: 12px;
}
.ops-filter { display: grid; gap: 4px; min-width: 0; }
.ops-filter__label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ops-filter .input { min-height: 44px; background: var(--surface); }
.ops-filter input[type=date] { padding-block: 0; padding-inline: 10px; width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; }
.ops-filter--search { grid-column: 1 / -1; position: relative; }
.ops-filter--search svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ops-filter--search .input { padding-inline-start: 42px; }
.ops-filters__reset { grid-column: 1 / -1; justify-self: start; }

/* list: stacked cards on phones, a table from 760px */
.ops-table, .ops-table tbody { display: block; }
.ops-table thead { display: none; }
.ops-table tbody { display: grid; gap: 8px; }
.ops-table.is-refreshing tbody { opacity: .55; transition: opacity .15s; }
.op-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px;
    padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
/* card: chip + time / user / frame + source */
.op-row td { display: block; min-width: 0; padding: 0; }
.op-row .op-type { grid-column: 1; grid-row: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.op-row .op-time { grid-column: 2; grid-row: 1; align-self: start; display: flex; align-items: baseline; gap: 6px; padding-top: 2px; }
.op-row .op-time .op-sub::before { content: "· "; }
.op-row .op-user-cell { grid-column: 1 / -1; grid-row: 2; font-weight: 500; margin-top: 4px; }
.op-row .op-frame-cell { grid-column: 1; grid-row: 3; display: flex; align-items: baseline; gap: 6px; font-size: 13.5px; color: var(--muted); }
.op-row .op-frame-cell::before { content: attr(data-label) ":"; font-size: 12.5px; }
.op-row .op-frame-cell.is-empty { visibility: hidden; }
.op-row .op-source { grid-column: 2; grid-row: 3; align-self: center; }
.op-row .op-detail { flex-basis: 100%; }

.op-time time { font-size: 13px; font-weight: 500; white-space: nowrap; cursor: help; }
.op-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.op-time .op-sub { font-variant-numeric: tabular-nums; white-space: nowrap; }
.op-user { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.op-user bdi, .op-frame { overflow-wrap: anywhere; }
.op-none { color: var(--muted); }
.op-frame-cell .op-frame { color: var(--text); }

.op-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 10px; border-radius: 999px;
    font-size: 12.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
    background: var(--well); color: var(--text);
}
.op-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.op-chip--image { background: var(--accent-tint); color: var(--accent-text); }
.op-chip--image .op-chip__dot { background: var(--chart-bar); }
.op-chip--admin { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.op-chip--admin .op-chip__dot { background: var(--charcoal); }
[data-theme="dark"] .op-chip--admin .op-chip__dot { background: var(--cream); }
.op-chip--muted { color: var(--muted); }
.op-chip--danger { background: var(--danger-tint); color: var(--danger-text); }
.op-chip--danger .op-chip__dot { background: var(--red); }

.op-source__tag { font-size: 12px; color: var(--muted); padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); white-space: nowrap; }

.op-row.is-skeleton { pointer-events: none; }
.op-row.is-skeleton .op-frame-cell::before { content: none; }
.sk { display: inline-block; height: 12px; border-radius: 6px; background: var(--well); animation: pulse 1.4s ease-in-out infinite; }
.op-row.is-skeleton .op-time .sk { width: 56px !important; }

.ops-empty { margin-top: 4px; }
.ops-more { display: flex; justify-content: center; margin-top: 14px; }
.ops-more .btn { min-width: 180px; }

@media (min-width: 640px) {
    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ops-filters { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1.2fr)) repeat(2, minmax(0, 1fr)); }
    .ops-filter--search { grid-column: auto; }
    .ops-filters__reset { grid-column: 1 / -1; }
}
@media (min-width: 960px) {
    .ops-charts { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
    .kpi__value { font-size: 34px; }
}
@media (min-width: 760px) {
    .ops-table-wrap {
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
    }
    .ops-table { display: table; width: 100%; border-collapse: collapse; }
    .ops-table thead { display: table-header-group; }
    .ops-table tbody { display: table-row-group; }
    .ops-table th {
        padding: 10px 16px; text-align: start;
        font-size: 12.5px; font-weight: 500; color: var(--muted);
        background: var(--well); border-bottom: 1px solid var(--line);
    }
    .op-row { display: table-row; padding: 0; background: none; border: 0; border-radius: 0; }
    .op-row td, .op-row .op-frame-cell, .op-row .op-source, .op-row .op-type, .op-row .op-time {
        display: table-cell; padding: 11px 16px; vertical-align: middle;
        border-bottom: 1px solid var(--line); text-align: start;
    }
    .op-row:last-child td { border-bottom: 0; }
    .op-row:hover td { background: var(--accent-tint); }
    .op-row .op-frame-cell { font-size: 14px; color: var(--text); }
    .op-row .op-frame-cell::before, .op-row .op-time .op-sub::before { content: none; }
    .op-row .op-frame-cell.is-empty { visibility: visible; }
    .op-row .op-user-cell { margin-top: 0; }
    .op-row .op-time { width: 150px; }
    .op-row .op-time time { display: block; }
    .op-row .op-type { width: 230px; }
    .op-row .op-type .op-chip { margin-inline-end: 6px; }
    .op-row .op-detail { display: block; margin-top: 3px; }
    .op-row .op-source { width: 100px; }
    .ops-table-wrap:has(.ops-table[hidden]) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .sk, .kpis[aria-busy="true"] .kpi__value { animation: none; }
}
