:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #f7f7f8;
  --surface-strong: #f0efff;
  --ink: #171922;
  --muted: #6f7480;
  --line: #dedfe5;
  --line-strong: #c8cad2;
  --accent: #7c3aed;
  --accent-dark: #6728d9;
  --danger: #b42318;
  --left-width: minmax(420px, 38vw);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button, select { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: var(--left-width) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.queue-panel {
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.queue-header { padding: 24px 26px 18px; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.back-link { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--accent); }
h1 { margin: 0; font-size: 30px; line-height: 1.12; letter-spacing: -.045em; }
.queue-header p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.queue-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 26px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  overflow: hidden;
}

.queue-tabs button {
  min-width: 0;
  padding: 12px 8px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: var(--paper);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.queue-tabs button:last-child { border-right: 0; }
.queue-tabs button:hover { background: var(--surface); }
.queue-tabs button.active { background: var(--accent); color: white; }

.collection-filter { padding: 17px 26px 0; }
.collection-filter label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 700; }
.select-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
select, .quiet-button {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}
select { min-width: 0; padding: 0 34px 0 11px; }
.quiet-button { padding: 0 11px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 650; }
.quiet-button:hover, .quiet-button[aria-pressed="true"] { border-color: #c4b5fd; color: var(--accent); background: #faf9ff; }

.progress-block { padding: 18px 26px 14px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.progress-copy span { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: #ececf0; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 180ms ease; }

.queue-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.queue-meta span { color: var(--muted); font-variant-numeric: tabular-nums; }

.queue-list { min-height: 0; overflow: auto; scroll-behavior: smooth; }
.queue-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 58px;
  width: 100%;
  padding: 8px 18px 8px 10px;
  border: 0;
  border-bottom: 1px solid #ececf0;
  background: var(--paper);
  cursor: pointer;
  text-align: left;
}
.queue-row:hover { background: var(--surface); }
.queue-row.current { box-shadow: inset 4px 0 0 var(--accent); background: var(--surface-strong); }
.queue-row.done { color: #8b8f99; }
.row-number { text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-main { min-width: 0; }
.row-name { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 650; white-space: nowrap; }
.row-path { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.row-state { display: flex; align-items: center; gap: 6px; margin-left: 10px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.done-mark { display: inline-grid; width: 17px; height: 17px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 10px; }
.queue-row.done .done-mark { border-color: var(--accent); background: var(--accent); color: white; }
.queue-empty { padding: 36px 26px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.queue-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.text-button { padding: 2px; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 11px; }

.preview-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; height: 100%; overflow: hidden; background: #fafafa; }
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.preview-header > div { display: flex; align-items: baseline; gap: 10px; }
.preview-header strong { font-size: 15px; }
.preview-header span { color: var(--muted); font-size: 12px; }
.key-help { margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
kbd { font-family: inherit; font-size: .88em; }

.embed-wrap { position: relative; min-height: 0; overflow: hidden; padding: 22px 28px 14px; }
.embed-stack { position: relative; width: min(100%, 650px); height: 100%; margin: 0 auto; }
.embed-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.embed-frame.active { opacity: 1; pointer-events: auto; visibility: visible; }
.embed-message { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 7px; color: var(--muted); text-align: center; }
.embed-message strong { color: var(--ink); font-size: 15px; }
.embed-message span { font-size: 12px; }
.embed-message[hidden] { display: none; }

.requirements {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 46px;
  padding: 7px 28px 11px;
}
.requirement {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.requirement::before { content: ""; width: 8px; height: 8px; border: 1px solid var(--line-strong); border-radius: 50%; }
.requirement.done { border-color: #c4b5fd; background: #f5f3ff; color: var(--accent); }
.requirement.done::before { border-color: var(--accent); background: var(--accent); }

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.prefetch-status { display: flex; align-items: center; gap: 8px; min-width: 150px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #ede9fe; }
.actions { display: flex; justify-content: flex-end; gap: 9px; }
.primary-button, .secondary-button, .danger-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: white; }
.primary-button:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.secondary-button { border: 1px solid var(--line-strong); background: var(--paper); }
.secondary-button:hover { border-color: #b8a1f8; color: var(--accent); }
.danger-button { border: 1px solid var(--danger); background: var(--danger); color: white; }
.actions kbd { margin-left: 9px; opacity: .72; }

dialog { width: min(430px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 0; box-shadow: 0 24px 80px rgba(23,25,34,.2); }
dialog::backdrop { background: rgba(23,25,34,.34); }
dialog form { padding: 24px; }
dialog h2 { margin: 0 0 10px; font-size: 19px; letter-spacing: -.025em; }
dialog p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .queue-panel { min-height: 100dvh; border-right: 0; }
  .queue-panel, .preview-panel { height: 100dvh; overflow: hidden; }
  .preview-panel { min-height: 100dvh; border-top: 1px solid var(--line); }
  .embed-wrap { height: 72vh; }
  .key-help { display: none; }
}

@media (max-width: 560px) {
  .queue-header { padding: 20px 16px 16px; }
  .queue-tabs { margin: 0 16px; }
  .queue-tabs button { padding: 11px 4px; font-size: 11px; }
  .collection-filter, .progress-block { padding-left: 16px; padding-right: 16px; }
  .queue-meta { padding: 0 16px; }
  .preview-header, .action-bar { padding-left: 14px; padding-right: 14px; }
  .embed-wrap { padding: 14px 10px 8px; }
  .action-bar { align-items: stretch; flex-direction: column; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions .primary-button { grid-column: 1 / -1; grid-row: 1; }
  .quiet-button#reset-current { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
