@font-face {
  font-family: Manrope;
  src: url('/fonts/manrope-cyrillic-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Manrope;
  src: url('/fonts/manrope-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  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;
}

:root {
  color-scheme: dark;
  --bg: #111112;
  --panel: #19191c;
  --field: #131315;
  --stroke: #2d2d32;
  --accent: #ff6655;
  --accent-hover: #ff8274;
  --text: #f4f3f2;
  --muted: #a6a4ab;
  --subtle: #83818a;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-family: Manrope, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
input, button, fieldset { font: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }

.header { border-bottom: 1px solid #252529; background: #141415; }
.header-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; font-size: 24px; font-weight: 800; letter-spacing: -.05em; line-height: 1; white-space: nowrap; color: var(--text); text-decoration: none; }
.brand-icon { display: grid; place-items: center; width: 35px; height: 35px; margin-right: 10px; border-radius: 10px; background: var(--accent); color: #1f1212; }
.tool-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.tool-nav a { padding: 8px 11px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700; line-height: 1.25; }
.tool-nav a:hover { color: var(--text); background: #202023; }
.tool-nav a[aria-current="page"] { border-color: #603531; background: #302121; color: #ff9d90; }

.main { padding-block: 48px 56px; }
.intro { margin-bottom: 26px; }
.intro h1 { font-size: clamp(2.08rem, 5.1vw, 3.5rem); font-weight: 800; line-height: 1.07; letter-spacing: -.068em; }
.intro h1 .intro-accent { color: var(--accent); }
.intro p { margin-top: 12px; color: var(--muted); line-height: 1.6; }

.panel { min-width: 0; border: 1px solid var(--stroke); border-radius: 16px; background: var(--panel); padding: 20px; }
.source-form label, .filename label, .time-fields label, legend { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.35; }
.source-controls { display: flex; align-items: stretch; gap: 10px; }
.url-field, .filename-field { display: flex; align-items: center; min-width: 0; border: 1px solid #353539; border-radius: 9px; background: var(--field); transition: border-color .18s; }
.url-field:focus-within, .filename-field:focus-within { border-color: var(--accent); }
.url-field { flex: 1 1 auto; }
.url-field .icon { margin-left: 14px; color: var(--subtle); }
.url-field input, .filename-field input { flex: 1 1 auto; min-width: 0; width: 100%; border: 0; outline: none; color: var(--text); background: transparent; }
.url-field input { height: 46px; padding: 0 12px; }
input::placeholder { color: var(--subtle); opacity: 1; }

.button { min-width: 0; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 800; transition: background-color .18s, color .18s, border-color .18s; }
.button:disabled { cursor: default; }
.language-button { min-height: 34px; padding-inline: 10px; border-color: var(--stroke); background: var(--panel); color: var(--text); }
.language-button:hover { border-color: var(--accent); }
.load-button { min-height: 48px; padding-inline: 21px; background: #edebeb; color: #1b1b1f; }
.load-button:hover:not(:disabled) { background: #fff; }
.load-button:disabled { background: #bcbac1; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.46fr); gap: 16px; margin-top: 16px; align-items: start; }
.editor { display: grid; min-width: 0; gap: 16px; }
.range-mode { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding-block: 9px; font-size: 14px; font-weight: 750; }
.range-mode .text-button:not(:disabled) { color: #ff9d90; }
.tool-guide { margin-top: 28px; padding-top: 21px; border-top: 1px solid var(--stroke); }
.tool-guide h2 { font-size: 18px; line-height: 1.4; }
.tool-guide p { margin-top: 7px; max-width: 66ch; line-height: 1.6; color: var(--muted); }
.panel-heading, .heading-text { display: flex; align-items: center; gap: 10px; }
.panel-heading { justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.panel h2 { font-size: 17px; letter-spacing: -.026em; font-weight: 800; line-height: 1.25; }
.section-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #38383e; border-radius: 9px; background: #242428; color: #c5c3ca; }
.section-icon .icon { width: 17px; height: 17px; }
.accent-icon { border-color: #53302e; background: #372323; color: var(--accent); }

.poster { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; border: 1px solid #39383c; background: #131315; }
.source-player { position: relative; width: 100%; min-height: 202px; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid #39383c; border-radius: 10px; background: #101012; }
.source-player iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.playback-notice { color: var(--muted); font-size: 14px; margin-top: 8px; line-height: 1.45; }
.playback-notice a { display: inline-block; margin-top: 4px; color: #ff9d90; text-underline-offset: 3px; }
.poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview-icon { position: absolute; inset: 50% auto auto 50%; translate: -50% -50%; display: grid; place-items: center; width: 48px; height: 48px; color: #eee; border: 1px solid #ffffff40; border-radius: 14px; background: #17171aa8; backdrop-filter: blur(8px); }
.preview-icon .icon { width: 25px; height: 25px; }
.poster-tag, .poster-duration { position: absolute; bottom: 9px; display: flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 5px; background: #121214e8; font-size: 12px; font-weight: 750; }
.poster-tag { left: 9px; }
.poster-tag .icon { width: 16px; height: 16px; color: var(--accent); }
.poster-duration { right: 9px; font: 700 12px var(--mono); padding: 5px 7px; }
.video-info { margin-top: 15px; min-height: 48px; overflow-wrap: anywhere; }
.video-info h3 { font-size: 16px; line-height: 1.45; font-weight: 800; }
.video-info p { margin-top: 4px; font-size: 13px; line-height: 1.45; color: var(--muted); }

.filename { margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--stroke); }
.filename-field input { padding: 0 11px; height: 42px; font-size: 14px; }
.filename-field span { align-self: stretch; display: grid; place-items: center; padding-inline: 11px; border-left: 1px solid var(--stroke); color: var(--muted); font: 13px var(--mono); }

.duration, .format { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 8px; border: 1px solid var(--stroke); border-radius: 7px; background: #141416; font: 700 13px var(--mono); white-space: nowrap; }
.duration .icon { width: 16px; height: 16px; color: var(--accent); }
.format { gap: 2px; padding: 3px; }
.format-badge { padding: 7px 10px; color: #ff9d90; }
.format label { position: relative; cursor: pointer; }
.format label:has(:disabled) { cursor: default; }
.format input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.format label span { display: block; padding: 6px 8px; border-radius: 4px; color: var(--muted); }
.format label:hover span { color: var(--text); }
.format input:checked + span { background: #302121; color: #ff9d90; }
.format input:focus-visible + span { outline: 2px solid var(--accent); }

.timeline { --start: 0%; --end: 100%; position: relative; height: 50px; overflow: hidden; border: 1px solid #333338; border-radius: 9px; background: #131315; }
.track { position: absolute; inset: 0 13px; isolation: isolate; background:
  repeating-linear-gradient(to right, #39393f 0 1px, transparent 1px 20%) top 7px left / 100% 9px no-repeat,
  repeating-linear-gradient(to right, #2e2e34 0 1px, transparent 1px 4%) top 7px left / 100% 5px no-repeat,
  repeating-linear-gradient(to right, #2e2e34 0 1px, transparent 1px 4%) bottom 7px left / 100% 5px no-repeat,
  linear-gradient(#38383e, #38383e) center / 100% 2px no-repeat; }
.track-selection { position: absolute; inset: 18px calc(100% - var(--end)) 18px var(--start); border-block: 1px solid #91514a; background: #4f2e2e; }
.timeline[data-ready="true"] .track-selection { border-color: var(--accent); background: #9a493f; }
.slider-pair { position: absolute; inset: 0 7px; }
.slider-pair input { appearance: none; pointer-events: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; outline: 0; background: transparent; }
.slider-pair input:focus { z-index: 2; }
.slider-pair input::-webkit-slider-thumb { appearance: none; pointer-events: auto; height: 29px; width: 12px; border: 1px solid #ba645b; border-radius: 4px; background: linear-gradient(90deg, transparent 4px, #703e39 4px 5px, transparent 5px 6px, #703e39 6px 7px, transparent 7px) #e29084; cursor: ew-resize; }
.slider-pair input::-moz-range-thumb { pointer-events: auto; height: 27px; width: 10px; border: 1px solid #ba645b; border-radius: 4px; background: linear-gradient(90deg, transparent 3px, #703e39 3px 4px, transparent 4px 5px, #703e39 5px 6px, transparent 6px) #e29084; cursor: ew-resize; }
.slider-pair input:not(:disabled)::-webkit-slider-thumb { background-color: var(--accent); border-color: var(--accent); }
.slider-pair input:not(:disabled)::-moz-range-thumb { background-color: var(--accent); border-color: var(--accent); }
.slider-pair input:disabled::-webkit-slider-thumb { cursor: default; opacity: .75; }
.slider-pair input:disabled::-moz-range-thumb { cursor: default; opacity: .75; }
.slider-pair input:focus-visible::-webkit-slider-thumb { outline: 2px solid white; outline-offset: 2px; }
.slider-pair input:focus-visible::-moz-range-thumb { outline: 2px solid white; outline-offset: 2px; }
.time-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font: 12px var(--mono); }

.time-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; gap: 12px; margin-top: 15px; }
.time-input { width: 100%; min-width: 0; height: 43px; padding: 0 12px; color: var(--text); background: var(--field); border: 1px solid #353539; border-radius: 8px; font: 600 16px var(--mono); }
.time-input:disabled { color: var(--muted); }
.time-input[aria-invalid="true"], .url-field:has(input[aria-invalid="true"]) { border-color: var(--accent); }
.text-button { color: var(--muted); background: transparent; border-color: transparent; padding: 8px 7px; white-space: nowrap; }
.time-fields .text-button { min-height: 43px; }
.text-button:hover:not(:disabled) { color: var(--text); background: #27272b; }
.text-button:disabled { color: var(--subtle); }


.playhead { display: grid; gap: 6px; margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--stroke); }
.playhead-heading, .playhead-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
.playhead-heading label { color: var(--muted); font-size: 14px; font-weight: 700; }
.playhead-time { font: 600 13px var(--mono); }
.playhead input[type="range"] { width: 100%; height: 24px; margin: 0; accent-color: var(--accent); cursor: ew-resize; }
.playhead-actions .button { display: inline-flex; align-items: center; gap: 5px; white-space: normal; }
.playhead-actions .icon { width: 15px; height: 15px; }
.playhead-actions .mark-end:not(:disabled) { color: var(--accent-hover); }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
.qualities { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quality { position: relative; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 65px; padding: 10px 11px; border: 1px solid #353539; border-radius: 9px; background: #1e1e21; cursor: pointer; transition: border-color .18s, background-color .18s; }
.quality:hover { border-color: #686770; }
.quality:has(:checked) { background: #302121; border-color: #c9594d; }
.quality:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.quality:has(:disabled) { cursor: default; }
.quality input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.quality-text { display: grid; gap: 3px; overflow-wrap: anywhere; }
.quality strong { font-size: 14px; font-weight: 800; line-height: 1.25; }
.quality-text span { font-size: 13px; color: var(--muted); line-height: 1.3; }
.radio-mark { display: grid; place-items: center; width: 17px; height: 17px; flex: none; border: 1px solid #67666c; border-radius: 50%; color: #211211; }
.radio-mark .icon { display: none; width: 13px; height: 13px; stroke-width: 2.8; }
.quality:has(:checked) .radio-mark { background: var(--accent); border-color: var(--accent); }
.quality:has(:checked) .radio-mark .icon { display: block; }

.export-actions { margin-top: 15px; }
.export-buttons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); gap: 10px; }
.export-buttons:has(.preview-button[hidden]) { grid-template-columns: minmax(0, 1fr); }
.preview-button, .save-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 47px; padding: 9px 11px; font-size: 15px; }
.preview-button { background: #242428; border-color: #46464b; color: var(--text); }
.preview-button:hover:not(:disabled) { background: #302121; border-color: #c9594d; }
.preview-button:disabled { color: var(--muted); }
.save-button { background: var(--accent); color: #211211; }
.save-button:hover:not(:disabled) { background: var(--accent-hover); }
.save-button:disabled { background: #a34e45; color: #fff4f3; }
.preview-button .icon, .save-button .icon { width: 19px; height: 19px; stroke-width: 2; }
.job-status, .error, .download-again { margin-top: 10px; }
.job-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 14px; }
.job-status progress { width: 100%; height: 8px; accent-color: var(--accent); }
.error { color: #ff9d90; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.download-again { display: inline-block; text-decoration-color: #a9625a; text-underline-offset: 3px; color: #ff9d90; font-size: 14px; }

@media (max-width: 780px) {
  .shell { width: calc(100% - 36px); }
  .header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; padding-block: 12px 10px; }
  .tool-nav { grid-area: 2 / 1 / auto / -1; justify-content: flex-start; margin-left: -2px; }
  .tool-nav a { padding-inline: 8px; }
  .main { padding-block: 34px 40px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 1.3fr); align-items: start; gap: 12px; }
  .preview-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .source-player, .source-player:not([hidden]) ~ .video-info, .playback-notice { grid-column: 1 / -1; }
  .playback-notice { margin-top: 0; }
  .video-info { align-self: center; margin-top: 0; min-height: auto; }
  .filename { grid-column: 1 / -1; margin-top: 0; padding-top: 12px; }
}

@media (max-width: 430px) {
  .shell { width: calc(100% - 28px); }
  .header-inner { min-height: 58px; }
  .main { padding-top: 26px; }
  .intro { margin-bottom: 18px; }
  .intro p { margin-top: 8px; }
  .panel { padding: 15px; border-radius: 13px; }
  .source-controls { flex-direction: column; }
  .load-button { min-height: 42px; }
  .range-panel .panel-heading { gap: 7px; }
  .time-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .time-fields .text-button { grid-column: 1 / -1; justify-self: start; min-height: 32px; padding-block: 4px; }
  .export-buttons { grid-template-columns: minmax(0, 1fr); }
  .quality { min-height: 68px; }
  .quality-text span { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
