:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #1e1f22;
  --muted: #5c5e66;
  --border: #d4d7dc;
  --accent: #5865f2;
  --accent-soft: rgba(88, 101, 242, 0.08);
  --ok: #23a55a;
  --err: #da373c;
  --track: #e3e5e8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1f22;
    --card: #2b2d31;
    --text: #f2f3f5;
    --muted: #b5bac1;
    --border: #3f4147;
    --accent-soft: rgba(88, 101, 242, 0.15);
    --track: #1e1f22;
  }
}

* { box-sizing: border-box; }
/* Elements with their own `display` (e.g. .dropzone) must still disappear when [hidden]. */
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
h1 { margin: 0 0 4px; font-size: 22px; }
.sub { margin: 0 0 20px; color: var(--muted); }
.pro-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; color: #fff;
  background: linear-gradient(135deg, var(--accent), #eb459e);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  border: 0;
  padding: 0;
  margin: 0 0 14px;
}
.opt { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.opt input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.opt-note { color: var(--muted); font-size: 13px; }
.options:disabled { opacity: .5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 40px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.dropzone.disabled { opacity: .5; pointer-events: none; }
.dz-icon { font-size: 28px; color: var(--accent); }
.dz-title { font-weight: 600; margin-top: 6px; }
.dz-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.notice.error { border-color: var(--err); color: var(--err); }
.notice.ok { border-color: var(--ok); color: var(--ok); }

.progress { margin-top: 20px; }
.file-name { font-weight: 600; margin-bottom: 12px; word-break: break-all; }
.proc-note { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }
.step { margin-bottom: 14px; }
.step-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bar { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.fill.done { background: var(--ok); }
.fill.failed { background: var(--err); width: 100% !important; animation: none; margin-left: 0; }
.fill.indeterminate { width: 30% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }

.foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* Phones and tablets have no drag-and-drop: show tap wording instead. */
.when-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .when-mouse { display: none; }
  .when-touch { display: inline; }
}

/* ---- Trim screen ---- */
.editor { margin-top: 4px; }
.preview { position: relative; background: #000; border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.preview video { display: block; width: 100%; max-height: 50vh; background: #000; }
.preview-msg { padding: 28px 16px; text-align: center; color: #b5bac1; font-size: 14px; }

.range { position: relative; height: 32px; }
.range .track { position: absolute; left: 0; right: 0; top: 13px; height: 6px; border-radius: 3px; background: var(--track); }
.range .sel { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }
.range .sel.other { opacity: .45; } /* the other parts (multi-part trim) */
.parts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.part-chips { display: contents; }
.part-chip {
  font: inherit; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.part-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.part-chip .x { border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 50%; }
.part-chip .x:hover { color: var(--text); background: var(--accent-soft); }
.add-part {
  font: inherit; font-size: 12px; padding: 5px 10px; border: 1px dashed var(--border); border-radius: 999px;
  background: transparent; color: var(--text); cursor: pointer;
}
.add-part:disabled { opacity: .5; cursor: not-allowed; }
.pro-tag { font-size: 10px; font-weight: 700; color: #fff; padding: 1px 5px; border-radius: 4px; margin-left: 2px;
  background: linear-gradient(135deg, var(--accent), #eb459e); }
.range input[type=range] {
  position: absolute; left: 0; top: 0; width: 100%; height: 32px; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range input[type=range]::-webkit-slider-runnable-track { background: none; height: 32px; }
.range input[type=range]::-moz-range-track { background: none; }
.range input[type=range]::-webkit-slider-thumb {
  pointer-events: auto; -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: 5px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: grab;
}
.range input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: grab;
}
.range input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--text); outline-offset: 2px; }

.times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.t-len { color: var(--text); font-weight: 600; }
.t-len[data-q="great"] { color: var(--ok); }
.t-len[data-q="rough"] { color: var(--err); }
.ed-hint { min-height: 1.4em; font-size: 13px; color: var(--muted); margin: 8px 0 12px; }
.ed-hint.warn { color: var(--err); }

.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.go-hint { font-size: 12px; color: var(--muted); text-align: right; margin: 0 0 8px; }
.go-hint:empty { display: none; }
.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 18px; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }

/* ---- Editing tools ---- */
.tools { border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 14px; }
.tools.disabled .tool-row:not(.always) { opacity: .45; pointer-events: none; } /* "Post as" works without the device encoder */
.opt.disabled { opacity: .45; }
.tool-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tool-label { font-size: 13px; color: var(--muted); min-width: 44px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 13px; padding: 6px 10px; border: 0; background: transparent; color: var(--text);
  cursor: pointer; border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tools-note { font-size: 13px; color: var(--muted); }
.tool-hint { font-size: 12px; color: var(--muted); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* Crop frame over the preview: everything outside it is darkened; drag it to choose what's kept. */
.crop-frame {
  position: absolute; box-sizing: border-box; border: 2px solid #fff; border-radius: 2px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); cursor: move; touch-action: none; z-index: 2;
}
.crop-frame::before, .crop-frame::after { /* rule-of-thirds guides */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .25);
}
.crop-frame::before { left: 33.33%; right: 33.33%; border-top: 0; border-bottom: 0; }
.crop-frame::after { top: 33.33%; bottom: 33.33%; border-left: 0; border-right: 0; }

/* Caption: preview layer drawn with the same code as the encoder (edits.js drawCaption). */
.caption-layer { position: absolute; pointer-events: none; }
.text-input {
  flex: 1; min-width: 0; padding: 7px 10px; font: inherit; font-size: 16px; /* 16px: iOS zooms in on smaller inputs */ color: inherit;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
}
.text-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.resume { margin: 10px 0 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--accent-soft); }
.resume p { margin: 0 0 10px; font-size: 14px; }
.legal-links { margin-top: 10px; text-align: center; font-size: 12px; color: var(--muted); }
.legal-links a { color: var(--muted); }

/* ---- Policy pages (/privacy, /terms) ---- */
.doc { max-width: 720px; line-height: 1.6; }
.doc h2 { font-size: 18px; margin: 26px 0 8px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { font-size: 15px; }
.doc ul { padding-left: 20px; }
.doc li { margin: 4px 0; }
.doc a { color: var(--accent); }
.doc code { font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); }
.doc .foot a { color: var(--muted); }
.doc .agent { padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; }
