@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url("./vendor/dm-sans-latin.woff2") format("woff2");
}

:root {
  color: #17251e;
  background: #f3f6ef;
  font-family: "DM Sans", system-ui, sans-serif;
  --ink: #17251e;
  --forest: #14251d;
  --green: #325844;
  --lime: #d5f681;
  --muted: #516459;
  --border: #d6e0d5;
  --surface: #fff;
  --soft: #eff4eb;
  --radius: 20px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; }
:focus-visible { outline: 3px solid #547a34; outline-offset: 3px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.app-header { padding-top: env(safe-area-inset-top); color: #fff; background: var(--forest); }
.app-header-inner, main {
  width: min(100%, 980px);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
.app-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-size: 1.4rem; font-weight: 850; letter-spacing: -.025em; }
.brand-mark { width: 36px; height: 36px; display: inline-grid; place-items: center; background: var(--lime); color: var(--forest); border-radius: 10px; }
.app-header-actions { display: flex; align-items: center; gap: 6px; }
.header-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 8px 10px; background: transparent; border: 1px solid #596d60; border-radius: 10px; color: #f3f8ef; font-size: .875rem; }
.header-button svg { width: 17px; height: 17px; }
@media (max-width: 350px) { .header-button span { display: none; } }
@media (display-mode: standalone) { .install-app { display: none; } }

.app-intro { padding: 25px 0 19px; }
.app-tagline { margin: 0 0 6px; color: var(--green); font-weight: 700; }
h1, h2, h3, p { margin-block-start: 0; }
h1 { margin-block-end: 9px; font-size: clamp(1.85rem, 7.4vw, 2.55rem); line-height: 1.08; letter-spacing: -.055em; }
h2 { font-size: 1.3rem; line-height: 1.2; letter-spacing: -.025em; }
.app-privacy, .source-hint { display: flex; align-items: center; gap: 7px; color: var(--muted); margin: 0; font-size: .875rem; }
.app-privacy svg, .source-hint svg { width: 17px; height: 17px; }

.compressor-grid { display: grid; gap: 14px; min-width: 0; }
.media-panel, .settings-panel, .progress-section, .result-section {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.media-panel, .settings-panel { padding: 14px; }
.dropzone {
  padding: 20px 14px 10px;
  text-align: center;
  border: 1px dashed #9cb6a2;
  border-radius: 15px;
  background: var(--soft);
  transition: background .2s ease;
}
.dropzone:is(.dragover, .dragging, .drag) { background: #e2efc9; border-color: var(--green); }
.import-icon { width: 47px; height: 47px; display: inline-grid; place-items: center; margin-bottom: 10px; border-radius: 14px; color: var(--green); background: #e1eadb; }
.dropzone h2 { margin-bottom: 5px; }
.dropzone p { margin-bottom: 14px; color: var(--muted); }
.dropzone .import-formats { margin: 8px 0 0; font-size: .875rem; }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border: 1px solid transparent; border-radius: 11px; font-weight: 750; text-decoration: none; text-align: center; }
.primary { background: var(--lime); color: var(--forest); border-color: #b9dc60; }
.secondary { background: var(--soft); color: var(--green); border-color: var(--border); }
.button svg { width: 19px; height: 19px; }
.choose-button, .compress-button { width: 100%; }
.sample-button, .preview-button, .text-button, footer button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px;
  padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--green); font-weight: 650;
}
.sample-button svg, .preview-button svg { width: 17px; height: 17px; }

.file-heading, .settings-title, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.file-heading { margin-bottom: 10px; }
.file-heading > div { flex: 1; min-width: 0; }
.file-heading strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-heading small, .video-info, .result-bottom small { color: var(--muted); font-size: .875rem; }
.file-icon, .result-icon, .working-icon { display: inline-grid; place-items: center; flex: none; width: 39px; height: 39px; border-radius: 10px; color: var(--green); background: var(--soft); }
.icon-button { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--green); }
.preview-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.preview-tabs button, .mode-tabs button { min-height: 44px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 6px 9px; font-size: .875rem; font-weight: 700; }
.preview-tabs .selected, .mode-tabs .selected { background: #e3eddb; border-color: #bccdb6; color: var(--forest); }
.preview-tabs > span { margin-left: auto; font-size: .75rem; color: var(--muted); }
.video-stage { height: clamp(165px, 42vw, 268px); background: var(--forest); border-radius: 12px; overflow: hidden; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-info { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 0; }
.settings-title { margin-bottom: 10px; }
.settings-title h2 { margin: 0; }
.settings-title svg { color: var(--green); }

.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #f3f5f0; border-radius: 11px; margin-bottom: 10px; }
.quality-options { display: grid; gap: 6px; }
.quality-card { width: 100%; min-height: 53px; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-align: left; }
.quality-card.selected { background: var(--soft); border-color: #91ae86; }
.quality-card strong, .quality-card small { display: block; }
.quality-card small { color: var(--muted); font-size: .875rem; }
.quality-tag { margin-left: auto; color: var(--green); font-size: .875rem; white-space: nowrap; }
.radio { flex: none; width: 16px; height: 16px; border: 1px solid #758b78; border-radius: 50%; }
.quality-card.selected .radio { border: 5px solid var(--green); }
.advanced { margin-top: 8px; border-bottom: 1px solid var(--border); }
.advanced summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; font-weight: 700; }
.advanced summary::-webkit-details-marker { display: none; }
.chevron { width: 8px; height: 8px; margin-right: 4px; border: solid var(--green); border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.advanced[open] .chevron { transform: translateY(2px) rotate(225deg); }
.advanced-fields { display: grid; gap: 8px; padding: 2px 0 12px; }
.field-row, .toggle-row, .trim-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-row select, .trim-fields input, .size-input input {
  min-height: 44px; padding: 7px 9px; border: 1px solid #b9c9b9; border-radius: 8px; color: var(--ink); background: var(--surface); font-size: 1rem;
}
.field-row select { appearance: none; padding-right: 32px; background: var(--surface) url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" stroke="%23325844" stroke-width="1.5"%3E%3Cpath d="m3 5 4 4 4-4"/%3E%3C/svg%3E') no-repeat right 9px center; }
.toggle-row { min-height: 44px; cursor: pointer; }
.toggle-row > span:first-child { display: flex; align-items: center; gap: 7px; }
.toggle-row input { appearance: none; flex: none; width: 38px; height: 23px; padding: 2px; border: 1px solid #879a88; border-radius: 20px; background: #d7e0d6; }
.toggle-row input::before { content: ""; display: block; width: 17px; height: 17px; border-radius: 50%; background: white; }
.toggle-row input:checked { background: var(--green); }
.toggle-row input:checked::before { transform: translateX(15px); }
.switch { display: none; }
.trim-fields, .size-shortcuts { display: flex; gap: 7px; }
.trim-fields label { min-width: 0; display: grid; gap: 3px; flex: 1; }
.trim-fields input, .size-input input { width: 100%; min-width: 0; }
.field-help, .size-settings p { font-size: .875rem; color: var(--muted); }
.size-settings p { margin: 8px 0 0; }
.size-input { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.size-shortcuts button { min-height: 44px; flex: 1; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.size-shortcuts button.selected { background: var(--soft); border-color: #91ae86; }

.estimate { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 9px; margin: 12px 0 9px; }
.estimate > div > span { display: block; font-size: .75rem; font-weight: 750; color: var(--muted); }
.estimate strong { font-size: 1.13rem; }
.estimate p { width: 100%; margin: 0; font-size: .875rem; color: var(--muted); }
.saved-pill, .result-savings { color: #325d2b; background: #e8f2d8; border-radius: 7px; padding: 4px 7px; font-weight: 750; font-size: .875rem; }
.preview-button { width: 100%; }
.output-note { font-size: .875rem; text-align: center; color: var(--muted); }

.notice { color: var(--green); border: 1px solid #b9d1b7; border-radius: 11px; background: #ebf3e3; padding: 10px 12px; margin-bottom: 10px; }
.notice.error { color: #8a392d; background: #fff1eb; border-color: #ebc3b6; }
.notice.warning { color: #694d15; background: #fff5da; border-color: #e7d198; }
.progress-section, .result-section { padding: 14px; margin-top: 14px; scroll-margin-block: 12px; }
.progress-top, .progress-top > div, .result-header { display: flex; align-items: center; gap: 8px; }
.progress-top, .progress-meta { justify-content: space-between; }
.progress-top p, .result-header p, .progress-meta, .save-hint { color: var(--muted); margin: 3px 0 0; font-size: .875rem; }
.progress-meta { display: flex; gap: 8px; }
.progress-track { height: 8px; background: var(--soft); border-radius: 8px; overflow: hidden; margin: 9px 0; }
#progress-bar { height: 100%; width: 0; background: #5a8645; transition: width .2s ease; }
.result-header { flex-wrap: wrap; }
.result-header h2 { margin: 0; }
.result-bottom { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.result-bottom strong { overflow-wrap: anywhere; }
.result-bottom small { display: block; margin: 3px 0 9px; }
.result-actions { display: grid; gap: 6px; }
#download { grid-row: 1; }
.save-hint { margin-top: 9px; padding: 8px; background: var(--soft); border-radius: 8px; }
footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 6px; color: var(--muted); font-size: .875rem; padding: 9px 0 max(15px, env(safe-area-inset-bottom)); }
footer a { display: inline-flex; min-height: 44px; align-items: center; padding-inline: 6px; }
.footer-sep { opacity: .6; }

dialog { width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: #11281f99; }
dialog h2 { margin: 10px 0; }
dialog p, dialog li { line-height: 1.5; color: var(--muted); }
dialog ol { padding-left: 23px; }
dialog > .button { width: 100%; margin-top: 6px; }
.dialog-note, .install-steps { padding: 10px; border-radius: 9px; background: var(--soft); }
.install-steps h3 { margin: 0; }
.install-steps ol { margin: 6px 0 0; }
.install-other, .install-footnote { font-size: .875rem; margin: 8px 0; }

@media (min-width: 780px) {
  .app-header-inner, main { padding-inline: 24px; }
  .compressor-grid:has(.settings-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); align-items: start; }
  .media-panel, .settings-panel { padding: 20px; }
  .dropzone { padding: 30px 24px 14px; }
  .choose-button { max-width: 360px; }
  .sample-button { display: flex; margin-inline: auto; }
  .video-stage { height: 300px; }
  .result-actions { display: flex; flex-direction: row-reverse; }
}

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