:root {
  --bg: #f5f3fa;
  --surface: #ffffff;
  --surface-2: #f1eef8;
  --line: #e4dff0;
  --text: #1d1a2b;
  --muted: #706b84;
  --accent: #6d28d9;
  --accent-2: #c026d3;
  --accent-soft: #efe7ff;
  --on-accent: #ffffff;
  --warn: #b45309;
  --danger: #c0262d;
  --stage: #121019;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .05), 0 10px 30px rgba(30, 20, 60, .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100e17;
    --surface: #1a1824;
    --surface-2: #24212f;
    --line: #312d40;
    --text: #efedf6;
    --muted: #a29eb5;
    --accent: #a37bff;
    --accent-2: #e06ef0;
    --accent-soft: #2b2342;
    --warn: #f0a648;
    --danger: #ff6b6b;
    --stage: #08070c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100e17; --surface: #1a1824; --surface-2: #24212f; --line: #312d40; --text: #efedf6; --muted: #a29eb5;
  --accent: #a37bff; --accent-2: #e06ef0; --accent-soft: #2b2342; --warn: #f0a648; --danger: #ff6b6b; --stage: #08070c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 "Rubik", "Segoe UI", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }
svg { flex: none; }
.muted { color: var(--muted); font-size: 14px; }
body.modal-open { overflow: hidden; }

/* ---------- כותרת ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1200px; width: 100%; margin: 0 auto; padding: 20px 24px 8px;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 28px; letter-spacing: -.5px; direction: ltr; }
.logo b {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { color: var(--muted); font-size: 15px; font-weight: 400; margin: 0; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: none; border: 0; color: var(--accent); font-size: 15px; font-weight: 500;
  cursor: pointer; padding: 8px 10px; border-radius: 10px;
}
.link-btn:hover { background: var(--accent-soft); }
.link-btn svg { width: 18px; height: 18px; fill: currentColor; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 12px 24px 24px; }

/* ---------- בחירת סרטון ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  min-height: 62vh; border-radius: 28px;
  border: 2px dashed var(--line); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; color: inherit; cursor: pointer; padding: 24px 40px; border-radius: 24px;
}
.drop-icon {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 12px 30px rgba(109, 40, 217, .3);
  transition: transform .15s;
}
.drop-icon svg { width: 48px; height: 48px; }
.drop-inner:hover .drop-icon { transform: scale(1.05); }
.drop-title { font-size: 30px; font-weight: 700; }
.drop-sub { color: var(--muted); font-size: 17px; }
.perks { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0; padding: 0 16px; }
.perks li {
  background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 14px;
}

/* ---------- כפתורים ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 16px; font-weight: 500;
  padding: 11px 18px; border-radius: 14px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, border-color .15s, transform .05s;
}
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: var(--on-accent);
  box-shadow: 0 8px 22px rgba(109, 40, 217, .28);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 16px 22px; font-size: 19px; font-weight: 600; width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); }

.mini {
  appearance: none; border: 0; background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 500; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.mini:hover { background: var(--accent-soft); color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 500; padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.pill svg { width: 18px; height: 18px; fill: currentColor; }
.pill:hover { border-color: var(--accent); }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* כפתורי בחירה גדולים */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--surface-2); padding: 4px; border-radius: 14px;
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--text);
  font-size: 15px; font-weight: 500; padding: 10px 4px; border-radius: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1.25;
  transition: background .12s, color .12s;
}
.seg button small { font-size: 12px; color: var(--muted); font-weight: 400; direction: ltr; min-height: 15px; }
.seg button:hover:not(:disabled) { background: var(--surface); }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 4px rgba(30, 20, 60, .12); }
.seg button.on small { color: var(--accent); }
.seg button:disabled { opacity: .35; cursor: default; }
.seg.small { display: inline-grid; padding: 3px; border-radius: 11px; }
.seg.small button { padding: 5px 10px; font-size: 14px; border-radius: 8px; }

input[type=number], select {
  font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0;
}
input[type=number]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }

/* ---------- עורך ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.stage-col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-size: 15px; font-weight: 700;
}

.stage {
  background: var(--stage); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  padding: 14px; min-height: 280px;
}
.frame { position: relative; display: inline-block; line-height: 0; max-width: 100%; overflow: hidden; border-radius: 6px; }
.frame video { display: block; max-width: 100%; max-height: 58vh; cursor: pointer; }

.crop-layer { position: absolute; inset: 0; pointer-events: none; }
.crop-layer.active { pointer-events: auto; cursor: crosshair; }
.crop-box {
  position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .6);
  outline: 2px solid #fff; outline-offset: -1px; cursor: move;
}
.crop-layer:not(.active) .crop-box .hd { display: none; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; inset: 0; pointer-events: none; border: 0 solid rgba(255, 255, 255, .35); }
.crop-box::before { left: 33.33%; right: 33.33%; border-left-width: 1px; border-right-width: 1px; }
.crop-box::after { top: 33.33%; bottom: 33.33%; border-top-width: 1px; border-bottom-width: 1px; }
.hd { position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 4px; z-index: 1; }
.hd[data-h=nw] { left: -8px; top: -8px; cursor: nwse-resize; }
.hd[data-h=ne] { right: -8px; top: -8px; cursor: nesw-resize; }
.hd[data-h=sw] { left: -8px; bottom: -8px; cursor: nesw-resize; }
.hd[data-h=se] { right: -8px; bottom: -8px; cursor: nwse-resize; }

.transport { display: flex; align-items: center; gap: 14px; }
.play-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
}
.play-btn svg { width: 22px; height: 22px; fill: currentColor; }
.play-btn .i-pause, .play-btn.playing .i-play { display: none; }
.play-btn.playing .i-pause { display: block; }

.timeline { position: relative; flex: 1; height: 46px; cursor: pointer; touch-action: none; }
.tl-track { position: absolute; left: 0; right: 0; top: 19px; height: 8px; border-radius: 4px; background: var(--surface-2); }
.tl-sel { position: absolute; top: 19px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tl-handle {
  position: absolute; top: 7px; width: 18px; height: 32px; margin-left: -9px;
  background: var(--accent); border: 3px solid var(--surface); border-radius: 7px;
  cursor: ew-resize; z-index: 2; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.tl-head { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; z-index: 3; border-radius: 1px; opacity: .7; }

/* ציר הזמן רץ משמאל לימין, אז גם "התחלה" משמאל ו"סוף" מימין, מתחת לידיות */
.trim-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin-top: 12px; direction: ltr; }
.t-box { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.t-box.center { align-items: center; justify-content: center; }
.t-box.end { align-items: flex-end; }
.t-label { font-size: 13px; color: var(--muted); }
.t-val { font-size: 17px; font-weight: 600; direction: ltr; font-variant-numeric: tabular-nums; }
.t-val.big { font-size: 20px; color: var(--accent); direction: rtl; }
.hint { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

.crop-tools {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.crop-opts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- הגדרות ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 14px; }
.panel .card-title { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.f-label { font-weight: 500; font-size: 15px; }
.f-head { display: flex; justify-content: space-between; align-items: baseline; }
.val { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.adv { border-top: 1px solid var(--line); padding-top: 12px; }
.adv summary {
  cursor: pointer; font-weight: 500; color: var(--muted); list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before {
  content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; margin-top: -4px;
}
.adv[open] summary::before { transform: rotate(135deg); margin-top: 4px; }
.adv summary:hover { color: var(--accent); }
.adv-body { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; }

.summary {
  font-size: 15px; color: var(--muted);
  background: var(--surface-2); border-radius: 12px; padding: 10px 14px;
}
.summary b { color: var(--text); font-weight: 600; }
.summary em { display: block; font-style: normal; color: var(--warn); font-size: 14px; margin-top: 4px; }
.actions { display: flex; flex-direction: column; gap: 8px; }

.progress { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 0; }
.p-text { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { width: 100%; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; margin-inline-start: 0; }
.error { color: var(--danger); margin: 0; font-size: 15px; }
body.busy .panel .seg, body.busy .panel .adv, body.busy .trim-card { pointer-events: none; opacity: .55; }

/* ---------- חלון התוצאה ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 8, 20, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease-out;
}
.modal-card {
  position: relative; background: var(--surface); border-radius: 24px; padding: 24px;
  width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
  animation: pop .18s ease-out;
}
.modal-card .m-title { margin: 0; font-size: 24px; font-weight: 700; text-align: center; }
.close {
  position: absolute; top: 14px; left: 14px; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.close svg { width: 20px; height: 20px; fill: currentColor; }
.close:hover { color: var(--text); }
.result-img {
  border-radius: 14px; padding: 12px; display: flex; justify-content: center;
  background-color: var(--surface-2);
  background-image: linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%),
    linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
}
.result-img img { max-width: 100%; max-height: 50vh; height: auto; display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 8px; text-align: center; display: flex; flex-direction: column; }
.stats span { font-size: 13px; color: var(--muted); }
.stats b { font-size: 17px; font-weight: 600; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- הסבר ושאלות נפוצות ---------- */
.about { width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 24px 8px; }
.about-inner {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 28px 24px; box-shadow: var(--shadow);
}
.about h2 { font-size: 21px; font-weight: 600; margin: 22px 0 8px; }
.about p, .about li { color: var(--muted); font-size: 16px; }
.about p { margin: 0; max-width: 820px; }
.about b { color: var(--text); font-weight: 600; }
.steps, .why { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 4px; }
.faq { display: flex; flex-direction: column; gap: 8px; }
.faq details { background: var(--surface-2); border-radius: 12px; padding: 10px 16px; }
.faq summary { cursor: pointer; font-weight: 500; color: var(--text); }
.faq details p { margin-top: 6px; }
.nojs { text-align: center; color: var(--danger); }

.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 18px; }

/* ---------- מסכים צרים ---------- */
@media (max-width: 920px) {
  .editor { grid-template-columns: 1fr; }
  .panel { position: static; }
}
@media (max-width: 560px) {
  .top { padding: 14px 16px 4px; }
  .brand { flex-direction: column; gap: 0; }
  .tag { font-size: 13px; }
  .about { padding: 8px 16px; }
  .about-inner { padding: 4px 18px 20px; }
  main { padding: 10px 16px 20px; }
  .stage { padding: 6px; min-height: 180px; }
  .card { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .drop { min-height: 56vh; }
  .drop-title { font-size: 26px; }
  .trim-row { grid-template-columns: 1fr 1fr; }
  .t-box.center { grid-column: 1 / -1; order: -1; }
  .mini { font-size: 12px; }
  .modal { padding: 12px; }
  .modal-card { padding: 20px 16px; }
}
