:root {
  --bg: #f6f7f9;
  --card: #fff;
  --line: #e3e6ea;
  --text: #1b1d21;
  --muted: #7a808a;
  --accent: #2b7fff;
  --danger: #e5484d;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --card: #1c1f24; --line: #2c3037;
    --text: #e9ebee; --muted: #9aa0aa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 80px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
}

main, .top { max-width: 760px; margin: 0 auto; }

.top { padding: 28px 0 14px; }
.top h1 { margin: 0; font-size: 1.6rem; }
.sub, .meta, .hint { color: var(--muted); font-size: .86rem; }
.sub { margin: 6px 0 0; }
.meta { margin: 2px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

h2 { margin: 0 0 4px; font-size: 1.1rem; }
h3 { margin: 18px 0 8px; font-size: .95rem; }

/* 주소 입력 */
.urlbar { position: relative; }
.urlbar input { width: 100%; padding-right: 38px; }
.inbox {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 28px; height: 28px; padding: 0; border: 0; background: none;
  color: var(--muted); cursor: pointer; font-size: .95rem; line-height: 1;
}
.inbox:hover { color: var(--danger); }

input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
input[type="checkbox"] { width: auto; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
label input, label select { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--text); margin: 0; }
output { color: var(--text); font-weight: 600; }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 14px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.07); }
.ghost { background: transparent; }
.small { padding: 5px 10px; font-size: .83rem; }
.big { width: 100%; margin-top: 14px; padding: 12px; font-size: 1rem; }
.grow { flex: 1; }

.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.edge { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.grid4 label { display: flex; align-items: center; gap: 4px; }
.grid4 input { width: 100%; padding: 6px 8px; }

.opts { margin-top: 12px; }
.opts summary { cursor: pointer; color: var(--muted); font-size: .86rem; }

.msg {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 8px;
  background: rgba(229, 72, 77, .12); color: var(--danger);
  font-size: .88rem; white-space: pre-wrap;
}
.msg.ok { background: rgba(43, 127, 255, .12); color: var(--accent); }

/* 영상 정보 */
.videohead { display: flex; gap: 12px; align-items: flex-start; }
.videohead img { width: 120px; border-radius: 8px; flex: none; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tab {
  border: 0; background: none; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--muted); padding: 10px 12px;
}
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pane { display: none; }
.pane.on { display: block; }

/* 미리보기 + 크롭 */
.stage { margin-bottom: 16px; }
.preview { position: relative; line-height: 0; background: #000; border-radius: 8px; overflow: hidden; }
.preview img { width: 100%; height: auto; display: block; }

.cropbox {
  position: absolute; border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  cursor: move; touch-action: none;
}
.cropbox .h {
  position: absolute; width: 14px; height: 14px; background: var(--accent);
  border: 2px solid #fff; border-radius: 3px; touch-action: none;
}
.cropbox .nw { left: -8px; top: -8px; cursor: nwse-resize; }
.cropbox .ne { right: -8px; top: -8px; cursor: nesw-resize; }
.cropbox .sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.cropbox .se { right: -8px; bottom: -8px; cursor: nwse-resize; }

.stamp { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; }
.stamp strong { font-size: 1.3rem; }
.stamp button { margin-left: auto; }
.croppanel { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }

.range { width: 100%; }
.dual { display: grid; gap: 4px; }

/* 미세조정 칩 */
.nudges { display: flex; gap: 4px; margin-top: 8px; }
.nudges button { flex: 1; padding: 6px 0; font-size: .82rem; min-width: 0; }

/* 시작/끝, 모드 선택 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segbtn { border: 0; border-radius: 0; background: transparent; padding: 7px 14px; color: var(--muted); }
.segbtn + .segbtn { border-left: 1px solid var(--line); }
.segbtn.on { background: var(--accent); color: #fff; font-weight: 600; }

/* 썸네일 격자 - 좁아도 3칸 */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.thumb { position: relative; }
.thumb img { width: 100%; border-radius: 8px; display: block; background: #000; }
.thumb .cap { font-size: .75rem; color: var(--muted); margin: 4px 0 4px; }
.thumb .del {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px;
  padding: 0; border: 0; border-radius: 999px; line-height: 1;
  background: rgba(0, 0, 0, .62); color: #fff; font-weight: 700;
}
.thumb .del:hover { background: var(--danger); }
.thumb a.get {
  display: block; text-align: center; text-decoration: none;
  font-size: .8rem; padding: 5px; border: 1px solid var(--line);
  border-radius: 6px; color: var(--text);
}
.thumb a.get:hover { border-color: var(--accent); color: var(--accent); }

/* 결과 파일 */
.files { margin-top: 12px; display: grid; gap: 10px; }
.file { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.file video, .file img { width: 100%; border-radius: 6px; display: block; margin-bottom: 8px; }
.file .name { font-size: .85rem; word-break: break-all; }

/* 진행률 */
.progress {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
.progress .track { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress #barFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress span { font-size: .82rem; color: var(--muted); white-space: nowrap; }

@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .videohead img { width: 84px; }
}
