/* FlixFormat — "Bright & Friendly" (design B). Mobile first.
   Uses logical properties (inline/block) so Arabic (dir="rtl") mirrors automatically. */
:root {
  --ink: #1B1B1F;
  --ink-2: #55555E;
  --ink-3: #6E6E78;
  --bg: #FFFFFF;
  --soft: #F2F2F4;
  --sun: #FFC727;
  --sun-soft: #FFF6D9;
  --sun-ink: #6B5A1E;
  --blue-soft: #E8F0FF;
  --blue: #1F47B8;
  --green: #0A7A3E;
  --tile-1: #E8F0FF; --tile-2: #FFF0E5; --tile-3: #E9F8EF; --tile-4: #FFF6D9; --tile-5: #F0ECFF;
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Thai", "Noto Sans Arabic", "Noto Sans JP", Tahoma, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; }
a { color: var(--ink); }
a:hover { color: #000; }
img, svg { display: block; }
button { font: inherit; }
.wrap { max-width: 720px; margin-inline: auto; padding-inline: 16px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Language suggestion bar */
.suggest { display: none; background: var(--blue-soft); color: var(--ink); font-size: 15px; }
.suggest.show { display: block; }
.suggest .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-block: 8px; }
.suggest-actions { display: flex; gap: 8px; }
.suggest a, .suggest button { min-height: 40px; padding-inline: 14px; border-radius: 20px; border: 0; font-weight: 700; display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }
.suggest a { background: var(--ink); color: #fff; }
.suggest button { background: transparent; color: var(--ink); }

/* Header */
.site-header .wrap { display: flex; justify-content: space-between; align-items: center; padding-block: 12px; gap: 12px; }
.logo { font-size: 22px; font-weight: 900; letter-spacing: -0.6px; text-decoration: none; color: var(--ink); direction: ltr; }
.logo span { background: var(--sun); padding: 0 4px; border-radius: 6px; }

/* Language switcher: <details> with plain links (crawlable, works without JS) */
.lang { position: relative; }
.lang summary { list-style: none; display: flex; align-items: center; gap: 6px; min-height: 44px; padding-inline: 14px; border-radius: 22px; background: var(--soft); font-weight: 600; font-size: 15px; cursor: pointer; }
.lang summary::-webkit-details-marker { display: none; }
.lang-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; width: 260px; max-width: calc(100vw - 32px); background: #fff; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.16); padding: 8px; }
.lang-panel ul { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.lang-panel li a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding-inline: 12px; border-radius: 12px; text-decoration: none; font-size: 16px; }
.lang-panel li a:hover { background: var(--soft); }
.lang-panel li a[aria-current="true"] { font-weight: 800; background: var(--sun-soft); }
.set-default { width: 100%; margin-block-start: 6px; min-height: 44px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; font-weight: 700; cursor: pointer; }
.set-default[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Hero */
.hero { padding-block: 8px 4px; display: flex; flex-direction: column; gap: 12px; }
.badge { align-self: flex-start; font-size: 13px; font-weight: 700; background: var(--blue-soft); color: var(--blue); padding: 6px 12px; border-radius: 14px; }
h1 { margin: 0; font-size: clamp(32px, 9vw, 44px); line-height: 1.1; font-weight: 900; letter-spacing: -0.02em; }
:lang(ar) h1, :lang(th) h1, :lang(ja) h1 { line-height: 1.35; letter-spacing: 0; }
.sub { margin: 0; font-size: 17px; color: var(--ink-2); }

/* Tool card */
.tool { margin-block-start: 16px; background: var(--sun-soft); border-radius: 28px; padding: 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.tool-icon { width: 72px; height: 72px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; }
.btn-main { width: 100%; min-height: 60px; border: 0; border-radius: 30px; background: var(--ink); color: #fff; font-size: 18px; font-weight: 800; cursor: pointer; }
.btn-main[disabled] { opacity: .55; cursor: not-allowed; }
.formats { font-size: 14px; color: var(--sun-ink); direction: ltr; }
.privacy-line { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 14px; padding: 10px 14px; font-size: 15px; font-weight: 700; }
.output { font-size: 15px; font-weight: 800; background: var(--sun); padding: 10px 16px; border-radius: 22px; }
.elsewhere { font-size: 14px; color: var(--sun-ink); }
.elsewhere a { font-weight: 700; color: var(--ink); }
.pending { font-size: 13px; color: var(--sun-ink); }

.trust { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-block: 16px; }
.trust div { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 13px; font-weight: 600; color: #3A3A42; }
.faq-jump { display: flex; justify-content: center; }
.faq-jump a { font-weight: 700; padding: 12px; }

/* Sponsored */
.sponsor { margin-block: 8px; border-radius: 20px; background: var(--soft); padding: 16px; display: flex; gap: 12px; align-items: center; }
.sponsor-logo { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: #fff; }
.sponsor small { display: block; font-size: 12px; color: var(--ink-3); }
.sponsor .label { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sponsor strong { display: block; font-size: 15px; }

/* Sections */
section { padding-block: 20px 4px; }
h2 { margin: 0 0 12px; font-size: 22px; font-weight: 900; }
.steps { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; align-items: flex-end; min-height: 72px; border-radius: var(--radius); padding: 16px; font-size: 15px; font-weight: 800; text-decoration: none; }
.tile:nth-child(5n+1) { background: var(--tile-1); } .tile:nth-child(5n+2) { background: var(--tile-2); }
.tile:nth-child(5n+3) { background: var(--tile-3); } .tile:nth-child(5n+4) { background: var(--tile-4); }
.tile:nth-child(5n) { background: var(--tile-5); }
details.qa { background: var(--soft); border-radius: 16px; margin-block-end: 10px; }
details.qa summary { list-style: none; cursor: pointer; padding: 16px; font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary::after { content: "+"; font-weight: 900; }
details.qa[open] summary::after { content: "–"; }
details.qa p { margin: 0; padding: 0 16px 16px; color: var(--ink-2); }

/* Share */
.share { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.share a, .share button { min-height: 52px; border: 0; border-radius: 16px; background: var(--soft); color: var(--ink); font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; }
.share .native { background: var(--ink); color: #fff; grid-column: 1 / -1; }
.share-status { min-height: 1.5em; font-size: 14px; color: var(--green); margin: 8px 0 0; }

/* Legal / text pages */
.prose { padding-block: 16px 32px; }
.prose p { color: var(--ink-2); }

/* Footer */
.site-footer { margin-block-start: 32px; background: var(--soft); }
.site-footer .wrap { padding-block: 24px; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: var(--ink-3); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer nav a { color: var(--ink); min-height: 32px; display: inline-flex; align-items: center; }

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool { padding: 32px; }
}

/* ---- Working tool (Chunk 3) ---- */
.tool-work, .tool-done { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tool.is-drag { outline: 3px dashed var(--ink); outline-offset: -8px; }
.btn-main { transition: transform .08s ease, background-color .15s ease; }
.btn-main:active:not([disabled]) { transform: scale(.97); }
/* Progress: the button fills with yellow as the work advances (right-to-left in Arabic) */
.btn-main.is-progress {
  --dir: to right;
  background: linear-gradient(var(--dir), var(--sun) var(--p, 0%), #fff var(--p, 0%));
  color: var(--ink); border: 2px solid var(--ink); opacity: 1; cursor: progress;
  font-variant-numeric: tabular-nums;
}
[dir="rtl"] .btn-main.is-progress { --dir: to left; }
.file-info { width: 100%; background: #fff; border-radius: 14px; padding: 12px 14px; font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.file-name { font-weight: 700; word-break: break-all; }
.file-est { font-weight: 800; }
.change-file { align-self: center; background: none; border: 0; text-decoration: underline; font-weight: 600; color: var(--sun-ink); min-height: 40px; cursor: pointer; }
.tool-status { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--sun-ink); }
.tool-status.is-error { color: #A11A1A; font-weight: 700; }
.done-check { width: 64px; height: 64px; border-radius: 50%; background: var(--ink); display: flex; align-items: center; justify-content: center; }
.tool-done h2 { margin: 0; font-size: 26px; }
.tool-done h2:focus { outline: none; }
.done-sizes { font-size: 17px; font-weight: 700; display: flex; gap: 10px; align-items: center; direction: ltr; }
.done-sizes s { color: var(--sun-ink); }
.done-sizes strong { background: var(--sun); padding: 4px 10px; border-radius: 12px; }
.tool-done video { width: 100%; max-height: 320px; border-radius: 16px; background: #EDE3C2; }
.btn-send { display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-save { width: 100%; min-height: 52px; border: 2px solid var(--ink); border-radius: 26px; background: transparent; color: var(--ink); font-size: 16px; font-weight: 700; cursor: pointer; }
.btn-save.btn-main { background: var(--ink); color: #fff; }
.send-hint { margin: 0; font-size: 13px; color: var(--sun-ink); }
.tool-done .sponsor { width: 100%; background: #fff; text-align: start; }
.btn-again { background: none; border: 0; font-size: 16px; font-weight: 800; text-decoration: underline; min-height: 44px; cursor: pointer; color: var(--ink); }

/* "How small?" choice (general compressor) */
.levels { width: 100%; }
.lv-label { font-weight: 700; font-size: 15px; margin: 2px 0 8px; text-align: center; }
.lv-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lv { background: #fff; border: 2px solid transparent; border-radius: 14px; padding: 10px 6px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; color: var(--ink, #1f2937); cursor: pointer; }
.lv b { font-size: 14px; line-height: 1.2; }
.lv-est { font-size: 13px; opacity: .75; }
.lv[aria-checked="true"] { border-color: var(--blue, #2563eb); box-shadow: 0 2px 10px rgba(37,99,235,.18); }
.levels.is-locked { opacity: .55; pointer-events: none; }
.tool.has-levels .output { display: none; }
.saves-mp4 { font-size: 13px; color: var(--ink-2); text-align: center; margin-top: -4px; }

/* Trimmer */
.trim { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.trim-preview { width: 100%; max-height: 46vh; background: #000; border-radius: 14px; }
.trim-nopreview { font-size: 14px; color: var(--ink-2); text-align: center; margin: 0; }
.trim-range { position: relative; height: 44px; }
.trim-range::before { content: ""; position: absolute; left: 0; right: 0; top: 18px; height: 8px; border-radius: 4px; background: #fff; }
.trim-fill { position: absolute; top: 18px; height: 8px; border-radius: 4px; background: var(--blue); left: 0; right: 0; }
.trim-range input[type=range] { position: absolute; left: 0; top: 0; width: 100%; height: 44px; margin: 0; background: none;
  pointer-events: none; -webkit-appearance: none; appearance: none; }
.trim-range input[type=range]::-webkit-slider-runnable-track { background: none; height: 44px; }
.trim-range input[type=range]::-moz-range-track { background: none; }
.trim-range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 28px; height: 40px; margin-top: 2px;
  border-radius: 10px; background: var(--ink); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: grab; }
.trim-range input[type=range]::-moz-range-thumb { pointer-events: auto; width: 22px; height: 34px; border-radius: 10px; background: var(--ink);
  border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: grab; }
.trim-range input[type=range]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--sun); }
.trim-times { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.trim-times b { color: var(--ink); font-variant-numeric: tabular-nums; }
.trim-set { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trim-set button { background: #fff; border: 0; border-radius: 12px; min-height: 44px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.lv-row-2 { grid-template-columns: 1fr 1fr; }
.tool.has-trim .output, .tool.has-trim .formats, .tool.has-trim .saves-mp4 { display: none; }
.trim.is-locked { opacity: .55; pointer-events: none; }

/* Image converter (bulk) */
.img-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow-y: auto; }
.img-item { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 6px 10px 6px 6px; }
.img-thumb { width: 48px; height: 48px; border-radius: 8px; background: var(--soft); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-meta { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.img-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.img-size { color: var(--ink-2); font-size: 13px; }
.img-state { font-size: 13px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.img-state.ok { color: var(--green); }
.img-state.bad { color: #B42318; }
.img-format { width: 100%; }
.tool.has-files .output, .tool.has-files .tool-icon { display: none; }
.tool.is-busy .change-files, .tool.is-busy .img-format { opacity: .55; pointer-events: none; }
.tool.is-drop { outline: 3px dashed var(--blue); outline-offset: 4px; }
.img-done-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.img-done-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.img-more { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 10px; background: #fff; font-weight: 700; }
.img-list { max-height: 228px; }
.img-item { padding-top: 4px; padding-bottom: 4px; }
.img-thumb { width: 44px; height: 44px; }
.img-item { grid-template-columns: 44px 1fr auto; }
.img-thumb img[loading] { content-visibility: auto; }
.privacy-line { font-size: 14px; justify-content: center; text-align: center; }
.output { text-align: center; }
.reframe { width: 100%; display: flex; flex-direction: column; gap: 6px; } .reframe.is-locked { opacity: .55; pointer-events: none; } .reframe .lv-label { margin-top: 4px; }

/* ---- Laptop / desktop layout: phones keep the single column above ---- */
@media (min-width: 960px) {
  .wrap { max-width: 1140px; padding-inline: 32px; }
  .top {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); column-gap: 56px;
    grid-template-areas: "hero tool" "trust tool" "jump tool" ". tool"; align-items: start; padding-block-start: 24px;
  }
  .top > .hero { grid-area: hero; padding-block-start: 40px; }
  .top > .tool { grid-area: tool; margin-block-start: 0; }
  .top > .trust { grid-area: trust; justify-items: start; padding-block: 24px 8px; }
  .top > .trust div { flex-direction: row; text-align: start; font-size: 15px; gap: 10px; }
  .top > .faq-jump { grid-area: jump; justify-content: flex-start; }
  .top > .faq-jump a { padding-inline: 0; }
  .hero h1 { font-size: clamp(40px, 4.2vw, 56px); line-height: 1.08; }
  .hero .sub { font-size: 19px; }
  .tool .btn-main { max-width: 100%; }
  .below { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); column-gap: 56px; align-items: start; margin-block-start: 24px; }
  .below #faq { margin-block-start: 0; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sponsor[data-slot="below-tool"] { max-width: 640px; }
}
@media (min-width: 960px) {
  .sponsor[data-slot="below-tool"] { max-width: none; }
  .top > .trust { grid-template-columns: repeat(3, auto); column-gap: 28px; justify-content: start; }
  .top > .trust div { white-space: nowrap; }
}
/* Focus ring only for keyboard users, not after a tap or click */
details.qa summary:focus { outline: none; }
details.qa summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 14px; }
.lang summary:focus { outline: none; }
.lang summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
/* Footer centered on laptop/desktop */
@media (min-width: 960px) {
  .site-footer .wrap { align-items: center; text-align: center; }
  .site-footer nav { justify-content: center; }
}
/* Legal / text pages: comfortable reading width, consistent text colour */
.prose { max-width: 720px; }
.prose li { color: var(--ink-2); margin-block: 4px; }
.prose ul { padding-inline-start: 22px; }
.prose h2 { font-size: 20px; margin-block: 28px 8px; }
.prose a { font-weight: 600; }
@media (min-width: 960px) { .prose { margin-inline: auto; } }
/* Contact form */
.contact form { display: flex; flex-direction: column; gap: 6px; margin-block: 16px; }
.contact label { font-weight: 700; font-size: 15px; margin-block-start: 10px; }
.contact label span { font-weight: 400; color: var(--ink-3); }
.contact input, .contact select, .contact textarea { font: inherit; font-size: 16px; padding: 12px 14px; border: 2px solid #E2E2E6; border-radius: 14px; background: #fff; color: var(--ink); }
.contact input:focus, .contact select:focus, .contact textarea:focus { outline: none; border-color: var(--blue); }
.contact .btn-main { margin-block-start: 16px; }
.contact .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-status { min-height: 1.5em; font-weight: 600; }
.cf-status.is-ok { color: var(--green); }
.cf-status.is-error { color: #B42318; }
.cf-note { font-size: 14px; }
/* Sponsored offer slots */
.sponsor { flex-direction: column; align-items: stretch; gap: 6px; }
.sponsor-link { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.sponsor-logo { display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; color: var(--ink-2); overflow: hidden; }
.sponsor-logo img { width: 100%; height: 100%; object-fit: contain; }
.sponsor-body { display: flex; flex-direction: column; gap: 2px; text-align: start; min-width: 0; }
.sp-t { font-size: 14px; color: var(--ink-2); }
.sp-cta { margin-block-start: 4px; font-weight: 800; font-size: 14px; color: var(--blue); }
.sp-cta::after { content: " →"; }
[dir="rtl"] .sp-cta::after { content: " ←"; }
.sp-note { font-size: 11px; color: var(--ink-3); text-align: start; }
