:root {
  --bg: #f6f2eb;
  --panel: #fffdf9;
  --line: #e6dfd3;
  --ink: #2a2521;
  --muted: #80766c;
  --accent: #c4552b;
  --accent-ink: #fff;
  --accent-soft: #f7e3d9;
  --start: #22a06b;
  --end: #e5484d;
  --warn: #b7791f;
  --soft: #d92d20;        /* zoomed closer than the image can fill */
  --warn-soft: #fbf0db;
  --ok: #22a06b;
  --stage: #2a2521;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(42, 37, 33, .06), 0 4px 16px rgba(42, 37, 33, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons & fields ---------- */
.btn {
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
  background: var(--panel); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; position: relative;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:not(:disabled):hover { background: #ad4722; }
.btn.ghost { border-color: var(--line); background: var(--panel); }
.btn.ghost:not(:disabled):hover { border-color: #cfc5b6; background: #fbf8f3; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 20px; font-size: 15px; }
.btn input[type=file], .add-images input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, .box:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff;
  min-width: 110px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 11px; padding-left: 2px;
}
.privacy { margin: 0 auto 0 8px; color: var(--muted); font-size: 13px; }
.privacy::before { content: "🔒 "; }
a.brand { color: inherit; text-decoration: none; }

/* account bar: usage chip, pricing, account / log in */
.account-bar { display: flex; align-items: center; gap: 4px; }
.acct-link {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; text-decoration: none;
}
.acct-link:hover { color: var(--ink); background: #f3eee6; }
.usage {
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; margin-right: 4px;
  background: #f3eee6; color: var(--ink); white-space: nowrap;
}
.usage.out { background: var(--warn-soft); color: #7a4f10; }
.usage.pro { background: var(--accent-soft); color: #8c3a1b; }

/* ---------- layout ---------- */
.workspace {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px;
}
.panel { background: var(--panel); overflow-y: auto; padding: 14px; }
.shots-panel { border-right: 1px solid var(--line); }
.settings-panel { border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 10px 2px 0; }

/* ---------- shots ---------- */
.shot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.shot {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center;
  padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  cursor: pointer; user-select: none;
}
.shot:hover { border-color: #cfc5b6; }
.shot.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.shot.dragging { opacity: .4; }
.shot.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.shot.drop-after { box-shadow: 0 3px 0 var(--accent); }
.shot canvas { width: 52px; height: 52px; border-radius: 6px; display: block; background: #eee; }
.shot .meta { min-width: 0; }
.shot .title { font-weight: 600; display: flex; align-items: center; gap: 5px; }
.shot .file { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot .secs { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shot .warn-dot { color: var(--warn); font-size: 12px; }
.shot .remove {
  border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1;
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
}
.shot .remove:hover { background: #f3ede4; color: var(--ink); }

.add-images {
  position: relative; margin-top: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px; border: 1.5px dashed #d6ccbd; border-radius: var(--radius);
  cursor: pointer; text-align: center; font-weight: 600;
}
.add-images:hover { border-color: var(--accent); background: #fffaf5; }
.add-images .plus { font-size: 20px; color: var(--accent); line-height: 1; }
.add-images small { font-weight: 400; font-size: 11px; }
.add-images.full { display: none; }

/* ---------- stage ---------- */
.stage-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage {
  flex: 1; min-height: 0; position: relative;
  background: var(--stage);
  display: flex; align-items: center; justify-content: center;
  padding: 28px; overflow: hidden;
}
.empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 24px; overflow-y: auto; }
.empty-inner { max-width: 460px; text-align: center; }
.empty h1 { font-size: 28px; line-height: 1.2; margin-bottom: 10px; letter-spacing: -.01em; }
.empty p { color: var(--muted); margin: 0 0 18px; }
.empty .btn { margin-top: 4px; }
.empty .small { margin-top: 10px; }
.restore {
  margin-top: 24px; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.restore p { color: var(--ink); margin: 0 0 8px; }
.restore ul { margin: 0 0 10px; padding-left: 18px; color: var(--muted); font-size: 13px; }

.frame { position: relative; line-height: 0; box-shadow: 0 8px 30px rgba(0, 0, 0, .35); }
.frame canvas { display: block; }

.box, .playhead { position: absolute; }
.box {
  border: 2px solid var(--start); cursor: move; touch-action: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.box.end { border-color: var(--end); border-style: dashed; }
.box.active { box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 0 0 4px rgba(255, 255, 255, .45); }
.box .tag {
  position: absolute; top: -22px; left: -2px;
  font: 700 10px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .06em;
  padding: 4px 6px; border-radius: 4px; background: var(--start); color: #fff; white-space: nowrap;
}
.box.end .tag { background: var(--end); top: auto; bottom: -22px; left: auto; right: -2px; }
.box .h {
  position: absolute; width: 14px; height: 14px; background: #fff;
  border: 2px solid var(--start); border-radius: 3px;
}
.box.end .h { border-color: var(--end); }
.h.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.h.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.h.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.h.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.box.soft { border-color: var(--soft) !important; border-style: solid; border-width: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.4); background: repeating-linear-gradient(45deg, rgba(217,45,32,.16) 0 8px, transparent 8px 16px); }
.box.soft .tag { background: var(--soft); }
.box.soft .tag::after { content: " · SOFT"; }
.box.soft .h { border-color: var(--soft); }
.playhead {
  border: 2px solid #ffd166; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(20, 16, 12, .45);
}

.shot-controls { padding: 12px 16px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; margin-bottom: 10px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 2px solid; }
.swatch.start { border-color: var(--start); }
.swatch.end { border-color: var(--end); border-style: dashed; }
.control-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.sharpness { margin: 10px 0 0; font-size: 13px; padding: 7px 10px; border-radius: 8px; background: #eef7f1; color: #1d6b49; }
.swatch.soft { background: var(--soft); border-color: var(--soft); }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 1200px) { .tagline { display: none; } }
.sharpness.bad { background: #fdecec; color: #a3231c; font-weight: 600; }

/* ---------- settings ---------- */
.setting { margin-bottom: 18px; }
.label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.seg { display: flex; background: #f1ebe2; border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  border: 0; background: transparent; border-radius: 7px; padding: 6px 4px; cursor: pointer;
}
.seg button[aria-checked=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.setting > small { display: block; margin-top: 5px; font-size: 12px; }
.range { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { font-size: 12px; color: var(--muted); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.duration-head { display: flex; justify-content: space-between; align-items: baseline; }
.duration-head strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 8px; background: #efe8de; border-radius: 4px; overflow: hidden; margin: 6px 0 6px; }
.meter .fill { height: 100%; width: 0; background: var(--ok); transition: width .15s; }
.meter .mark { position: absolute; top: 0; bottom: 0; left: 33.333%; width: 2px; background: #fff; }
.duration.over strong, .duration.over #durationNote { color: var(--end); }
.duration.over .fill { background: var(--end); }
.duration.under strong, .duration.under #durationNote { color: var(--warn); }
.duration.under .fill { background: var(--warn); }
#durationNote { font-size: 12px; display: block; }

.preview-box {
  background: var(--stage); border-radius: var(--radius); overflow: hidden;
  display: flex; justify-content: center; align-items: center;
}
.preview-box canvas { display: block; width: 100%; height: auto; }
.preview-box.vertical canvas { width: auto; height: 340px; max-width: 100%; }
.preview-controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.preview-controls input { flex: 1; accent-color: var(--accent); }

.render { margin-bottom: 14px; }
.progress { height: 8px; background: #efe8de; border-radius: 4px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.render-status { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; }

.result { border-top: 1px solid var(--line); padding-top: 14px; }
.result video { width: 100%; max-height: 340px; background: #000; border-radius: var(--radius); display: block; margin-bottom: 10px; }
.result .btn { width: 100%; }
.stale { background: var(--warn-soft); color: #7a5214; border-radius: 8px; padding: 7px 10px; font-size: 13px; margin: 10px 0 0; }
.checks { list-style: none; padding: 0; margin: 12px 0 8px; font-size: 13px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; padding: 3px 0; }
.checks li::before { content: "✓"; color: var(--ok); font-weight: 700; }
.checks li.bad::before { content: "✗"; color: var(--end); }
.checks .rule { color: var(--muted); font-size: 12px; grid-column: 2; }

/* ---------- overlays ---------- */
.dropzone {
  position: fixed; inset: 0; z-index: 30; background: rgba(196, 85, 43, .12);
  border: 3px dashed var(--accent); display: grid; place-items: center; pointer-events: none;
}
.dropzone div { background: var(--accent); color: #fff; font-weight: 700; padding: 12px 22px; border-radius: 10px; font-size: 16px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 40;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 9px; font-weight: 600;
  transition: opacity .18s, transform .18s; max-width: min(560px, 90vw); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--end); }
.unsupported { position: fixed; inset: 0; z-index: 50; background: rgba(42, 37, 33, .6); display: grid; place-items: center; padding: 16px; }
.unsupported .card { background: var(--panel); border-radius: 14px; padding: 24px 26px; max-width: 480px; box-shadow: var(--shadow); }
.unsupported h2 { font-size: 20px; margin-bottom: 10px; }

/* ---------- narrow screens: editing is a desktop job, but nothing should break ---------- */
@media (max-width: 1000px) {
  body { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .shots-panel, .settings-panel { border: 0; border-bottom: 1px solid var(--line); }
  .stage { min-height: 60vh; padding: 20px 16px; }
  .privacy { display: none; }
  .account-bar { margin-left: auto; }
  #pricingLink { display: none; }
  .topbar { justify-content: space-between; }
}
