/* MakeItFit - the family's light UI (aiworld-brand/assets/web/app-style.css tokens), dark from the OS.
   Phone first. Logical properties (inline-start/end) so right-to-left languages can be added later. */
:root {
  --ground: #f5f5f8; --surface: #ffffff; --surface-2: #efeff5; --border: #e3e3eb; --border-strong: #d2d2de;
  --ink: #191923; --muted: #5f5f70; --faint: #8b8b9a;
  --accent: #5550d8; --accent-strong: #4440c2; --accent-soft: #ebebfd;
  --ok: #16925a; --ok-soft: #e3f5ec; --warn: #a3640a; --warn-soft: #fcf2e0; --danger: #cc3737; --danger-soft: #fcebeb;
  --shadow: 0 1px 2px rgba(22, 22, 44, .06);
  --font: system-ui, -apple-system, "Segoe UI", "Arial Hebrew", "Geeza Pro", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #14141b; --surface: #1c1c25; --surface-2: #252531; --border: #2c2c38; --border-strong: #3a3a48;
    --ink: #ececf3; --muted: #a8a8ba; --faint: #7a7a8c;
    --accent: #8d89f7; --accent-strong: #a6a3ff; --accent-soft: #29284a;
    --ok: #3fcf8e; --ok-soft: #173327; --warn: #f0b44c; --warn-soft: #382c16; --danger: #f27272; --danger-soft: #3a1d1d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }
button { font: inherit; color: inherit; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 10px; margin-inline-end: auto; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.toplink { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-size: 15px; }
.toplink:hover { color: var(--ink); }
.toplink svg { width: 19px; height: 19px; }

/* hero */
.hero { padding: 18px 0 14px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(32px, 7vw, 52px); line-height: 1.05; letter-spacing: -0.025em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lead { margin: 0; color: var(--muted); font-size: 17px; max-width: 36em; }

/* the tool card */
.tool { margin-top: 14px; padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }

.limit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.limit-field { display: inline-flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--ground); cursor: text; }
.limit-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.limit-label { color: var(--muted); font-weight: 600; }
.limit-field input { width: 3.2em; border: 0; padding: 4px 0; background: transparent; color: var(--ink); font: 700 26px var(--font); text-align: center; outline: none; }
.limit-unit { font-weight: 700; font-size: 20px; padding-inline-end: 6px; }
.limit-field.bad { border-color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 14px; cursor: pointer; }
.chips button:hover { border-color: var(--accent); color: var(--ink); }
.chips button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.limit-bad { flex-basis: 100%; margin: 0; color: var(--danger); font-size: 14px; }

.drop { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 16px; border: 2px dashed var(--border-strong); border-radius: 16px; text-align: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.compact { flex-direction: row; justify-content: center; padding: 12px; }
.drop.compact .drop-icon, .drop.compact .drop-title { display: none; }
.drop-icon { width: 46px; height: 46px; color: var(--accent); stroke-width: 2.2; }
.drop-title { margin: 0; font-weight: 600; font-size: 18px; }
.drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.camera { display: none; }
@media (hover: none) and (pointer: coarse) { .camera { display: inline-flex; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--ink); font: 600 16px var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.big { min-height: 54px; padding: 0 28px; font-size: 18px; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .chips button:focus-visible, .seg button:focus-visible, .row-actions button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }

/* the file list */
.files { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.files:empty { display: none; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.file.dragging { opacity: .45; }
.file.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.thumb { flex: none; width: 52px; height: 52px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img, .thumb canvas { max-width: 100%; max-height: 100%; transition: transform .2s; }
.file-text { min-width: 0; flex: 1; }
.file-name { margin: 0; font-weight: 600; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.file-meta { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.file-meta .flag { color: var(--warn); font-weight: 600; }
.row-actions { flex: none; display: flex; gap: 2px; }
.row-actions button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.row-actions button:hover { background: var(--surface-2); color: var(--ink); }
.row-actions button:disabled { opacity: .3; cursor: default; background: transparent; }
.row-actions svg { width: 19px; height: 19px; }

.summary { margin-top: 14px; display: grid; gap: 12px; }
.total { font-size: 16px; font-variant-numeric: tabular-nums; }
.total .over { color: var(--warn); font-weight: 600; }
.total .fits { color: var(--ok); font-weight: 600; }
.output { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.output-label { color: var(--muted); font-weight: 600; }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 15px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.seg button:disabled { opacity: .4; cursor: default; }
.note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); font-size: 15px; }
.go-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.go-row .big { flex: 1 1 220px; }

/* panels: working, ask, can't fit, result */
.panel { margin-top: 14px; padding: 16px; border-radius: 14px; background: var(--ground); border: 1px solid var(--border); }
.panel h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.01em; }
.panel p { margin: 0 0 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stage { font-weight: 600; color: var(--ink) !important; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.bar div { height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width .2s; }
.bar.busy div { width: 35%; animation: busy 1.1s ease-in-out infinite; }
@keyframes busy { from { margin-inline-start: -35%; } to { margin-inline-start: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar.busy div { animation: none; width: 100%; opacity: .5; } }
.ask, .cant { background: var(--accent-soft); border-color: transparent; }

.result { background: var(--ok-soft); border-color: transparent; }
.result-head { display: flex; gap: 12px; align-items: flex-start; }
.check { flex: none; width: 34px; height: 34px; color: var(--ok); stroke-width: 2.2; }
.result h2 { font-size: 22px; font-variant-numeric: tabular-nums; }
.result .exact { margin: 0 0 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.outputs { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.outputs li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; background: var(--surface); }
.outputs .o-name { flex: 1 1 200px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.outputs .o-size { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.outputs .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.previews { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.previews img, .previews canvas { max-height: 150px; max-width: 46%; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.previews .more { color: var(--muted); font-size: 14px; padding: 0 6px 6px; }

.error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--ink); }

.privacy { margin: 16px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 15px; }
.privacy svg { width: 18px; height: 18px; color: var(--ok); }
.badge { padding: 2px 9px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-size: 13px; font-weight: 600; }
.rule { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.rule b { color: var(--ink); }

footer { margin: 40px 0 0; padding: 22px 0 36px; border-top: 1px solid var(--border); color: var(--faint); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px 20px; }
footer a { color: var(--muted); }

@media (max-width: 480px) {
  .toplink .long { display: none; }
  .chips { gap: 5px; }
  .chips button { padding: 5px 8px; font-size: 13px; }
  .tool { padding: 14px; border-radius: 16px; }
  .file { gap: 10px; }
  .row-actions button { width: 34px; }
}
@media (min-width: 720px) {
  .hero { padding-top: 34px; }
  .tool { padding: 24px; }
}
