/* ============================================
   VideoCropper - one page, one stylesheet.
   Sections: tokens, base, header, landing, editor, controls,
   result, info, footer, tool (stage/transport/panel), phones.
   ============================================ */

/* ---------- 0. type ---------- */
/* Self-hosted and preloaded, with font-display: optional: the page
   paints once, in this face when it is ready (nearly always, it is
   preloaded and then cached) and in the fallback otherwise - never a
   swap mid-paint. The fallback is metric-matched to it so the two
   lay out alike. */
@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 200 800;
    font-display: optional;
    src: url('fonts/plus-jakarta-sans-latin.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: 'Jakarta Fallback';
    src: local('Arial'), local('Helvetica'), local('Liberation Sans');
    size-adjust: 104%;
    ascent-override: 100%;
    descent-override: 26%;
    line-gap-override: 0%;
}

/* ---------- 1. tokens ---------- */
:root {
    --primary: #2f6df6;
    --primary-hover: #245be0;
    --primary-soft: rgba(47, 109, 246, 0.12);
    --danger: #ef4444;
    --text: #1c1d22;
    --text-soft: #5f6470;
    --text-faint: #979ca8;
    --bg: #f3f4f7;
    --card: #ffffff;
    --field: #f3f4f7;
    --border: #dfe2e8;
    --border-soft: #eceef2;
    --shadow: rgba(20, 24, 40, 0.08);
    --header-h: 60px;
    --container: 1200px;
    --pad: 30px;
    --r: 14px;
    --r-sm: 10px;
}

[data-theme="dark"] {
    --primary: #4c8bff;
    --primary-hover: #3a7bf2;
    --primary-soft: rgba(76, 139, 255, 0.16);
    --text: #eceef3;
    --text-soft: #9ba1ad;
    --text-faint: #666c78;
    --bg: #111216;
    --card: #1a1b20;
    --field: #111216;
    --border: #2a2c33;
    --border-soft: #23252b;
    --shadow: rgba(0, 0, 0, 0.35);
}

/* ---------- 2. base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    background: var(--bg);
}

body {
    font-family: 'Plus Jakarta Sans', 'Jakarta Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: var(--primary);
}

/* every inline SVG is a stroke icon */
.icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    width: 24px;
    height: 24px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ---------- 3. header ---------- */
.header {
    position: relative;
    z-index: 900;
    height: var(--header-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
}

.header-inner {
    height: 100%;
    max-width: var(--container);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 36px;
    padding: 0 var(--pad);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.4px;
    flex-shrink: 0;
    text-decoration: none;
    color: var(--text);
}

.logo-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-soft);
}

.logo-tile .icon {
    width: 19px;
    height: 19px;
    stroke-width: 2.4;
}

@media (hover: hover) {
    .logo:hover .logo-tile {
        background: var(--primary-hover);
    }
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nav-link {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-soft);
    white-space: nowrap;
}

@media (hover: hover) {
    .nav-link:hover {
        color: var(--text);
        background: var(--card);
    }
}

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    margin-left: 2px;
    background: none;
    border: none;
    border-radius: 999px;
    color: var(--text-soft);
    cursor: pointer;
}

@media (hover: hover) {
    .theme-btn:hover {
        color: var(--text);
        background: var(--card);
    }
}

.theme-btn .icon {
    width: 20px;
    height: 20px;
    stroke-width: 1.8;
}

.icon-moon { display: none; transform: scale(0.9); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- 4. landing: the button first ---------- */
.hero {
    min-height: calc(100vh - var(--header-h));
    min-height: calc(var(--vhpx, 100svh) - var(--header-h));
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 90px 20px 80px;
}

.hero h1 {
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 18px;
}

.hero-sub {
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-soft);
    max-width: 640px;
    margin-bottom: 48px;
    text-wrap: pretty;
}

.btn-hero {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 22px 76px;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--r);
    cursor: pointer;
    box-shadow: 0 8px 24px var(--primary-soft);
}

@media (hover: hover) {
    .btn-hero:hover {
        background: var(--primary-hover);
    }
}

.btn-hero:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-hero .icon {
    width: 1.3em;
    height: 1.3em;
    stroke-width: 2.5;
}

/* hidden but laid out: iOS ignores the first click on a display:none input */
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    clip: rect(0 0 0 0);
}

body.drag-active::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 122, 255, 0.1);
    pointer-events: none;
    z-index: 9999;
}

[data-theme="dark"] body.drag-active::before {
    background: rgba(10, 132, 255, 0.2);
}

/* ---------- 5. editor: one window, picture + panel ---------- */
.editor {
    display: none;
    min-height: calc(100vh - var(--header-h));
    min-height: calc(var(--vhpx, 100svh) - var(--header-h));
    padding: 40px 20px;
}

.editor.active {
    display: block;
}

.window {
    width: fit-content;
    max-width: var(--container);
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: 0 10px 30px var(--shadow);
    overflow: hidden;
}

.stage {
    flex: 1;
    position: relative;
    padding: var(--pad);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
}

#canvas {
    max-width: min(100%, var(--cw, 100%));
    max-height: calc(100vh - var(--header-h) - 250px);
    border-radius: 8px;
}

.panel {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-soft);
    max-height: calc(100vh - var(--header-h) - 80px);
}

.panel-scroll {
    --panel-bg: var(--card);
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--pad);
    padding-bottom: 12px;
    background:
        linear-gradient(var(--panel-bg) 30%, transparent) center top,
        linear-gradient(transparent, var(--panel-bg) 70%) center bottom,
        radial-gradient(farthest-side at 50% 0, var(--shadow), transparent) center top,
        radial-gradient(farthest-side at 50% 100%, var(--shadow), transparent) center bottom;
    background-repeat: no-repeat;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
    background-attachment: local, local, scroll, scroll;
}

.panel.can-scroll .panel-scroll {
    overscroll-behavior: contain;
}

.panel-scroll,
.stage {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.panel-scroll::-webkit-scrollbar {
    width: 6px;
}

.panel-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.panel-actions {
    margin-top: 28px;
    padding: var(--pad);
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
}

/* ---------- 6. buttons ---------- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    padding: 12px 16px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    box-shadow: 0 6px 18px var(--primary-soft);
}

.btn:hover {
    background: var(--primary-hover);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn .icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

.download-row {
    display: flex;
    gap: 8px;
}

.mini-btn {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--field);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    color: var(--text-soft);
    cursor: pointer;
}

@media (hover: hover) {
    .mini-btn:hover {
        border-color: var(--border);
        color: var(--text);
    }
}

.mini-btn:disabled {
    opacity: 0.6;
}


.mini-btn .icon {
    width: 18px;
    height: 18px;
}

.mini-btn .spinner {
    width: 16px;
    height: 16px;
    margin-right: 0;
    border-top-color: var(--text-soft);
}

/* fullscreen: #fullBtn (in the transport bar) toggles .full on the .stage */


@media (min-width: 900px) {
    .stage:not(.full) {
        padding-bottom: 84px;
    }
}

.full-icon-exit {
    display: none;
}

.stage.full .full-icon-enter {
    display: none;
}

.stage.full .full-icon-exit {
    display: block;
}

.stage.full {
    position: fixed;
    inset: 0;
    z-index: 3000;
    height: auto;
    max-height: none;
    padding: 12px;
    justify-content: center;
    background: var(--bg);
}

.stage.full #canvas {
    position: static;
    width: auto;
    margin: 0;
    max-width: 100%;
    max-height: calc(100% - 34px);
}

.stage.full .full-btn {
    color: var(--text);
}

/* ---------- 7. result ---------- */
.result {
    display: none;
    min-height: calc(100vh - var(--header-h));
    min-height: calc(var(--vhpx, 100svh) - var(--header-h));
    padding: 40px 20px;
}

.result.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-window {
    width: fit-content;
    min-width: min(100%, 440px);
    max-width: 100%;
    padding: var(--pad);
    text-align: center;
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 10px 30px var(--shadow);
}

.result-name {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 12px 0 18px;
    font-size: 14px;
}

.name-input {
    font: inherit;
    font-weight: 500;
    color: var(--text);
    text-align: right;
    background: none;
    border: none;
    outline: none;
    padding: 0 1px 2px;
}

.name-ext {
    color: var(--text-faint);
    padding-bottom: 2px;
}

.name-pencil {
    display: flex;
    margin-left: 8px;
    color: var(--text-faint);
    cursor: pointer;
}

.name-pencil:hover {
    color: var(--primary);
}

.name-pencil .icon {
    width: 14px;
    height: 14px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.result-actions .btn {
    width: 100%;
    max-width: 360px;
}

/* the secondary actions: quiet labeled pills */
.result-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--field);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    cursor: pointer;
}

.link-btn .icon {
    width: 15px;
    height: 15px;
}

@media (hover: hover) {
    .link-btn:hover {
        color: var(--text);
        border-color: var(--border);
    }
}

/* ---------- 8. controls ---------- */
.seg {
    display: flex;
    padding: 4px;
    gap: 2px;
    background: var(--field);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
}

.seg-btn {
    flex: 1;
    padding: 9px 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
    background: none;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
}

.seg-btn[aria-pressed="true"] {
    color: var(--text);
    background: var(--card);
    box-shadow: 0 1px 3px var(--shadow), 0 0 0 1px var(--border-soft);
    font-weight: 600;
}

.dd {
    position: relative;
    width: 100%;
}

.dd-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    cursor: pointer;
}

.dd-btn:hover,
.dd.open .dd-btn {
    border-color: var(--primary);
}

.dd-btn .caret {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    color: var(--text-faint);
    flex-shrink: 0;
}

.dd.open .dd-btn .caret {
    transform: rotate(180deg);
}

.dd-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: none;
    max-height: 45vh;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-y: auto;
    box-shadow: 0 14px 36px var(--shadow);
    z-index: 1000;
}

.dd.open .dd-menu {
    display: block;
}

.dd-menu:focus {
    outline: none;
}

.dd-option {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    text-align: left;
    color: var(--text);
    background: none;
    border: 0;
    border-top: 1px solid var(--border-soft);
    cursor: pointer;
}

.dd-option:first-child {
    border-top: none;
}

.dd-option:hover,
.dd-option.focused {
    background: var(--field);
}

.dd-option[aria-selected="true"] {
    color: var(--primary);
    font-weight: 600;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
}

/* the scrub bar: a filled track (--fill is set by the script), a small
   thumb that grows while it is held; the input stays 28px tall so the
   finger target is real */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    --fill: 0%;
    width: 100%;
    height: 28px;
    background: transparent;
    outline: none;
    cursor: pointer;
    touch-action: pan-y;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--primary) var(--fill), var(--border) var(--fill));
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.12s;
}

@media (hover: hover) {
    input[type="range"]:hover::-webkit-slider-thumb {
        transform: scale(1.15);
    }
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.3);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}

input[type="range"]::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: var(--primary);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.12s;
}

input[type="range"]:active::-moz-range-thumb {
    transform: scale(1.3);
}

input[type="range"]:focus-visible {
    outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--primary-soft), 0 0 0 1px var(--primary);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    border: 2px solid var(--border);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    max-width: calc(100% - 40px);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #fff;
    background: #1c1d22;
    border-radius: 12px;
    box-shadow: 0 6px 20px var(--shadow);
    visibility: hidden;
    z-index: 2000;
}

[data-theme="dark"] .toast {
    background: #2a2c33;
}

.toast.show {
    visibility: visible;
}

/* ---------- 9. info + footer ---------- */
.info {
    background: var(--card);
}

.info-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 80px 20px;
}

.info h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 40px 0 15px;
}

.info h2:first-child {
    margin-top: 0;
}

.info p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-soft);
    margin: 0 0 14px;
}

.info .faq {
    background: var(--bg);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
}

.info .faq summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.info .faq summary::-webkit-details-marker {
    display: none;
}

.info .faq summary::after {
    content: '+';
    font-size: 20px;
    font-weight: 400;
    color: var(--text-faint);
    flex-shrink: 0;
}

.info .faq[open] summary::after {
    content: '\00d7';
}

.info .faq p {
    padding: 0 20px 16px;
}

.footer {
    padding: 25px;
    text-align: center;
    font-size: 14px;
    color: var(--text-soft);
    background: var(--card);
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--text-soft);
    text-decoration: none;
}

.footer a:hover {
    color: var(--primary);
}

/* ============================================
   10. the tool itself
   ============================================ */

/* the stage shows the crop canvas over the current frame; the source
   <video> decodes off-screen, the result <video> plays on the result screen */
#video {
    display: none;
}

#canvas {
    display: block;
    max-width: min(100%, 640px);
    max-height: calc(100vh - var(--header-h) - 250px);
    touch-action: pan-y;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.result-video {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 60vh;
    margin: 0 auto;
    border-radius: 8px;
    background: #000;
}

.saved-note {
    margin: 24px auto 8px;
    max-width: 34ch;
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
}

.result-meta {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* transport: play, the scrub bar, the time and fullscreen in one bar
   under the picture; the buttons are round and borderless so the bar
   reads as a player, not a form */
.transport {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 40px));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 999px;
    background: var(--field);
    border: 1px solid var(--border-soft);
    box-shadow: 0 10px 28px var(--shadow);
    z-index: 10;
}

.transport .mini-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--card);
    color: var(--text);
}

.transport .mini-btn .icon {
    width: 16px;
    height: 16px;
}

@media (hover: hover) {
    .transport .mini-btn:hover {
        background: var(--primary-soft);
        color: var(--primary);
    }
}

/* the play / pause glyphs are solid, like every player's */
.play-icon,
.pause-icon {
    fill: currentColor;
    stroke: none;
}

.transport #playBtn {
    color: var(--text);
}

.transport input[type="range"] {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.time-val {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 84px;
    text-align: right;
}

.time-total {
    color: var(--text-faint);
}

/* in fullscreen the same bar floats over the picture */
.stage.full .transport {
    bottom: 18px;
    width: min(720px, calc(100% - 28px));
}

.ctl-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 26px;
    margin-bottom: 8px;
}

.ctl-head .control-label {
    margin-bottom: 0;
}

/* a small segmented control that sits in a heading row */
.seg-mini {
    padding: 2px;
    border-radius: 8px;
}

.seg-mini .seg-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
}

.reset-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
}

.reset-link:disabled {
    color: var(--text-soft);
    opacity: 0.5;
    cursor: default;
}

@media (hover: hover) {
    .reset-link:not(:disabled):hover {
        text-decoration: underline;
    }
}

.dd {
    margin-top: 10px;
}

.dim-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dim-x {
    flex: 0 0 auto;
    font-size: 14px;
    color: var(--text-faint);
}

.dim-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    background: var(--field);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
    appearance: textfield;
}

.dim-input::-webkit-inner-spin-button,
.dim-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dim-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* while cropping the button IS the progress bar */
#downloadBtn.cropping {
    position: relative;
    overflow: hidden;
    opacity: 1;
    cursor: progress;
}

#downloadBtn.cropping::before {
    content: "";
    position: absolute;
    inset: 0;
    width: var(--p, 0%);
    background: rgba(255, 255, 255, 0.3);
    transition: width 0.25s;
}

#downloadBtn.cropping > * {
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ?debug: the stages of a crop, for a phone whose console we cannot see */
.dbg-line {
    margin: 0 0 8px;
    max-height: 140px;
    overflow: auto;
    font: 11px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--text-soft);
    white-space: pre-wrap;
}

.out-size {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

#sizeSeg .seg-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.block-label {
    margin-top: 18px;
}

span.block-label {
    display: block;
}

.stage.full #canvas {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
}

/* ============================================
   11. phones - kept last so its rules win every tie
   ============================================ */
@media (max-width: 899px) {
    :root {
        --header-h: 48px;
        --pad: 20px;
    }

    .header-inner {
        gap: 12px;
    }

    .logo {
        gap: 8px;
    }

    .logo-tile {
        width: 26px;
        height: 26px;
        border-radius: 8px;
    }

    .logo-tile .icon {
        width: 15px;
        height: 15px;
    }

    .logo-text {
        font-size: 16px;
    }

    .theme-btn {
        width: 32px;
        height: 32px;
    }

    .theme-btn .icon {
        width: 17px;
        height: 17px;
    }

    .nav {
        display: none;
    }

    .theme-btn {
        margin-left: auto;
    }

    .hero {
        padding: 40px 20px 60px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .hero-sub {
        font-size: 16px;
        margin-bottom: 40px;
    }

    .btn-hero {
        width: min(100%, 360px);
        justify-content: center;
        padding: 20px 24px;
        font-size: 19px;
    }

    /* full-bleed compact editor on the page's own grey */
    .editor {
        padding: 0;
        min-height: calc(100vh - var(--header-h));
        min-height: calc(var(--vhpx, 100svh) - var(--header-h));
    }

    .editor.active {
        display: flex;
        flex-direction: column;
    }

    .window {
        width: 100%;
        flex-direction: column;
        max-height: calc(100vh - var(--header-h));
        max-height: calc(var(--vhpx, 100svh) - var(--header-h));
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: none;
        overflow: visible;
    }

    .panel-scroll {
        --panel-bg: var(--bg);
        border-top-right-radius: 0;
    }

    /* a band under the picture keeps the corner buttons off the crop
       handles; the tool passes fitMobileStage extra = 72 */
    .stage {
        flex: 0 0 auto;
        height: auto;
        padding: 16px 16px 82px;
        background: var(--bg);
    }

    .transport {
        width: calc(100% - 24px);
        bottom: 12px;
        background: var(--card);
    }

    .transport .mini-btn {
        background: var(--field);
    }

    .panel {
        width: 100%;
        flex: 0 1 auto;
        min-height: 0;
        max-height: none;
        border-left: none;
    }

    .panel-actions {
        margin-top: 0;
        border-top: none;
        padding-top: 0;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .panel.can-scroll {
        border-top: 1px solid var(--border-soft);
    }

    .panel.can-scroll .panel-actions {
        border-top: 1px solid var(--border-soft);
        padding-top: 12px;
    }

    /* phones: current time only */
    .time-total {
        display: none;
    }

    .time-val {
        min-width: 40px;
    }

    #canvas {
        position: static;
        width: auto;
        max-width: 100%;
        max-height: var(--stageH, 42vh);
        margin: 0 auto;
    }

    .result {
        padding: 20px;
    }

    .result-window {
        width: 100%;
        min-width: 0;
        padding: 0;
        background: none;
        border-radius: 0;
        box-shadow: none;
    }

    .result-actions .btn {
        max-width: none;
    }

    .info-inner {
        padding: 50px 20px;
    }
}
