@font-face {
  font-family: "Pretendard";
  src: url("ui-assets/pretendard.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  --night: #0d0f1c;
  --paper: #f4f1e8;
  --gold: #ffd84a;
  --sheet: #ffffff12;
  --line: #ffffff24;
  --outline: #ffffff45;
  --hover: #ffffff1a;
  --ink: var(--paper);
  --muted: #b4b8cc;
  --accent: var(--gold);
  --accent-pale: #ffd84a1f;
  --danger: #ff9f8c;
  --stage: #0b0d18;
  --scope: var(--gold);
  --radius: 99px;
  --rail: 270px;
  --gutter: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; background: radial-gradient(ellipse at 70% 40%, #232850, var(--night) 65%) fixed var(--night); }
body { margin: 0; min-height: 100vh; color: var(--ink); word-break: keep-all; }
h1, h2, p, figure { margin: 0; }
h1 { font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 15px; font-weight: 700; letter-spacing: -.015em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
select option { background: var(--night); color: var(--paper); }
:where(a, button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--night); }

/* 별: 위치·크기·반짝임 시점은 sky.js가 무작위로 정한다. 사진 뒤에 깔린다 */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.sky i { position: absolute; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px #fff, 0 0 14px 4px #9fb4ff88; animation: twinkle 3s ease-in-out infinite alternate; }
.sky i:nth-child(7n) { box-shadow: 0 0 8px 2px #fff, 0 0 22px 8px #ffdc6e88; }
@keyframes twinkle { from { opacity: .25; transform: scale(.7); } to { opacity: 1; transform: scale(1.15); } }

.shell { width: min(1552px, calc(100% - 2 * var(--gutter))); margin-inline: auto; }
.masthead-inner { min-height: 72px; display: flex; align-items: center; gap: 24px; }
.wordmark { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.tagline { padding-left: 18px; border-left: 1px solid var(--outline); color: var(--muted); white-space: nowrap; }
.tagline em { color: var(--gold); font-style: normal; font-weight: 700; }
@media (max-width: 760px) { .tagline { display: none; } }
.brand-icon { flex: none; width: 29px; height: 29px; color: var(--accent); }
.media-nav { order: 1; display: flex; gap: 24px; }
.media-nav a {
  display: inline-flex; align-items: center; gap: 7px; padding-block: 8px;
  border-block-end: 2px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.media-nav a:hover { color: var(--ink); }
.media-nav a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
.media-nav svg, .button svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.masthead-status { display: flex; margin-left: auto; }
.model-status { display: grid; gap: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.model-status progress {
  display: block; appearance: none; width: 100%; height: 3px; border: 0; border-radius: 2px;
  accent-color: var(--accent); background: var(--line);
}
.model-status progress::-webkit-progress-bar { background: transparent; }
.model-status progress::-webkit-progress-value { border-radius: 2px; background: var(--accent); }
.model-status progress::-moz-progress-bar { border-radius: 2px; background: var(--accent); }
.model-status progress:indeterminate {
  background: linear-gradient(var(--accent), var(--accent)) left center / 32% 100% no-repeat var(--line);
  animation: model-loading 1.4s ease-in-out infinite alternate;
}
.model-status progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes model-loading { to { background-position: right center; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.app-shell { padding-block: 6px 20px; }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: 18px; }
.preview { grid-area: 1 / 1; }
.queue { grid-area: 1 / 2; border: 1px solid var(--line); border-radius: 18px; background: var(--sheet); backdrop-filter: blur(8px); }
.queue, .preview { min-width: 0; display: flex; flex-direction: column; }
.queue { padding: 0 12px 12px; }
.queue-head, .preview-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.queue-head { padding: 0 4px; border-bottom: 1px solid var(--line); }
.queue-head h2 { display: flex; gap: 9px; align-items: center; }
.queue-count { min-width: 1.4ch; text-align: right; color: var(--muted); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.queue-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; }
.rows { flex: 1; min-height: 0; contain: size; overflow-y: auto; margin: 0; padding: 8px 3px; list-style: none; scrollbar-color: var(--outline) transparent; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 54px; align-items: center; border-radius: 10px; }
.row + .row { margin-top: 2px; }
.row.active { background: var(--hover); }
.row-select, .row-content {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px;
  min-width: 0; min-height: 48px; padding: 8px; color: var(--ink);
}
.row-select { border: 0; border-radius: 10px; background: transparent; text-align: left; }
.row-select:hover { background: var(--hover); }
.row-select:focus-visible { outline-offset: -2px; }
.row-number { min-width: 2ch; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.row-details { min-width: 0; }
.filename, .row-state { display: block; }
.filename { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.row-state, .row-duration { color: var(--muted); font-size: 12px; }
.row-duration { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.row[data-state="done"] .row-state { color: var(--accent); }
.row[data-state="review"] .row-state, .row[data-state="failed"] .row-state { color: var(--danger); }
.remove { width: 27px; height: 30px; margin-right: 4px; padding: 0; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 19px; }
.remove:hover:enabled { color: var(--danger); background: var(--hover); }
.actions { display: grid; gap: 8px; margin-top: auto; padding: 12px 4px 2px; border-top: 1px solid var(--line); }
.work-time, .summary { font-size: 12px; font-variant-numeric: tabular-nums; }
.work-time { color: var(--ink); font-weight: 600; }
.queue-summary { display: flex; justify-content: space-between; align-items: center; gap: 5px; min-height: 32px; }
.summary { color: var(--muted); line-height: 1.45; word-break: keep-all; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  padding: 7px 12px; border: 1px solid transparent; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; line-height: 1.35; text-align: center; word-break: keep-all;
}
.button.outline { color: var(--ink); background: transparent; border-color: var(--outline); }
.button.outline:hover:enabled { background: var(--hover); }
.queue-head .button { min-height: 33px; padding: 5px 9px; }
.add-button svg { width: 14px; height: 14px; }
.primary, .accent { background: var(--gold); color: var(--night); }
.primary:hover:enabled, .accent:hover:enabled { background: #ffe585; }
.button:disabled, .button.outline:disabled { background: #ffffff0f; color: #8c90a8; border-color: transparent; }
.actions .clear { min-height: 30px; padding: 4px 6px; flex: none; color: var(--muted); background: transparent; font-size: 12px; }
.actions .clear:hover:enabled { color: var(--danger); background: var(--hover); }
.actions .clear:disabled { color: var(--muted); opacity: .64; }
.actions .stop { border-color: var(--danger); color: var(--danger); }
.actions .stop:hover:enabled { background: var(--hover); }

.preview { min-height: min(720px, calc(100svh - 100px)); padding: 0 14px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--sheet); }
.preview-head { flex-wrap: wrap; align-content: center; padding: 12px 9px; }
.preview-details { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 14px; }
.preview-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage { flex: 1; display: grid; place-items: center; min-width: 0; padding: 20px; overflow: hidden; border-radius: 12px; background: #00000040; }

/* 파일이 없으면 목록과 제목 줄을 숨기고 첫 화면만 보여 준다 */
.workbench:has(.drop:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
.workbench:has(.drop:not([hidden])) :is(.queue, .preview-head) { display: none; }
.workbench:has(.drop:not([hidden])) .preview { min-height: calc(100svh - 100px); padding: 0; border: 0; background: none; }
.stage:has(.drop:not([hidden])) { padding: 0; overflow: visible; background: none; }
.workbench:has(.drop:not([hidden])) .notice { text-align: center; }

.drop {
  display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-content: center; align-items: center;
  justify-self: center; width: min(100%, 1320px); gap: 28px 56px; padding: 8px 18px;
}
.hero-title { font-size: clamp(48px, 6.2vw, 96px); line-height: 1.06; letter-spacing: -.06em; font-weight: 900; }
.hero-title span { display: block; color: transparent; -webkit-text-stroke: 1.5px var(--paper); transition: color .8s; }
.drop.done .hero-title span { color: var(--gold); -webkit-text-stroke-color: var(--gold); }
.drop-hint { margin-block: 24px 30px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.upload { display: inline-flex; align-items: center; gap: 14px; padding: 8px 30px 8px 8px; border: 0; border-radius: 99px; background: var(--gold); color: var(--night); font-size: 19px; font-weight: 800; }
.upload i { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--night); color: var(--gold); font-style: normal; font-size: 24px; transition: transform .4s; }
.upload:hover i { transform: rotate(180deg); }
.drop-formats { margin-top: 14px; color: var(--muted); font-size: 13px; }
.demo { width: min(100%, max(420px, calc((100svh - 300px) * 1.5))); justify-self: center; transform: rotate(1.5deg); padding: 14px 14px 0; border-radius: 6px; background: var(--paper); color: var(--night); box-shadow: 0 30px 80px #000a; }
.demo-stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; }
/* 기울인 액자에서 사진 경계가 계단 모양이 되지 않게 액자색 테두리를 별도 층으로 덮는다 */
.demo-stage::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--paper); will-change: transform; pointer-events: none; }
.demo-stage img { clip-path: inset(1px); }
.demo-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop.done .demo-before { opacity: 0; transition: opacity .8s; }
.demo-ring { position: absolute; left: 90.6%; top: 83.3%; width: 7.5%; aspect-ratio: 1; translate: -50% -50%; border: 2px solid var(--gold); border-radius: 50%; pointer-events: none; animation: pulse 1.6s ease-out infinite; }
.drop.done .demo-ring { display: none; }
/* 동영상 예시: 두 배 높이의 영상에서 위쪽(원본)과 아래쪽(보정 결과)을 골라 보여 준다 */
.demo-stage video { position: absolute; top: 0; left: 0; width: 100%; height: 200%; clip-path: inset(1px 1px calc(50% + 1px)); }
.drop.done .demo-stage video { top: -100%; clip-path: inset(calc(50% + 1px) 1px 1px); }
.demo-buttons { display: flex; gap: 8px; margin-left: auto; }
.demo-auto:disabled { opacity: .35; }
@keyframes pulse { from { scale: .7; opacity: 1; } to { scale: 1.4; opacity: 0; } }
.demo figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px; font-weight: 700; }
.demo-auto { padding: 5px 14px; border: 1.5px solid var(--night); border-radius: 99px; background: none; color: var(--night); font-size: 13px; }
.demo-strip { grid-column: 1 / -1; display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.demo-strip button { padding: 4px; border: 2px solid transparent; border-radius: 12px; background: none; line-height: 0; opacity: .55; transition: .2s; }
.demo-strip button:hover, .demo-strip button[aria-pressed="true"] { opacity: 1; translate: 0 -6px; }
.demo-strip button[aria-pressed="true"] { border-color: var(--gold); }
.demo-strip img { width: 108px; height: 72px; border-radius: 7px; }

body.dragging::after { content: "✦ 여기에 놓으세요"; position: fixed; inset: 14px; z-index: 5; display: grid; place-items: center; border: 3px dashed var(--gold); border-radius: 24px; background: #0d0f1ce6; font-size: 34px; font-weight: 800; pointer-events: none; }

.stage-message { color: var(--ink); font-size: 13px; }

.picture, .video-frame { position: relative; width: fit-content; max-width: 100%; line-height: 0; }
.picture { user-select: none; }
.picture, .video-frame, .video-result { box-shadow: 0 0 0 8px var(--paper), 0 24px 70px #000a; }
.picture.adjusting, .video-frame { cursor: crosshair; touch-action: none; }
.picture img, .video-frame canvas, .video-result { display: block; width: auto; height: auto; max-width: 100%; max-height: min(52vh, 620px); }
.picture img, .video-frame canvas { pointer-events: none; }
#result { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 0 0 var(--split, 50%)); }
.divider { position: absolute; inset: 0 auto 0 var(--split, 50%); z-index: 1; width: 34px; transform: translateX(-50%); cursor: ew-resize; touch-action: none; }
.divider::before { content: ""; position: absolute; inset: 0 auto 0 calc(50% - 1px); width: 2px; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.divider-handle {
  position: absolute; top: 50%; left: 50%; display: grid; grid-template-columns: repeat(2, 1fr);
  place-items: center; width: 33px; height: 33px; padding: 0 5px; transform: translate(-50%, -50%);
  border: 1px solid white; border-radius: 50%; background: var(--stage); color: white; pointer-events: none;
}
.divider-handle::before, .divider-handle::after { content: ""; width: 5px; height: 5px; border: solid currentColor; transform: rotate(45deg); }
.divider-handle::before { border-width: 0 0 1.5px 1.5px; }
.divider-handle::after { border-width: 1.5px 1.5px 0 0; }
.divider:focus-visible { outline: none; }
.divider:focus-visible .divider-handle { outline: 2px solid var(--scope); outline-offset: 3px; }
.view-label {
  position: absolute; top: 9px; padding: 6px 7px; border-radius: 4px;
  background: var(--stage); color: white; font-size: 11px; line-height: 1; pointer-events: none;
}
.before { left: 9px; }
.after { right: 9px; }
.region-targets { position: absolute; inset: 0; pointer-events: none; }
.target {
  position: absolute; padding: 0; transform: translate(-50%, -50%); border: 2px dashed white;
  border-radius: 50%; background: transparent; color: white; box-shadow: 0 0 0 1px var(--stage);
  cursor: grab; touch-action: none; pointer-events: auto;
}
.target[aria-pressed="true"] { z-index: 1; border-color: var(--scope); color: var(--scope); }
.target:focus-visible { outline-color: var(--scope); }
.target span {
  position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%); min-width: 16px;
  padding: 2px 3px; border-radius: 3px; background: var(--stage); color: inherit;
  font-size: 11px; line-height: 1; pointer-events: none;
}

.controls { margin-top: 12px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.control-group, .area-controls, .size-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 13px; }
/* 편집과 결과 화면의 높이를 같게 한다 */
#edit-controls, #result-controls { min-height: 66px; align-content: flex-end; }
.edit-row { column-gap: 40px; }
#size-controls { margin-left: 28px; }
.edit-row input { width: 180px; }
.control-group input { min-width: 78px; width: min(36%, 190px); accent-color: var(--accent); }
.size-controls { min-width: 0; }
.size-controls input { width: clamp(85px, 14vw, 180px); }
.control-group output { color: var(--muted); font-variant-numeric: tabular-nums; }
/* 작업 알림 자리는 비어 있어도 남겨 둔다 (두 줄까지) */
.action-row { display: flex; align-items: center; gap: 12px; min-height: 46px; margin-top: 8px; padding-inline: 8px; }
.action-row .accent { flex: none; margin-left: auto; }
.workbench:has(.drop:not([hidden])) .action-row { min-height: 0; }
.position-note { flex-basis: 100%; color: var(--muted); font-size: 13px; }
.dark-outline { background: transparent; border-color: var(--outline); color: var(--ink); }
.dark-outline:hover:enabled { background: var(--hover); }
.controls select { min-height: 33px; padding: 4px 8px; border: 1px solid var(--outline); border-radius: 6px; background: var(--sheet); color: var(--ink); }
.controls button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-pale); }
.video-tools { display: grid; gap: 10px; position: relative; }
/* 편집 도구가 안 보이는 상태(visibility: hidden)에서도 이 줄은 보인다 */
#video-result-controls { position: absolute; top: 10px; left: 8px; visibility: visible; }
.video-tools .frame-controls input { flex: 1 1 130px; min-width: 95px; }
.frame-controls output { white-space: nowrap; }
.video-tabs { display: flex; gap: 4px; }
.video-tabs .button { min-height: 31px; padding: 4px 9px; font-size: 12px; }
.video-tabs button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-pale); }
.notice { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

@media (max-width: 1020px) {
  :root { --rail: 224px; }
  .drop { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .demo { width: min(100%, 640px); }
}

@media (max-width: 640px) {
  :root { --gutter: 12px; }
  html { scrollbar-gutter: auto; }
  .masthead-inner { min-height: 0; flex-wrap: wrap; gap: 6px 16px; padding-top: 9px; }
  .wordmark { font-size: 18px; }
  .brand-icon { width: 26px; height: 26px; }
  .model-status { font-size: 11px; }
  .media-nav { gap: 18px; }
  .media-nav a { font-size: 13px; }
  .app-shell { padding-block: 6px 12px; }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .queue { grid-area: 2 / 1; }
  .preview { min-height: 0; padding: 0 9px 9px; }
  .preview-head { min-height: 54px; gap: 6px 12px; padding: 8px 5px; }
  h1 { font-size: 18px; }
  .stage { padding: 10px; }
  .drop { gap: 22px; padding: 12px 4px; }
  .demo-strip { gap: 8px; }
  .demo-strip img { width: 66px; height: 44px; }
  .queue { padding: 0 9px 9px; }
  .queue-head { min-height: 46px; }
  .queue-empty { padding: 11px 4px; }
  .rows { flex: 0 1 auto; contain: none; max-height: 224px; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-summary, .work-time { grid-column: 1 / -1; }
  .controls { margin-top: 9px; padding: 8px 2px 0; }
  .action-row { padding-inline: 2px; }
  #size-controls { margin-left: 0; }
}
/* 브라우저판의 라이선스 고지 링크 */
.legal { position: fixed; right: 12px; bottom: 6px; font-size: 11px; color: inherit; opacity: .55; }
.legal:hover, .legal:focus-visible { opacity: 1; }
