:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ec;
  --accent: #0f9d8a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f5f2;
  --warn: #c2410c;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 22px; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.logo span { color: var(--accent); }
.tagline { margin: 0; font-size: 13px; color: var(--muted); }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #c9ced8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.big { padding: 14px 18px; font-size: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 15px; }

/* drop zone */
.drop {
  margin: 28px 0; border: 2px dashed #c8ced9; border-radius: 20px; background: var(--card);
  min-height: 340px; display: grid; place-items: center; text-align: center; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 24px; }
.drop-title { font-size: 24px; font-weight: 800; margin: 0; line-height: 1.4; }
.drop-lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.drop-sub { margin: 18px 0 10px; color: var(--muted); font-size: 13px; }
.drop-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; }

/* editor layout */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; margin: 24px 0; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }

.stage { display: flex; flex-direction: column; gap: 14px; }
.canvas-wrap { position: relative; background: #0d1117; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 240px; cursor: pointer; }
.view-label { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 99px; pointer-events: none; }
#seek { flex: 1; min-width: 120px; }
#view { display: block; max-width: 100%; max-height: 62vh; height: auto; }

.transport { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.spacer { flex: 1; }

/* trim */
.trim { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 18px; }
.trim-head { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.trim-track { position: relative; height: 28px; }
.trim-rail, .trim-fill { position: absolute; top: 11px; height: 6px; border-radius: 3px; }
.trim-rail { left: 0; right: 0; background: var(--line); }
.trim-fill { background: var(--accent); }
.playhead { position: absolute; top: 3px; width: 2px; height: 22px; background: var(--ink); border-radius: 1px; pointer-events: none; }
.trim-track input[type=range] {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none; height: 28px;
}
.trim-track input[type=range]::-webkit-slider-runnable-track { background: none; }
.trim-track input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 16px; height: 26px; border-radius: 5px;
  background: #fff; border: 2px solid var(--accent); cursor: ew-resize; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.trim-track input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 22px; border-radius: 5px;
  background: #fff; border: 2px solid var(--accent); cursor: ew-resize;
}

/* panel */
.panel { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.field + .field { margin-top: 18px; }
.field-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.field-title { font-weight: 700; font-size: 14px; }
.badge { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; padding: 1px 10px; border-radius: 99px; font-variant-numeric: tabular-nums; }
#quality, #seek, #abr { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: none; margin: 4px 0; cursor: pointer; }
#quality::-webkit-slider-runnable-track, #seek::-webkit-slider-runnable-track, #abr::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--fill, 70%), var(--line) var(--fill, 70%)); }
#quality::-moz-range-track, #seek::-moz-range-track, #abr::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
#quality::-moz-range-progress, #seek::-moz-range-progress, #abr::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
#quality::-webkit-slider-thumb, #seek::-webkit-slider-thumb, #abr::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
#quality::-moz-range-thumb, #seek::-moz-range-thumb, #abr::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.presets { display: flex; gap: 8px; }
.chip {
  flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 6px 4px;
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.3;
}
.chip small { font-weight: 500; font-size: 11px; color: var(--muted); }
.chip:hover { border-color: var(--accent); }
.chip.active { border-color: var(--accent); background: var(--accent-soft); }
.msg { margin: 8px 0 0; font-size: 12px; color: var(--warn); min-height: 0; }
.msg:empty { display: none; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check.small { margin: 0; font-size: 13px; font-weight: 500; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.check.disabled { opacity: .5; cursor: default; }

/* estimate */
.estimate { border-color: var(--accent); }
.est-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.est-label { font-size: 12px; color: var(--muted); }
.est-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.est-val.big { font-size: 28px; color: var(--accent); line-height: 1.2; }
.arrow { color: var(--muted); padding-bottom: 6px; }
.meter { height: 8px; background: var(--line); border-radius: 4px; margin: 12px 0 8px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 4px; width: 0; transition: width .2s; }
.est-cut { font-weight: 700; font-size: 15px; }
.est-detail { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.est-detail li { display: flex; justify-content: space-between; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .tiny { margin: 0; }

/* ads */
.ad-slot {
  border: 1px dashed #c8ced9; border-radius: 10px; color: #a0a7b5; font-size: 12px;
  display: grid; place-items: center; background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 8px, #f3f5f8 8px, #f3f5f8 16px);
}
.ad-wide { height: 100px; }
.ad-side { height: 260px; }
.ad-modal { height: 250px; margin: 16px 0; }

/* info */
.info { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 24px 16px; margin: 24px 0 40px; }
.info h2 { font-size: 18px; margin: 18px 0 6px; }
.info p, .info li { font-size: 14px; color: #3a4252; }

.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 18px 0; text-align: center; font-size: 13px; }
.site-footer a { color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(13,17,23,.55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-box { background: var(--card); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 24px; }
.modal-box h3 { margin: 0 0 12px; font-size: 18px; }
.progress { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.result-big { font-size: 26px; font-weight: 800; margin: 4px 0; }
.result-big .down { color: var(--accent); }
.modal video { width: 100%; border-radius: 10px; background: #000; margin: 8px 0; }
#quality:focus { outline: none; }
#quality:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

/* v2: グループ化した設定 */
.card-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: none; padding-top: 2px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.item-name { font-weight: 700; font-size: 14px; }
.item-save { font-size: 13px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-save.off { color: var(--muted); font-weight: 500; }
.item .check { margin: 0; }
.scale-labels span:nth-child(2) { color: var(--ink); }
.trim-info { font-size: 12px; margin-top: 2px; }
.est-row .right { text-align: right; }
.est-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.est-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.est-status.ok { color: var(--accent); }
.sub-actions { display: flex; justify-content: space-between; }
.link { background: none; border: none; padding: 4px 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:disabled { opacity: .5; cursor: default; }
#seek { --fill: 0%; }
#seek:focus { outline: none; }

/* v3: 再生バー兼トリミング */
.timeline { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 10px; }
.tl-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tl-trim { font-size: 13px; font-variant-numeric: tabular-nums; }
.tl-hint { margin: 6px 0 0; }
#track { height: 36px; cursor: pointer; touch-action: none; }
#track .trim-rail, #track .trim-fill { top: 14px; height: 8px; border-radius: 4px; }
#track input[type=range] { height: 36px; }
#track input[type=range]::-webkit-slider-thumb { height: 34px; width: 14px; }
#track .playhead { top: 4px; height: 28px; width: 3px; background: var(--ink); z-index: 4; }
#track .playhead::before { content: ""; position: absolute; top: -4px; left: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); }
#abr:disabled { opacity: .4; cursor: default; }
.item .check { margin-top: 8px; font-weight: 500; font-size: 13px; }

/* v4: SEO・複数ページ */
.drop-inner { padding: 24px 16px; }
.presets { flex-wrap: nowrap; }
.chip { min-width: 0; font-size: 13px; }
.ad-slot:empty { display: none; }
.ad-slot { background: none; border: none; min-height: 0; height: auto; }
.info h3 { font-size: 15px; margin: 14px 0 2px; }
.info.page h1 { font-size: 22px; margin: 20px 0 4px; }
.info a, .related a { color: var(--accent); }
.related { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 24px 14px; margin: 0 0 40px; }
.related h2 { font-size: 16px; margin: 14px 0 6px; }
.related ul { margin: 0; padding-left: 18px; columns: 2; column-gap: 24px; font-size: 14px; }
.related li { margin: 4px 0; break-inside: avoid; }
@media (max-width: 600px) { .related ul { columns: 1; } .drop-title { font-size: 20px; } }
