/* Stop-motion — tokenid, siis komponendid. Pinnad/tekstid ainult teemamuutujatest. */
/* Tiitrite lisafondid (joonistus.js FONTS) — Fontsource 5.3.0, OFL, sama allikas mis videotootlus/js/fonts.js */
@font-face {
    font-family: "Lora"; font-style: normal; font-weight: 700; font-display: swap;
    src: url("../assets/vendor/fontsource-5.3.0/lora/lora-latin-700-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Lora"; font-style: normal; font-weight: 700; font-display: swap;
    src: url("../assets/vendor/fontsource-5.3.0/lora/lora-latin-ext-700-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap;
    src: url("../assets/vendor/fontsource-5.3.0/oswald/oswald-latin-700-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap;
    src: url("../assets/vendor/fontsource-5.3.0/oswald/oswald-latin-ext-700-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
    --sm-accent-soft: var(--accent-soft, rgba(0, 209, 178, 0.09));
    --sm-ring: var(--accent-ring, rgba(0, 209, 178, 0.32));
    --sm-shutter: #e11d48;
    --sm-danger: #c81e48;
    --sm-r-btn: 8px;
    --sm-r-card: 12px;
    --sm-r-panel: 16px;
}
[data-theme="dark"] { --sm-shutter: #f43f5e; --sm-danger: #fb7185; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --sm-shutter: #f43f5e; --sm-danger: #fb7185; }
}

.sm-body { background: var(--bg-primary); }
/* Bulma .section / .button / flex-reeglid kirjutavad `hidden`-atribuudi üle — peitmine käib
   siin ainult atribuudiga, seega peab see alati võitma. */
#sm-app [hidden] { display: none !important; }
.sm-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Animatsioonid ---------- */
.sm-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; margin-bottom: 32px; }
.sm-head-text { flex: 999 1 320px; min-width: 0; }
.sm-badge {
    flex: none; width: 56px; height: 56px; border-radius: 14px; font-size: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--sm-accent-soft); color: var(--accent-color);
}
.sm-h1 { margin-bottom: 4px !important; letter-spacing: -0.015em; }
.sm-lead { color: var(--text-secondary); max-width: 60ch; line-height: 1.5; }
/* Polster miinus raam: Bulma nupu raam on 0 px (täidetud) või 1 px (kontuur) ja fookuses 1 px —
   välislaius jääb samaks. Kontuurnupu hover-raam: css/style.css „Kontuurnupp ei tohi…". */
.sm-cta { flex: none; font-weight: 600; height: 48px; padding-inline: calc(20px - var(--bulma-button-border-width)); border-radius: var(--sm-r-btn); }
.sm-empty { color: var(--text-secondary); margin: 16px 0; }
.sm-note {
    display: flex; gap: 12px; align-items: flex-start; margin-top: 32px; max-width: 720px;
    padding: 16px; border-radius: var(--sm-r-card); font-size: 14px; color: var(--text-secondary);
    background: var(--bg-card); border: 1px solid var(--border-light, var(--border-color));
}
.sm-note i { margin-top: 3px; }
/* Hoiatus: brauser võib mälu ise tühjendada (püsivusluba puudub) */
.sm-persist-warn { color: var(--text-primary); border-left: 4px solid hsl(42, 100%, 45%); }
.sm-persist-warn[hidden] { display: none; }
.sm-persist-warn i { color: hsl(38, 95%, 38%); }
.sm-persist-warn + .sm-note { margin-top: 12px; }
[data-theme="dark"] .sm-persist-warn i { color: hsl(45, 100%, 60%); }

.sm-grid {
    display: grid; gap: 16px; margin-top: 8px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.sm-card {
    background: var(--bg-card); border: 1px solid var(--border-light, var(--border-color));
    border-radius: var(--sm-r-card); overflow: hidden; box-shadow: var(--shadow-card);
    display: flex; flex-direction: column;
}
/* max-height: 9:16 animatsiooni kaart oleks muidu ~2x kõrgem kui teised */
.sm-card-thumb {
    display: flex; align-items: center; justify-content: center; width: 100%; max-height: 240px;
    border: 0; padding: 0; cursor: pointer; background: var(--bg-secondary);
    color: var(--text-muted); font-size: 32px; overflow: hidden;
}
.sm-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sm-card-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; }
.sm-card-title { font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.sm-card-meta { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.sm-card-body .dk-actions { margin-top: auto; }

/* ---------- Stuudio: kerimata täisaken ----------
   Stuudio katab kogu akna (saidi menüüriba peidetud) ja jagab selle grid-aladeks; lava võtab
   kogu ülejäänud ruumi. Kolm paigutust: lai (seaded paremal), kitsas/püsti (seaded paneelil
   alt) ja madal pikali (telefon põiki: kaadrid vasakul püsti, nupud paremal).
   Lai vaade: pildistamise nupud veerus lava paremal (joonistades tööriistad lava vasakul) — lava
   on kõrgusega piiratud ja lava all olnud nupuread võtsid sellelt ~145 px (2026-11-22). */
body.sm-in-studio { overflow: hidden; }
body.sm-in-studio > nav.navbar { display: none; }
.sm-studio {
    position: fixed; inset: 0; z-index: 35; overflow: hidden;
    display: grid; gap: 12px 16px; padding: 12px 16px;
    background: var(--bg-primary);
    grid-template-columns: minmax(0, 1fr) 84px 320px;
    /* Lava rida ei ole suurem kui laiusega piiratud kaader (--sm-ratio pannakse stuudiole app.js-is):
       üle jääv kõrgus läheb kaadririba alla (riba rida venib, riba ise align-self: start), mitte
       lava kohale ja alla (iPad, 2026-11-21). 468 = 2 × 16 polster + 84 nupuveerg + 320 paneel + 2 × 16 vahe */
    grid-template-rows: auto minmax(0, calc((100vw - 468px) / var(--sm-ratio, 1.7778))) minmax(auto, 1fr);
    grid-template-areas: "top top panel" "stage ctl panel" "strip strip panel";
}
.sm-btn { height: 44px; border-radius: var(--sm-r-btn); font-weight: 600; }
.sm-icon-btn { width: 44px; padding: 0; }
.sm-danger, .sm-danger:hover { color: var(--sm-danger); }

.sm-topbar { grid-area: top; display: flex; gap: 12px; align-items: center; min-width: 0; }
.sm-title {
    flex: 1 1 auto; min-width: 0; margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3;
    color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sm-settings-btn { display: none; }
.sm-export { flex: none; font-weight: 700; padding-inline: 20px; }

/* Video kokkupaneku seis: kaart lava kohal (kerimata vaates ei tohi ta lava kokku suruda) */
.sm-export-state {
    position: absolute; z-index: 6; top: 68px; left: 50%; transform: translateX(-50%);
    width: min(640px, calc(100% - 32px)); max-height: calc(100% - 80px); overflow: auto;
    display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; align-items: safe center;
    padding: 12px 44px 12px 16px; background: var(--bg-card); border-radius: var(--sm-r-card);
    border: 1px solid var(--border-light, var(--border-color));
    box-shadow: var(--shadow-3, 0 8px 32px rgba(0, 0, 0, 0.28));
}
.sm-export-close { position: absolute; top: 12px; right: 12px; }
.sm-export-progress { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sm-export-progress .progress { margin: 0; }
.sm-export-state .buttons { margin: 0; flex-wrap: wrap; }
.sm-export-state .buttons .button { margin-bottom: 0; }

/* Lava = suurim kast õiges kuvasuhtes, mis alale mahub (laius JA kõrgus). Konteineri ühikud,
   mitte max-height + aspect-ratio — see moonutaks kasti ja eelvaade näitaks muud kui kaader. */
.sm-stage-area {
    grid-area: stage; min-width: 0; min-height: 0; container-type: size;
    display: grid; place-items: center; position: relative;
}
/* Püsti telefonis on laiuti kaader ekraani laiusega piiratud (~24% ekraanist) — vihje lava all
   tühjas ribas. Kaob esimese kaadriga (kuvasuhe lukus) ja püstise/ruudu kuvasuhtega. */
.sm-rotate-hint {
    position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
    width: max-content; max-width: 100%; display: none; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 1.3;
    background: var(--bg-card); color: var(--text-secondary);
    border: 1px solid var(--border-light, var(--border-color));
}
.sm-rotate-hint i { font-size: 16px; animation: sm-rotate 2.4s var(--ease, ease) infinite; }
@keyframes sm-rotate { 0%, 35% { rotate: 0deg; } 55%, 85% { rotate: -90deg; } 100% { rotate: 0deg; } }
@media (prefers-reduced-motion: reduce) { .sm-rotate-hint i { animation: none; } }
@media (orientation: portrait) and (max-width: 899px) {
    .sm-studio.is-rotate-hint .sm-rotate-hint { display: flex; }
}
.sm-stage {
    position: relative; width: 100%;
    width: min(100cqw, 100cqh * var(--sm-ratio, 1.7778));
    background: #000; border-radius: var(--sm-r-panel); overflow: hidden;
}
.sm-stage video, .sm-stage .sm-base, .sm-stage .sm-onion, .sm-stage .sm-play-img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.sm-stage .sm-base, .sm-stage .sm-onion { pointer-events: none; }
/* Kaamerapildi peal: alati hele kiri tumedal looril (teema värvid ei loe pildi peal).
   Silt, mitte nupp: väike nurgaraadius ja tavakiri, et ei näeks välja nagu ümarad lavanupud. */
.sm-chip {
    position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center;
    max-width: calc(100% - 20px); height: 24px; padding: 0 8px; border-radius: 6px; pointer-events: none;
    background: rgba(0, 0, 0, 0.5); color: rgba(255, 255, 255, 0.92); font-size: 12px; font-weight: 500;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Uus kaader läheb filmi keskele, mitte lõppu — peab silma hakkama (merevaigukollane pildi peal
   loeb mõlemas teemas; tume kiri annab kontrasti ~10:1) */
.sm-chip.is-insert {
    height: auto; min-height: 28px; padding: 4px 10px; background: #fbbf24; color: #1c1917;
    font-size: 13px; font-weight: 700; line-height: 1.25; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    /* Kitsal laval (9:16 põiki-telefonis) murdub reale, mitte ei lõigata kolme punktiga */
    white-space: normal; text-align: right;
}
/* Murdub reale: kitsal laval (9:16 pikali-telefonis ~130 px) ei tohi režiimilüliti lava taha jääda.
   Kast ise laseb puudutused läbi — muidu ei saaks tühjas ülaribas joonistada. */
.sm-stage-tools {
    position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2;
    display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none;
}
.sm-stage-tools > * { pointer-events: auto; }
.sm-overlay-btn {
    width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
    background: rgba(0, 0, 0, 0.55); color: #fff;
}
@media (hover: hover) { .sm-overlay-btn:hover { background: rgba(0, 0, 0, 0.75); } }
.sm-overlay-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* Töörežiim (kaamera / joonistus) lava nurgas — sama tume loor nagu teistel lavanuppudel */
.sm-mode {
    display: flex; gap: 2px; padding: 3px; margin: 0; min-width: 0; border: 0;
    border-radius: 999px; background: rgba(0, 0, 0, 0.55);
}
/* Kaks klassi: css/style.css puuteseadme reegel `label:has(> input[type="radio"])` (0-1-2) */
.sm-stage .sm-mode label { position: relative; display: block; cursor: pointer; }
.sm-mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sm-mode label > span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%; font-size: 15px; color: rgba(255, 255, 255, 0.85);
    transition: background-color var(--dur-fast, 150ms) var(--ease, ease);
}
@media (hover: hover) { .sm-mode input:not(:checked):hover + span { background: rgba(255, 255, 255, 0.18); color: #fff; } }
.sm-mode input:checked + span { background: #fff; color: #111; }
.sm-mode input:focus-visible + span { outline: 3px solid #fff; outline-offset: 2px; }
/* Puuteseadmel sama puuteala nagu teistel lavanuppudel (40 px) */
@media (pointer: coarse) { .sm-mode label > span { width: 40px; height: 40px; font-size: 16px; } }
/* Teksti font lava peal (tekstitööriist või valitud tekst) — sama tume loor */
.sm-textbar { display: flex; }
.sm-textbar[hidden], .sm-studio:not(.is-draw) .sm-textbar { display: none; }
.sm-font-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; max-width: 100%; padding: 0 14px 0 12px;
    border: 0; border-radius: 999px; cursor: pointer; background: rgba(0, 0, 0, 0.55); color: #fff;
    font-size: 14px; font-weight: 600; white-space: nowrap;
}
@media (hover: hover) { .sm-font-btn:hover { background: rgba(0, 0, 0, 0.75); } }
.sm-font-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.sm-font-aa { font-size: 20px; line-height: 1; }
.sm-font-name { overflow: hidden; text-overflow: ellipsis; }
.sm-font-caret { font-size: 11px; opacity: 0.85; }
/* Madalal põiki-ekraanil (700×245) ei mahu viis fonti — aken kerib, ei jookse ekraanilt välja */
.sm-pop.sm-font-pop { width: 220px; max-height: calc(100dvh - 16px); overflow-y: auto; }
.sm-font-list { display: flex; flex-direction: column; gap: 4px; }
.sm-font-choice {
    min-height: 44px; padding: 4px 12px; border-radius: 8px; cursor: pointer; text-align: left;
    font-size: 20px; line-height: 1.2; background: var(--bg-primary); color: var(--text-primary);
    border: 2px solid transparent;
}
@media (hover: hover) { .sm-font-choice:not([aria-pressed="true"]):hover { background: var(--bg-hover, var(--bg-secondary)); } }
.sm-font-choice[aria-pressed="true"] { border-color: var(--accent-color); }
.sm-font-choice:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
/* Kaadri kestus: kuus valikut 3 × 2 ruudustikus + oma kestuse väli; madalal ekraanil aken kerib */
.sm-pop.sm-hold-pop { width: 252px; max-height: calc(100dvh - 16px); overflow-y: auto; }
.sm-hold-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sm-hold-choice {
    min-height: 44px; padding: 4px 6px; border-radius: 8px; cursor: pointer;
    font-size: 15px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums;
    background: var(--bg-primary); color: var(--text-primary); border: 2px solid transparent;
}
.sm-hold-choice.is-default { grid-column: 1 / -1; font-weight: 400; }
@media (hover: hover) { .sm-hold-choice:not([aria-pressed="true"]):hover { background: var(--bg-hover, var(--bg-secondary)); } }
.sm-hold-choice[aria-pressed="true"] { border-color: var(--accent-color); }
.sm-hold-choice:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-pop-note { font-size: 13px; color: var(--text-muted); }
/* Oma kestus: väli + „Määra" ühel real; 16 px font, et iOS ei suumiks välja fookusesse */
.sm-hold-custom { margin-top: 10px; }
.sm-hold-custom-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.sm-hold-custom-row { display: flex; gap: 6px; }
.sm-hold-custom-row .input.sm-hold-input {
    flex: 1 1 auto; min-width: 0; height: 44px; font-size: 16px; font-variant-numeric: tabular-nums;
    background: var(--bg-primary); color: var(--text-primary); border-color: var(--border-color);
}
.sm-hold-custom-row .input.sm-hold-input::placeholder { color: var(--text-muted); }
.sm-hold-custom-row .input.sm-hold-input.is-current { border: 2px solid var(--accent-color); }
.sm-hold-custom-row .input.sm-hold-input[aria-invalid="true"] { border-color: var(--sm-danger); }
/* Aken ise saab fookuse ainult puuteekraanil oma kestusega kaadril (vt toggleHoldPop) — nagu
   modaali konteiner css/style.css-is: ekraanilugeja loeb dialoogi, rõngast kogu akna ümber pole vaja */
.sm-hold-pop[tabindex="-1"]:focus, .sm-hold-pop[tabindex="-1"]:focus-visible { outline: none !important; }
.sm-hold-custom-row .button.sm-hold-set { flex: none; height: 44px; }
.sm-hold-custom .sm-pop-note { margin-top: 4px; }
.sm-hold-custom .sm-pop-note.is-error { color: var(--sm-danger); font-weight: 600; }
/* Madalal põiki-ekraanil üldine vihje ära — aken kerib niigi */
@media (max-height: 340px) { .sm-hold-pop > .sm-pop-note { display: none; } }
.sm-hold-val { font-variant-numeric: tabular-nums; }
.sm-hold-btn.is-held { border-color: var(--accent-color); }
#sm-fs .sm-fs-off, #sm-fs[aria-pressed="true"] .sm-fs-on { display: none; }
#sm-fs[aria-pressed="true"] .sm-fs-off { display: inline-block; }
.sm-stage-msg {
    position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; align-items: safe center;
    justify-content: center; justify-content: safe center; gap: 12px; padding: 16px; text-align: center; overflow: auto;
    background: var(--bg-card); color: var(--text-primary);
}
.sm-stage-msg p { max-width: 44ch; }
/* Keskel, aga kitsal laval (9:16 põiki) üle ajades kerib algusest — justify-content:center lõikaks ülaosa ära */
.sm-stage-msg { justify-content: flex-start; }
.sm-stage-msg > :first-child { margin-top: auto; }
.sm-stage-msg > :last-child { margin-bottom: auto; }
.sm-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.sm-flash.is-on { animation: sm-flash 220ms var(--ease-out, ease-out); }
@keyframes sm-flash { from { opacity: 0.55; } to { opacity: 0; } }

/* Pildistamise nupud: laias vaates veerg lava paremal (päästik keskel, pilt failist üleval, esitus
   all); kitsas vaates ja tahvli virnas rida lava all (sm-controls-row allpool). */
.sm-controls {
    grid-area: ctl; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; min-width: 0; margin: 0;
}
.sm-controls > * { flex: none; }
.sm-controls .sm-file-btn { order: -2; }
.sm-shutter, .sm-controls .sm-kbd-hint { order: -1; }
.sm-controls .sm-kbd-hint { white-space: normal; text-align: center; line-height: 1.7; max-width: 84px; margin-top: -6px; }
.sm-ctl-btn { width: 52px; height: 52px; padding: 0; border-radius: 50%; }
.sm-ctl-btn .sm-btn-text {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.sm-shutter {
    flex: none; width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
    border: 4px solid var(--text-primary); background: transparent; padding: 4px;
    transition: scale var(--dur-fast, 150ms) var(--ease, ease);
}
.sm-shutter:active { scale: 0.94; }
.sm-shutter:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 3px; }
.sm-shutter-dot { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--sm-shutter); }
.sm-kbd-hint { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.sm-kbd-hint kbd {
    font: inherit; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
    border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-secondary);
}
.sm-file-btn { position: relative; overflow: hidden; }
.sm-file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Seaded ---------- */
.sm-panel {
    grid-area: panel; align-self: start; max-height: 100%; overflow: auto;
    display: flex; flex-direction: column; gap: 16px; padding: 16px;
    background: var(--bg-card); border: 1px solid var(--border-light, var(--border-color));
    border-radius: var(--sm-r-panel);
}
/* Pealkiri ainult lahtitõmmatavas paneelis (seal on kõrval sulgemisnupp); laias vaates on paneel
   alati näha ja „Seaded" oleks tühi rida. aria-labelledby loeb peidetud pealkirja ikka. */
.sm-panel-head { display: none; align-items: center; justify-content: space-between; gap: 12px; }
.sm-panel-h { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.sm-panel-close { display: none; }
.sm-name { height: 44px; font-weight: 600; border-radius: var(--sm-r-btn); }
.sm-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.sm-field { display: flex; flex-direction: column; gap: 8px; }
.sm-field > .sm-label { margin-bottom: 0; }
.sm-label { display: block; padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.sm-label-sub { font-weight: 400; color: var(--text-muted); }
.sm-seg {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px;
    border-radius: 10px; background: var(--bg-primary);
}
/* Kaks klassi: css/style.css puuteseadme reegel `label:has(> input[type="radio"])` (0-1-2)
   teeb sildist muidu flex-konteineri ja valikukast kahaneb telefonis sisu laiuseks. */
.sm-panel .sm-seg label { position: relative; display: block; min-width: 0; cursor: pointer; }
.sm-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.sm-seg span {
    display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 6px;
    font-size: 14px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums;
    transition: background-color var(--dur-fast, 150ms) var(--ease, ease);
}
@media (hover: hover) { .sm-seg input:not(:disabled):not(:checked):hover + span { background: var(--bg-hover, var(--bg-card)); } }
.sm-seg input:checked + span {
    background: var(--bg-card); color: var(--text-primary); font-weight: 700;
    box-shadow: var(--shadow-1, 0 1px 2px rgba(17, 17, 26, 0.06), 0 4px 12px rgba(17, 17, 26, 0.08));
}
.sm-seg input:focus-visible + span { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-seg input:disabled { cursor: not-allowed; }
.sm-seg input:disabled + span { opacity: 0.6; }
.sm-check { display: flex; gap: 12px; align-items: center; min-height: 44px; font-size: 14px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.sm-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent-color); }
.sm-range-row { display: flex; align-items: center; gap: 12px; }
.sm-range { flex: 1 1 auto; min-width: 0; margin: 0; accent-color: var(--accent-color); }
.sm-range:disabled { opacity: 0.5; }
.sm-range-val { width: 40px; text-align: right; font-size: 14px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.sm-help { font-size: 13px; color: var(--text-muted); }
.sm-lock { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
/* Pöördumatu tegevus ei pea olema paneeli silmapaistvaim element — tekstinupp (kinnitus jääb) */
.sm-clear-all {
    align-self: flex-start; height: 36px; padding-inline: 8px; margin-left: -8px; font-size: 14px;
    background: transparent; border-color: transparent; box-shadow: none;
}
@media (hover: hover) { .sm-clear-all:not(:disabled):hover { background: var(--bg-hover, var(--bg-secondary)); } }
/* Bulma keelatud nupp toob raami ja tausta tagasi */
.sm-clear-all[disabled] { background: transparent; border-color: transparent; box-shadow: none; }
/* Hiirega arvuti: tihedam paneel, et kõik mahuks ~620 px kõrgusele aknale ära (sülearvuti 150%
   suurendusega, 2026-11-22). Puuteseadmel jäävad 40–44 px puutealad. */
@media (pointer: fine) {
    .sm-panel .sm-label { margin-bottom: 6px; }
    .sm-field { gap: 6px; }
    .sm-name { height: 38px; }
    .sm-seg span { height: 32px; }
    .sm-check { min-height: 30px; gap: 10px; }
}
.sm-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, 0.5); }

/* ---------- Kaadririba ---------- */
.sm-strip-wrap {
    grid-area: strip; align-self: start; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px;
    background: var(--bg-card); border: 1px solid var(--border-light, var(--border-color));
    border-radius: var(--sm-r-card);
}
.sm-strip-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.sm-strip-h { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.sm-count { font-size: 14px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sm-sel { flex: 1 1 auto; font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sm-strip-tools { display: flex; gap: 4px; flex: none; }
/* Tagasivõtt/uuesti on kogu riba kohta, ülejäänud nupud valitud kaadri kohta — väike vahe eraldab */
.sm-strip-tools .sm-hist-last { margin-inline-end: 8px; }
.sm-ic-v { display: none; }
/* Kõrgus on FIKSEERITUD ja sisaldab kerimisriba ruumi (--sm-sb mõõdab app.js): kaadrite lisandudes
   ilmuv kerimisriba tõstis muidu riba kõrgemaks ja lükkas lava ning nupud paigast (2026-11-21).
   scrollbar-gutter ei aita — see käib ainult püstise kerimisriba kohta. */
.sm-strip {
    display: flex; align-items: flex-start; gap: 8px; overflow-x: auto; overflow-y: hidden;
    list-style: none; margin: 0; padding: 4px; scroll-padding: 8px; scrollbar-width: thin;
    height: calc(64px + 8px + var(--sm-sb, 12px)); box-sizing: border-box;
}
.sm-strip li { flex: none; }
.sm-frame {
    position: relative; height: 64px; padding: 0; border-radius: 8px; cursor: pointer;
    border: 3px solid transparent; background: var(--bg-secondary); overflow: hidden; display: block;
}
.sm-frame img { height: 100%; width: 100%; object-fit: cover; display: block; }
.sm-frame.is-selected { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--sm-ring); }
.sm-frame:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-frame-num {
    position: absolute; left: 6px; bottom: 3px; font-size: 12px; font-weight: 700;
    color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); font-variant-numeric: tabular-nums;
}
/* Pikemalt näidatav kaader: kestus pisipildi nurgas (pildi peal — värvid ei sõltu teemast) */
.sm-frame-hold {
    position: absolute; right: 3px; top: 3px; display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 5px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.4;
    color: #fff; background: rgba(0, 0, 0, 0.72); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sm-frame-hold i { font-size: 9px; }

@media (hover: none) { .sm-kbd-hint { display: none; } }

/* ---------- Kitsas / püsti: lava üleval, kaadrid ja päästik all, seaded paneelil ---------- */
@media (max-width: 899px) {
    .sm-studio {
        gap: 8px; padding: 8px 12px 12px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        grid-template-areas: "top" "stage" "strip" "ctl";
    }
    .sm-topbar { gap: 8px; }
    .sm-back { width: 44px; padding: 0; }
    .sm-back .sm-btn-text, .sm-strip-tools .sm-btn-text {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .sm-strip-tools .button { width: 44px; padding: 0; }
    /* Kestuse nupp: tavalisel kaadril kell, pikemal kaadril kella asemel kestus („2 s"). Laius ei
       muutu — muidu hüppaks rida kaadrit valides teisele reale ja lava muutuks väiksemaks. */
    .sm-hold-btn:not(.is-held) .sm-hold-val {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .sm-strip-tools .sm-hold-btn.is-held .icon { display: none; }
    .sm-strip-tools .sm-hold-btn.is-held .sm-hold-val { font-size: 13px; font-weight: 700; white-space: nowrap; }
    .sm-settings-btn { display: inline-flex; }
    .sm-export { padding-inline: 14px; }
    .sm-export-state { top: 60px; }
    .sm-kbd-hint { display: none; }
    /* Pildistamise rida: viis võrdset pesa, päästik keskel — pool ei sõltu nuppude arvust */
    .sm-controls {
        display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; justify-items: center;
        gap: 8px; width: 100%; max-width: 480px; margin: 0 auto;
    }
    /* Päästikul kindel pesa — ruudustik paigutab pesade, mitte `order`-i järgi */
    .sm-shutter { grid-column: 3; }
    .sm-stage { border-radius: var(--sm-r-card); }
    .sm-frame { height: 52px; border-radius: 6px; }
    .sm-strip { height: calc(52px + 8px + var(--sm-sb, 12px)); gap: 6px; }
    .sm-strip-h { display: none; }
    .sm-strip-head { justify-content: space-between; }
    .sm-sel { flex: 0 1 auto; }
    /* Seaded: paneel alt üles */
    .sm-panel {
        position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 85%;
        border-radius: var(--sm-r-panel) var(--sm-r-panel) 0 0; border-bottom: 0;
        padding: 16px 16px 24px; gap: 16px; display: none;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
    }
    .sm-studio.is-settings-open .sm-panel { display: flex; }
    .sm-panel-head { display: flex; }
    .sm-panel-close { display: inline-block; }
    /* „Kaader kustutatud / Võta tagasi" (js/vota_tagasi.js, tekstisisesed stiilid) on vaikimisi
       all keskel — püstivaates täpselt päästiku peal 9 s. Siin lava ülaserva. */
    body.sm-in-studio .dk-undo-toast { bottom: auto !important; top: 64px !important; }
}
@media (max-width: 520px) {
    /* Valitud kaader paistab riba esiletõstust — tekst lükkaks nupud teisele reale */
    .sm-sel { display: none; }
    .sm-strip-head { gap: 4px 8px; }
    .sm-count { font-size: 13px; }
    .sm-strip-tools .button { width: 40px; height: 40px; }
    /* 7 × 40 + vahed mahub 360 px ekraanile ainult ilma eraldajata */
    .sm-strip-tools .sm-hist-last { margin-inline-end: 0; }
}
@media (max-width: 680px) {
    /* Seitse nuppu + loendur ei mahu ühele reale — loendur alati omal real, et rida ei hüppaks
       kaadrite lisandudes (loenduri tekst pikeneb) */
    .sm-count { flex: 1 0 100%; }
}
@media (max-width: 359px) {
    .sm-strip-tools { gap: 2px; }
    .sm-strip-tools .button { width: 36px; height: 36px; }
}
@media (max-width: 380px) {
    .sm-export { width: 44px; padding: 0; }
    .sm-export-text {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
}

/* ---------- Tahvel püsti (iPad): virn ----------
   Kõrval-paneel jättis 1024×1366 ekraanil 16:9 lavale 17% ekraanist ja ~670 px tühja (2026-11-21).
   Virn: lava kogu laiuses, nupud ja kaadrid kohe all, seaded avatult alumises ruumis. Klassi
   is-stack paneb app.js chooseStack() ainult siis, kui lava jääb virnas vähemalt sama suureks kui
   endises paigutuses (9:16 ja väiksemal tahvlil 4:3/1:1 jääb endine). Meediapäring = TABLET_MQ. */
@media (orientation: portrait) and (min-width: 700px) and (min-height: 900px) {
    .sm-studio.is-stack .sm-rotate-hint { display: none; }
    .sm-studio.is-stack {
        gap: 12px; padding: 12px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, calc((100vw - 24px) / var(--sm-ratio, 1.7778))) auto auto min-content;
        grid-template-areas: "top" "stage" "ctl" "strip" "panel";
        align-content: start;
    }
    .sm-studio.is-stack .sm-settings-btn,
    .sm-studio.is-stack .sm-panel-head { display: none; }
    .sm-studio.is-stack .sm-panel {
        position: static; z-index: auto; display: grid; align-self: start; max-height: none;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 32px; padding: 16px 20px 20px;
        border-radius: var(--sm-r-panel); border-bottom: 1px solid var(--border-light, var(--border-color));
        box-shadow: none;
    }
    .sm-studio.is-stack .sm-strip-h { display: inline; }
    .sm-studio.is-stack .sm-strip-head { justify-content: flex-start; }
    .sm-studio.is-stack .sm-sel { flex: 1 1 auto; }
    /* Virnas on nupud rida lava all (nagu kitsas vaade) */
    .sm-studio.is-stack .sm-controls {
        display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; justify-items: center;
        gap: 8px; width: 100%; max-width: 480px; margin: 0 auto;
    }
    .sm-studio.is-stack .sm-shutter { grid-column: 3; }
    .sm-studio.is-stack .sm-controls .sm-kbd-hint { grid-column: 4 / 6; justify-self: start; white-space: nowrap; max-width: none; margin: 0; }
}

/* ---------- Puutetahvel (iPad, mõlemas asendis): nupuveerg paremas ääres ----------
   Kahe käega hoides ulatub pöial ekraani servani, mitte keskele (2026-11-21, nagu iPadi
   kaamerarakendus). Pilt failist, päästik ja „Vaata" on paremas veerus ekraani keskkõrgusel;
   seaded avanevad nupust paremalt. Virn (is-stack) jääb, ainult nupud tulevad lava alt veergu.
   Hiire/puuteplaadiga arvuti (pointer: fine) jääb endise paigutuse juurde. */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 700px) {
    .sm-studio {
        gap: 12px; padding: 12px;
        grid-template-columns: minmax(0, 1fr) 84px;
        /* 120 = 2 × 12 polster + 12 vahe + 84 veerg */
        grid-template-rows: auto minmax(0, calc((100vw - 120px) / var(--sm-ratio, 1.7778))) minmax(auto, 1fr);
        grid-template-areas: "top top" "stage ctl" "strip ctl";
    }
    /* Viimane rida venib ekraani lõpuni, et nupuveerg (ja päästik) jääks ekraani keskele */
    .sm-studio.is-stack {
        align-content: stretch;
        grid-template-columns: minmax(0, 1fr) 84px;
        grid-template-rows: auto minmax(0, calc((100vw - 120px) / var(--sm-ratio, 1.7778))) auto minmax(min-content, 1fr);
        grid-template-areas: "top top" "stage ctl" "strip ctl" "panel ctl";
    }
    .sm-controls, .sm-studio.is-stack .sm-controls {
        grid-area: ctl; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 16px; width: auto; max-width: none; margin: 0;
    }
    .sm-controls > * { flex: none; }
    .sm-controls .sm-file-btn { order: -2; }
    .sm-shutter { order: -1; }
    .sm-kbd-hint, .sm-studio.is-rotate-hint .sm-rotate-hint { display: none; }
    .sm-settings-btn { display: inline-flex; }
    .sm-panel {
        position: fixed; z-index: 40; top: 0; left: auto; right: 0; bottom: 0;
        width: min(380px, 85vw); max-height: none; display: none; padding: 20px; gap: 20px;
        align-self: stretch; border-right: 0;
        border-bottom: 1px solid var(--border-light, var(--border-color));
        border-radius: var(--sm-r-panel) 0 0 var(--sm-r-panel);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
    }
    .sm-studio.is-settings-open .sm-panel { display: flex; }
    .sm-panel-head { display: flex; }
    .sm-panel-close { display: inline-block; }
    /* Virnas on paneel voos (eelmine plokk) — külgpaneeli laius ja äär ei kehti */
    .sm-studio.is-stack .sm-panel { width: auto; border-right: 1px solid var(--border-light, var(--border-color)); }
}

/* ---------- Madal pikali (telefon põiki): lava kogu kõrguses ----------
   Vasakul tagasi, kaadrid püsti ja kaadri nupud; paremal seaded, pildistamine ja video.
   Mähised (.sm-topbar, .sm-strip-wrap, .sm-strip-head) lahustuvad, nupud lähevad ise aladesse. */
@media (orientation: landscape) and (max-height: 520px) {
    .sm-studio {
        gap: 6px 10px; padding: 8px 12px;
        grid-template-columns: 80px minmax(0, 1fr) 64px;
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas: "back stage settings" "strip stage ctl" "tools stage export";
    }
    .sm-topbar, .sm-strip-wrap, .sm-strip-head { display: contents; }
    .sm-title, .sm-strip-h, .sm-count, .sm-sel { display: none; }
    .sm-back { grid-area: back; justify-self: center; }
    .sm-settings-btn { grid-area: settings; justify-self: center; }
    .sm-export { grid-area: export; justify-self: center; align-self: end; width: 52px; height: 52px; padding: 0; border-radius: 50%; }
    .sm-export-text {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .sm-export-state { top: 8px; }
    .sm-strip {
        grid-area: strip; flex-direction: column; align-items: stretch; overflow-x: hidden; overflow-y: auto;
        height: auto; min-height: 0; padding: 3px; gap: 6px; border-radius: var(--sm-r-btn);
        scrollbar-gutter: stable; /* püstine riba: kaadrid ei kitsene kerimisriba ilmudes */
        background: var(--bg-card); border: 1px solid var(--border-light, var(--border-color));
    }
    .sm-frame { width: 100%; height: auto; }
    .sm-strip-tools { grid-area: tools; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-self: end; }
    .sm-strip-tools .button { width: 38px; height: 38px; }
    .sm-strip-tools .sm-hist-last { margin-inline-end: 0; }
    /* Kestus omal real kogu veeru laiuses: tagasi + uuesti | nooled | kestus | korda + kustuta */
    .sm-strip-tools .button.sm-hold-btn { grid-column: 1 / -1; width: auto; padding: 0 4px; }
    .sm-strip-tools .sm-hold-btn.is-held .icon { display: inline-flex; }
    .sm-hold-btn:not(.is-held) .sm-hold-val {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .sm-ic-h { display: none; }
    .sm-ic-v { display: inline-block; }
    .sm-controls {
        grid-area: ctl; display: flex; flex-direction: column; justify-content: center; gap: 10px;
        max-width: none; margin: 0;
    }
    .sm-ctl-btn { width: 48px; height: 48px; }
    .sm-shutter { width: 64px; height: 64px; order: -1; }
    /* Ümmargused nupud ei tohi veerus kokku suruda (ovaalid) — mahutamine käib allpool kompaktsema
       paigutusega, mitte nuppe kahandades */
    .sm-controls > * { flex: none; }
    /* Päästik nupurea keskele: pilt failist üles, esitus alla */
    .sm-controls .sm-file-btn { order: -2; }
    /* Seaded: paneel paremalt (laiemal kui 899 px pikali-telefonil ei kehti kitsa vaate reeglid) */
    .sm-panel {
        position: fixed; z-index: 40; top: 0; left: auto; right: 0; bottom: 0;
        width: min(360px, 85vw); max-height: none; display: none; padding: 16px; gap: 16px;
        align-self: stretch; /* grid-lapse align-self:start teeks fikseeritud paneeli sisu-kõrguseks */
        border-radius: var(--sm-r-panel) 0 0 var(--sm-r-panel);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
    }
    .sm-studio.is-settings-open .sm-panel { display: flex; }
    .sm-panel-head { display: flex; }
    .sm-panel-close { display: inline-block; }
    .sm-settings-btn { display: inline-flex; }
    .sm-kbd-hint { display: none; }
    .sm-back { width: 44px; padding: 0; }
    .sm-back .sm-btn-text, .sm-strip-tools .sm-btn-text {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .sm-stage { border-radius: var(--sm-r-card); }
}

/* ---------- Väga madal pikali (brauseri ribadega telefon, ~240–340 px) ----------
   Paremasse veergu jäävad ainult seaded ja pildistamine; „Tee video" läheb vasakule tagasi-nupu
   kõrvale. Mahub 240 px kõrgusele (2026-11-19: 245 px juures surusid nupud ovaaliks ja kattusid). */
@media (orientation: landscape) and (max-height: 340px) {
    .sm-studio {
        gap: 6px 8px; padding: 6px 10px;
        grid-template-areas: "back stage settings" "strip stage ctl" "tools stage ctl";
    }
    .sm-back { justify-self: start; width: 38px; height: 38px; }
    .sm-export {
        grid-area: back; justify-self: end; align-self: center;
        width: 38px; height: 38px; border-radius: var(--sm-r-btn);
    }
    .sm-settings-btn { width: 40px; height: 40px; }
    .sm-controls { gap: 8px; }
    .sm-ctl-btn { width: 40px; height: 40px; }
    .sm-shutter { width: 56px; height: 56px; border-width: 3px; padding: 3px; }
    .sm-strip-tools .button { width: 36px; height: 36px; }
    .sm-overlay-btn { width: 34px; height: 34px; font-size: 14px; }
    .sm-mode { padding: 2px; }
    .sm-mode label > span { width: 34px; height: 34px; font-size: 14px; }
    .sm-stage-tools { top: 6px; left: 6px; right: 6px; gap: 6px; }
    .sm-font-btn { height: 34px; padding: 0 10px; gap: 6px; }
    .sm-font-name { display: none; }
    .sm-chip { right: 6px; bottom: 6px; max-width: calc(100% - 12px); height: 22px; font-size: 11px; }
    .sm-chip.is-insert { min-height: 24px; padding: 3px 8px; font-size: 12px; }
}
/* Alla ~290 px jääks neljale nupureale (tagasivõtt lisandus) kaadririba 30 px kõrguseks. Veerg
   kolme nupu laiuseks: kolm rida nagu enne. Lava on nii madalal kõrguse järgi piiratud, laiem
   veerg ei vähenda seda 16:9 puhul alates ~640 px laiusest. */
@media (orientation: landscape) and (max-height: 290px) {
    .sm-studio { grid-template-columns: 116px minmax(0, 1fr) 64px; }
    .sm-strip-tools { grid-template-columns: repeat(3, 1fr); }
    .sm-strip-tools #sm-hist-undo { grid-area: 1 / 1; }
    .sm-strip-tools #sm-hist-redo { grid-area: 1 / 2; }
    .sm-strip-tools #sm-dup { grid-area: 1 / 3; }
    .sm-strip-tools #sm-left { grid-area: 2 / 1; }
    .sm-strip-tools #sm-right { grid-area: 2 / 2; }
    .sm-strip-tools #sm-del { grid-area: 2 / 3; }
    .sm-strip-tools .button.sm-hold-btn { grid-row: 3; }
}

/* ---------- Joonistamine ----------
   Joonistusrežiim (.sm-studio.is-draw): lava on valge paber, kaamerapilti pole, lava all/kõrval
   tööriistariba (ala „draw"). Paber jääb heledaks ka tumedas teemas — joonistus on video sisu,
   mitte liides. Joonistuskiht: animatsioon/joonistus.js (Fabric.js). Eraldi plokk, et paigutuse
   põhireeglid jääksid puutumata. */
.sm-ctas { flex: none; margin: 0; }
.sm-ctas .button { margin-bottom: 0; }
.sm-shutter-plus { display: none; }
.sm-studio:not(.is-draw) .sm-kbd-draw,
.sm-studio.is-draw .sm-kbd-cam { display: none; }
/* Paber: valitud kaadri taust (app.js updateDrawbar → --sm-paper) */
.sm-studio.is-draw .sm-stage { background: var(--sm-paper, #fff); }
.sm-studio.is-draw #sm-video { display: none; }
.sm-studio.is-draw .sm-shutter {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-color); border-color: var(--accent-color); color: var(--on-accent, #fff);
}
.sm-studio.is-draw .sm-shutter-dot { display: none; }
.sm-studio.is-draw .sm-shutter-plus { display: inline-block; font-size: 28px; }

.sm-draw { position: absolute; inset: 0; }
.sm-draw canvas { display: block; }

/* Lai vaade: kahe veeruga tööriistaveerg lava vasakul (ala „draw" katab lava ja kaadririba rea) */
.sm-drawbar {
    grid-area: draw; min-width: 0; min-height: 0; align-self: start;
    display: grid; grid-template-columns: repeat(2, 40px); gap: 4px; justify-content: center; justify-content: safe center;
}
.sm-drawbar .sm-tool { width: 40px; height: 40px; font-size: 16px; }
.sm-ic-line { rotate: -45deg; }
.sm-ic-tri { rotate: -90deg; }
.sm-tool {
    flex: none; width: 44px; height: 44px; padding: 0; border-radius: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
    background: var(--bg-card); color: var(--text-secondary);
    border: 1px solid var(--border-light, var(--border-color));
    transition: background-color var(--dur-fast, 150ms) var(--ease, ease);
}
@media (hover: hover) { .sm-tool:not(:disabled):not([aria-pressed="true"]):hover { background: var(--bg-hover, var(--bg-secondary)); color: var(--text-primary); } }
.sm-tool:active:not(:disabled) { scale: 0.94; }
.sm-tool:disabled { opacity: 0.4; cursor: default; }
.sm-tool:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-tool[aria-pressed="true"] { background: var(--accent-color); border-color: var(--accent-color); color: var(--on-accent, #fff); }
.sm-tool.sm-danger { color: var(--sm-danger); }
.sm-style-dot {
    display: block; width: var(--sm-dot, 10px); height: var(--sm-dot, 10px); border-radius: 50%;
    background: #1a1a2e; box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px var(--border-color);
}

.sm-pop {
    width: 264px; max-width: calc(100vw - 16px); padding: 12px; display: flex; flex-direction: column; gap: 8px;
    background: var(--bg-card); color: var(--text-primary); border-radius: var(--sm-r-card);
    border: 1px solid var(--border-light, var(--border-color));
    box-shadow: var(--shadow-3, 0 8px 32px rgba(0, 0, 0, 0.28));
}
.sm-pop-h { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.sm-pop-sizes { display: flex; gap: 6px; }
.sm-size {
    width: 44px; height: 44px; padding: 0; border-radius: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-primary); color: var(--text-primary); border: 2px solid transparent;
}
.sm-size span { display: block; border-radius: 50%; background: currentColor; }
.sm-size[aria-pressed="true"] { border-color: var(--accent-color); }
.sm-size:focus-visible, .sm-swatch:focus-visible, .sm-swatch:has(> input:focus-visible) { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-pop-colors { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.sm-swatch {
    position: relative; aspect-ratio: 1; min-height: 30px; padding: 0; border-radius: 8px; cursor: pointer;
    border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.sm-swatch[aria-pressed="true"] { border-color: var(--text-primary); }
.sm-swatch-custom {
    display: flex; align-items: center; justify-content: center; overflow: hidden; color: #fff; font-size: 12px;
    background: conic-gradient(#f44336, #ff9800, #ffeb3b, #4caf50, #00bcd4, #3f51b5, #9c27b0, #f44336);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.sm-swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
/* Aken kasvas tausta reaga — madalal põiki-ekraanil (~245 px) kerib */
.sm-pop.sm-style-pop { max-height: calc(100dvh - 16px); overflow-y: auto; }
#sm-bgs { grid-template-columns: repeat(5, 1fr); }
/* Valge ja must peavad paistma ka sama värvi kaardil (hele/tume teema) */
#sm-bgs .sm-swatch { box-shadow: inset 0 0 0 1px var(--border-color); }
#sm-bgs .sm-swatch-custom.is-own { border-color: var(--text-primary); }
#sm-bgs .sm-swatch:disabled, #sm-bgs .sm-swatch-custom:has(> input:disabled), #sm-bg-all:disabled { opacity: 0.4; cursor: not-allowed; }
#sm-bgs .sm-swatch-custom:has(> input:disabled) input { cursor: not-allowed; }
/* Pildinupu valik joonistusrežiimis. Sildid on .sm-controls sees — sealne `order: -2` ei kehti siin. */
.sm-pop.sm-img-pop { width: 280px; }
.sm-img-pop .sm-img-choice.sm-file-btn {
    order: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px;
    border-radius: 10px; cursor: pointer; background: var(--bg-primary); color: var(--text-primary);
    border: 2px solid transparent;
}
@media (hover: hover) { .sm-img-pop .sm-img-choice:hover { border-color: var(--accent-color); } }
.sm-img-pop .sm-img-choice:has(> input:focus-visible) { outline: 3px solid var(--sm-ring); outline-offset: 2px; }
.sm-img-choice > i { font-size: 20px; width: 24px; text-align: center; color: var(--accent-color); flex: none; }
.sm-img-choice > span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sm-img-choice strong { color: var(--text-primary); font-size: 15px; }
.sm-img-choice small { color: var(--text-secondary); font-size: 13px; }
.sm-pop-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sm-pop-row .button { flex: 1 1 auto; height: 40px; font-size: 14px; margin: 0; }
.sm-pop-choice { display: flex; gap: 6px; margin-top: 2px; }
.sm-choice {
    flex: 1 1 0; min-width: 0; min-height: 40px; padding: 4px 8px; border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 14px; font-weight: 600; background: var(--bg-primary); color: var(--text-primary);
    border: 2px solid transparent; white-space: nowrap;
}
.sm-choice[aria-pressed="true"] { border-color: var(--accent-color); }
.sm-choice:focus-visible { outline: 3px solid var(--sm-ring); outline-offset: 2px; }

/* Paigutus: lai — tööriistaveerg lava vasakul, nupuveerg paremal (568 = 468 + 84 veerg + 16 vahe) */
.sm-studio.is-draw {
    grid-template-columns: 84px minmax(0, 1fr) 84px 320px;
    grid-template-rows: auto minmax(0, calc((100vw - 568px) / var(--sm-ratio, 1.7778))) minmax(auto, 1fr);
    grid-template-areas: "top top top panel" "draw stage ctl panel" "draw strip strip panel";
}
/* Kitsas/püsti: tööriistad rõhtsa ribana lava all (lava on seal laiusega piiratud — riba ei võta pildilt) */
@media (max-width: 899px) {
    .sm-studio.is-draw {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto auto auto;
        grid-template-areas: "top" "stage" "draw" "strip" "ctl";
    }
    .sm-drawbar { display: flex; flex-wrap: wrap; justify-content: center; justify-content: safe center; gap: 6px; align-self: auto; }
    .sm-drawbar .sm-tool { width: 42px; height: 42px; }
}
@media (max-width: 380px) {
    .sm-drawbar { gap: 4px; }
    .sm-drawbar .sm-tool { width: 38px; height: 38px; font-size: 15px; }
}
/* Madal pikali: tööriistad kahe veeruga püstises veerus lava vasakul */
@media (orientation: landscape) and (max-height: 520px) {
    .sm-studio.is-draw {
        grid-template-columns: 80px 80px minmax(0, 1fr) 64px;
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas: "back draw stage settings" "strip draw stage ctl" "tools draw stage export";
    }
    .sm-drawbar {
        display: grid; grid-template-columns: repeat(2, 38px); gap: 4px; align-self: stretch;
        align-content: center; align-content: safe center; justify-content: center; justify-content: safe center; overflow-y: auto;
    }
    .sm-drawbar .sm-tool { width: 38px; height: 38px; font-size: 15px; }
}
@media (orientation: landscape) and (max-height: 340px) {
    /* 14 nuppu kahes tulbas ei mahu 240 px kõrgusele — kolm tulpa (5 rida) */
    .sm-studio.is-draw {
        grid-template-columns: 80px 110px minmax(0, 1fr) 64px;
        grid-template-areas: "back draw stage settings" "strip draw stage ctl" "tools draw stage ctl";
    }
    .sm-drawbar { grid-template-columns: repeat(3, 34px); }
    .sm-drawbar .sm-tool { width: 34px; height: 34px; font-size: 14px; }
}
/* Kaadrinuppude kolm tulpa (vt kaameravaate ≤290 px plokk) ka joonistades */
@media (orientation: landscape) and (max-height: 290px) {
    .sm-studio.is-draw { grid-template-columns: 116px 110px minmax(0, 1fr) 64px; }
}
/* Tahvel püsti + virn (is-stack): tööriistad lava ja nuppude vahel. Peab olema pärast .is-draw
   reegleid — sama spetsiifilisus, muidu jääks virnale lai kaheveeruline ala. */
@media (orientation: portrait) and (min-width: 700px) and (min-height: 900px) {
    .sm-studio.is-stack.is-draw {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, calc((100vw - 24px) / var(--sm-ratio, 1.7778))) auto auto auto min-content;
        grid-template-areas: "top" "stage" "draw" "ctl" "strip" "panel";
    }
    .sm-studio.is-stack .sm-drawbar { display: flex; flex-wrap: wrap; justify-content: center; justify-content: safe center; gap: 6px; align-self: auto; }
}
/* Puutetahvel + joonistus: nupuveerg paremas ääres jääb, tööriistariba lava alla. Peab olema
   pärast .is-draw reegleid (sama spetsiifilisus). */
@media (pointer: coarse) and (min-width: 700px) and (min-height: 700px) {
    .sm-studio.is-draw {
        grid-template-columns: minmax(0, 1fr) 84px;
        grid-template-rows: auto minmax(0, calc((100vw - 120px) / var(--sm-ratio, 1.7778))) auto minmax(auto, 1fr);
        grid-template-areas: "top top" "stage ctl" "draw ctl" "strip ctl";
    }
    .sm-drawbar { display: flex; flex-wrap: wrap; justify-content: center; justify-content: safe center; gap: 6px; align-self: auto; }
    .sm-drawbar .sm-tool { width: 44px; height: 44px; font-size: 17px; }
    .sm-studio.is-stack.is-draw {
        grid-template-columns: minmax(0, 1fr) 84px;
        grid-template-rows: auto minmax(0, calc((100vw - 120px) / var(--sm-ratio, 1.7778))) auto auto minmax(min-content, 1fr);
        grid-template-areas: "top top" "stage ctl" "draw ctl" "strip ctl" "panel ctl";
    }
}
