:root {
  --bg: #f3efe4;
  --panel: rgba(255, 252, 245, 0.94);
  --ink: #1f2937;
  --muted: #667085;
  --line: #d8d0c1;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --danger: #b42318;
  --danger-soft: #fecdca;
  --timeline: #283243;
  --existing: #facc15;
  --existing-soft: rgba(250, 204, 21, 0.18);
  --selection: #ff2d55;
  --selection-soft: rgba(255, 45, 85, 0.2);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 24%),
    linear-gradient(135deg, #f8f4ea 0%, #ece4d5 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  gap: 20px;
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(14px);
}

.toolbar,
.workspace {
  display: grid;
  gap: 20px;
}

.toolbar {
  align-content: start;
}

.panel,
.viewer,
.timeline {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
}

.tool-list,
.mode-list {
  display: grid;
  gap: 12px;
}

.tool-button,
.mode-card,
button {
  font: inherit;
}

.tool-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.tool-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff, #eefcf9);
}

.tool-key {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f5f5f5;
  font-weight: 700;
}

.mode-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  cursor: pointer;
  background: #fff;
}

.mode-card input {
  margin: 0 0 6px;
}

.mode-card small {
  color: var(--muted);
}

.mode-card.danger:has(input:checked) {
  border-color: var(--danger);
  background: linear-gradient(180deg, #fff8f7, #ffe7e3);
}

.mode-card:not(.danger):has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff, #eefcf9);
}

.object-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.object-name {
  font-weight: 700;
}

.object-range {
  color: var(--muted);
}

.viewer-topbar,
.timeline-header,
.confirm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.frame-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.video-stage {
  margin-top: 18px;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.06)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1440' height='810' viewBox='0 0 1440 810'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' x2='1' y1='0' y2='1'%3E%3Cstop stop-color='%23182733'/%3E%3Cstop offset='1' stop-color='%2330556c'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect fill='url(%23g)' width='1440' height='810'/%3E%3Ccircle cx='1190' cy='160' r='120' fill='%23f59e0b' fill-opacity='.28'/%3E%3Ccircle cx='270' cy='600' r='180' fill='%2322c55e' fill-opacity='.18'/%3E%3Cpath d='M0 610 C 230 560, 320 690, 580 640 S 960 520, 1440 620 L1440 810 L0 810 Z' fill='%23ffffff' fill-opacity='.08'/%3E%3C/svg%3E") center/cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.mock-box {
  position: absolute;
  top: 28%;
  left: 38%;
  width: 18%;
  height: 29%;
  border: 3px solid #93c5fd;
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.12);
}

.mock-box span {
  position: absolute;
  top: -34px;
  left: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(147, 197, 253, 0.92);
  color: #0f172a;
  font-weight: 700;
}

.mode-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.timeline {
  display: grid;
  gap: 18px;
}

.legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-box.existing {
  background: var(--existing);
}

.legend-box.selected {
  background: var(--selection);
}

.confirm-body {
  color: var(--muted);
}

.selection-summary {
  color: #f8fafc;
  font-size: 18px;
  white-space: nowrap;
}

.frame-area {
  position: relative;
  display: grid;
  gap: 0;
  border-radius: 22px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--timeline);
  border: 1px solid #364152;
}

.selection-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(18, 26, 39, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(12px);
}

.track-lane {
  position: relative;
  min-height: 98px;
  min-width: 960px;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  background-size: calc(100% / 40) 100%, 100% 100%;
}

.track-lane::after {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.segment-layer,
.selected-layer {
  position: absolute;
  inset: 0;
}

.selected-layer {
  pointer-events: none;
}

.track-segment,
.selection-segment {
  position: absolute;
  top: 38px;
  height: 20px;
}

.track-line,
.selection-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 999px;
}

.track-line {
  background: var(--existing);
}

.selection-line {
  background: var(--selection);
  height: 4px;
  box-shadow: 0 0 0 6px var(--selection-soft);
}

.track-dot,
.selection-dot {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.track-dot {
  border: 4px solid var(--existing);
  background: var(--timeline);
}

.selection-dot {
  border: 4px solid var(--selection);
  background: var(--timeline);
  box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.16);
}

.track-point,
.selection-point {
  position: absolute;
  top: 38px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.track-point {
  border: 4px solid var(--existing);
  background: var(--timeline);
}

.selection-point {
  border: 4px solid var(--selection);
  background: var(--timeline);
  box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.16);
}

.frame-strip {
  display: grid;
  grid-template-columns: repeat(40, minmax(0, 1fr));
  gap: 0;
  min-width: 960px;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    rgba(14, 23, 38, 0.24);
  background-size: calc(100% / 40) 100%, 100% 100%;
}

.frame-cell {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 8px 4px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.84);
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.frame-cell:hover {
  background: rgba(255, 255, 255, 0.06);
}

.frame-cell.current {
  box-shadow: inset 0 -3px 0 0 #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.frame-cell.selected-range {
  background: var(--selection-soft);
}

.frame-cell.pending-point {
  background: var(--selection-soft);
  box-shadow: inset 0 0 0 2px rgba(255, 45, 85, 0.32);
}

.frame-cell.deleted {
  color: rgba(255, 255, 255, 0.3);
}

.frame-number {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
}

button.secondary {
  background: #eef2f6;
  color: var(--ink);
}

button.danger {
  background: var(--danger);
  color: white;
}

.confirm-actions,
.selection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(10px);
}

.confirm-modal {
  width: min(100%, 440px);
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 252, 245, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.24);
}

.confirm-modal h3 {
  margin: 0;
  font-size: 24px;
}

.confirm-modal .confirm-body {
  margin: 12px 0 0;
}

.confirm-modal .confirm-actions {
  margin-top: 20px;
  justify-content: flex-end;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .viewer-topbar,
  .timeline-header,
  .selection-overlay {
    flex-direction: column;
    align-items: stretch;
  }

  .track-lane {
    min-height: 88px;
  }

  .selection-overlay {
    left: 16px;
    right: 16px;
  }
}
