/* ------------------------------------------------------------------
   Video Toolkit — shared styles
   Light theme is the default; dark is applied by setting
   data-theme="dark" on the <html> element.
   ------------------------------------------------------------------ */

:root {
  --bg:        #f5f7fa;
  --panel:     #ffffff;
  --panel-2:   #eef1f6;
  --line:      #d9dfe7;
  --text:      #1b2330;
  --muted:     #64748b;
  --accent:    #2f7fc4;
  --accent-dk: #23638f;
  --on-accent: #ffffff;
  --ok:        #1a7f37;
  --err:       #c8341f;
  --shadow:    0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 4px 14px rgba(16, 24, 40, .10);
  --radius:    10px;
}

/* Neutral greys — no blue cast in the greys themselves. The accent is
   the only place colour appears. */
:root[data-theme="dark"] {
  --bg:        #101010;
  --panel:     #181818;
  --panel-2:   #222222;
  --line:      #2e2e2e;
  --text:      #ededed;
  --muted:     #9a9a9a;
  --accent:    #4a9eda;
  --accent-dk: #3b82b8;
  --on-accent: #101010;
  --ok:        #4ec46a;
  --err:       #f0675a;
  --shadow:    none;
  --shadow-lg: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
  transition: background .18s, color .18s;
}

.wrap { width: 100%; max-width: 980px; }
.wrap.narrow { max-width: 820px; }

/* The home page has little content, so it sits in the middle of the
   screen rather than clinging to the top. Auto margins are used instead
   of justify-content so a short window never clips the top. */
body.home { justify-content: center; }
body.home .wrap { margin: auto 0; }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .01em;
}

.tagline {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Home page header: one centred block, with the theme button pinned to
   the corner so it doesn't pull the title off-centre. */
.home-head {
  display: block;
  text-align: center;
  margin-bottom: 32px;
}
.home-head h1 { font-size: 26px; }
.home-head .tagline { font-size: 14px; margin-top: 6px; }

.theme-fixed {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.back {
  display: inline-block;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 10px;
}
.back:hover { color: var(--accent); }

/* ---------- theme toggle ---------- */
.theme-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* ---------- home cards ---------- */
/* Four wide tiles, two by two. Height follows the content rather than
   being forced square, so the text isn't stranded in a tall box. */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 170px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 28px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border-radius: 11px;
  color: var(--accent);
  margin-bottom: 18px;
}
.card-icon svg { width: 24px; height: 24px; }

.card-title { font-weight: 600; font-size: 17px; margin-bottom: 6px; }
.card-desc  { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* On a phone the tiles stack, and a strict square would leave each one
   taller than the screen. */
@media (max-width: 620px) {
  .cards { grid-template-columns: 1fr; gap: 14px; }
  .card  { min-height: 0; padding: 22px; }
  .card-icon { width: 38px; height: 38px; margin-bottom: 12px; }
  .card-icon svg { width: 20px; height: 20px; }
}

/* ---------- options ---------- */
.options {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
}
.opt-row + .opt-row { border-top: 1px solid var(--line); }

.opt-label { font-size: 14px; }
.opt-hint  { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

select {
  flex: 0 0 auto;
  min-width: 150px;
  padding: 7px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* toggle switch */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background .15s;
  pointer-events: none;
}
.switch .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .15s;
  pointer-events: none;
}
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .knob  { transform: translateX(18px); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- drop zone ---------- */
.drop {
  background: var(--panel);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--panel-2); }
.drop.over { border-style: solid; }
.drop.hide { display: none; }

.drop-icon { font-size: 30px; color: var(--accent); margin-bottom: 10px; line-height: 1; }
.drop strong { display: block; font-weight: 600; margin-bottom: 4px; }
.drop small  { color: var(--muted); font-size: 12.5px; }

input[type=file] { display: none; }

/* ---------- trim editor ---------- */
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: none;
}
.editor.show { display: block; }

.editor video {
  width: 100%;
  max-height: 440px;
  background: #000;
  border-radius: 7px;
  display: block;
  margin-bottom: 14px;
}

/* Shown when the browser can't decode the picture — the trim controls
   stay fully usable, so this is a note rather than an error. */
.editor-note {
  display: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.editor-note.show { display: block; }

/* A video that decoded nothing is just a black rectangle taking up
   space — collapse it down out of the way. */
.editor video.dead { max-height: 90px; opacity: .45; }

.range-row { margin-bottom: 12px; }

.range-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 5px;
}
.range-head .val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

/* Typed timecodes. The only precise way to work when there is no
   picture to look at. */
.time-input {
  width: 86px;
  padding: 4px 8px;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.time-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[type=range] {
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  margin-top: -6px;
  background: var(--accent);
  border: 2px solid var(--panel);
  border-radius: 50%;
}
input[type=range]::-moz-range-track {
  height: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px;
  background: var(--accent);
  border: 2px solid var(--panel);
  border-radius: 50%;
}

/* ---------- clip list (joiner) ---------- */
.clips-head {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.clips { list-style: none; }

.clip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.clip + .clip { margin-top: 8px; }

.clip-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 700;
}

.clip-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clip-size {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.clip-btns { flex: 0 0 auto; display: flex; gap: 4px; }

.clip-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.clip-btn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.clip-btn:disabled { opacity: .3; cursor: not-allowed; }
.clip-btn.remove:hover { color: var(--err); border-color: var(--err); }

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.selection { font-size: 13px; color: var(--muted); }
.selection b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- job panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  display: none;
}
.panel.show { display: block; }

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}
.file-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size { color: var(--muted); font-size: 12.5px; flex: 0 0 auto; }

.bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width .2s linear;
}
.bar-fill.working {
  width: 100% !important;
  background: linear-gradient(90deg, var(--panel-2) 0%, var(--accent) 50%, var(--panel-2) 100%);
  background-size: 200% 100%;
  animation: slide 1.1s linear infinite;
}
@keyframes slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.status { font-size: 13px; color: var(--muted); }
.status.done  { color: var(--ok); }
.status.error { color: var(--err); }

.mode-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  display: none;
}
.mode-note.show { display: block; }

/* FFmpeg's own words, shown only when something failed. */
.detail {
  display: none;
  margin-top: 10px;
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  word-break: break-word;
}
.detail.show { display: block; }

/* ---------- buttons ---------- */
.actions { display: none; gap: 10px; margin-top: 16px; }
.actions.show { display: flex; }

.btn {
  flex: 1;
  display: block;
  padding: 11px 16px;
  border: none;
  border-radius: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-dk); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-inline { flex: 0 0 auto; padding: 9px 18px; }
