:root {
  --bg: #0b0d10;
  --pane: #12151a;
  --bar: #181c22;
  --line: #262c35;
  --text: #e6e9ee;
  --muted: #8a93a1;
  --faint: #3a414c;
  --accent: #4f8cff;
  --audible: #3ddc97;
  --danger: #ff7272;
  --topbar: 36px;
  --gap: 6px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

svg {
  display: block;
}

/* ---------- 상단 바 ---------- */

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  -webkit-app-region: drag;
}

body.mac .topbar {
  padding-left: 84px; /* 신호등 버튼 자리 */
}

.topbar button {
  -webkit-app-region: no-drag;
}

.layouts {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: var(--pane);
}

.layout-pick {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 6px;
  border-radius: 5px;
  color: var(--accent);
}

.layout-pick:hover {
  background: var(--bar);
}

.layouts rect {
  fill: currentColor;
}

.layout-pick .caret svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spacer {
  flex: 1;
}

/* ---------- 칸 ---------- */

#grid {
  position: absolute;
  inset: var(--topbar) 0 0 0;
  display: grid;
  gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: var(--pane);
  box-shadow: 0 0 0 1px var(--line);
}

.pane.active {
  box-shadow: 0 0 0 2px var(--accent);
}

.pane.dragover {
  box-shadow: 0 0 0 2px var(--audible);
}

.pane.drop-target {
  box-shadow: 0 0 0 3px var(--accent);
}

.pane.drag-source {
  opacity: 0.55;
}

.bar {
  cursor: grab;
}

.bar input {
  cursor: text;
}

.num {
  cursor: grab;
}

.bar {
  position: relative;
  flex: none;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  border-radius: 8px 8px 0 0;
  background: var(--bar);
}

.bar button {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
}

.bar button:hover:not(:disabled) {
  background: var(--line);
  color: var(--text);
}

.bar button:disabled {
  color: var(--faint);
  cursor: default;
}

.bar svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.addr {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  margin: 0 4px;
  padding: 0 8px 0 4px;
  border-radius: 6px;
  background: var(--pane);
}

.addr:focus-within {
  box-shadow: 0 0 0 1.5px var(--accent);
}

.num {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  background: var(--line);
}

.pane.active .num {
  background: var(--accent);
  color: #fff;
}

.addr input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  user-select: text;
}

/* 입력 비우기 ×: 주소를 눌러 고치는 중이고 글자가 있을 때만 (.bar button 규칙보다 앞서게) */
.bar .addr .addr-clear {
  flex: none;
  display: none;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-right: -4px;
  border-radius: 50%;
  color: var(--bg);
  background: var(--muted);
}

.bar .addr .addr-clear:hover {
  color: var(--bg);
  background: var(--text);
}

.bar .addr .addr-clear svg {
  width: 9px;
  height: 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
}

.bar .addr:focus-within input:not(:placeholder-shown) + .addr-clear {
  display: grid;
}

.addr input::placeholder {
  color: var(--faint);
}

.bar .sound.live {
  color: var(--audible);
}

.bar .sound.live svg .wave {
  animation: pulse 1.2s ease-in-out infinite;
}

.bar .sound.off {
  color: var(--faint);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}

.progress::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  background: var(--accent);
  animation: slide 1s linear infinite;
}

.pane.loading .progress {
  opacity: 1;
}

@keyframes slide {
  from {
    left: -30%;
  }
  to {
    left: 100%;
  }
}

/* 웹페이지는 이 영역 위에 따로 얹힌다 */
.slot {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0 0 8px 8px;
  container-type: size;
}

.empty,
.error {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

.pane.open .empty,
.error {
  display: none;
}

.pane.failed .error {
  display: grid;
}

.big-num {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: var(--line);
}

.empty p,
.error p {
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chips button,
.error button {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bar);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
}

.chips .file-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

.chips .camera-chip {
  display: flex;
  align-items: center;
  gap: 5px;
}

.file-chip svg,
.camera-chip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.chips button:hover,
.error button:hover {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.empty .hint {
  font-size: 12px;
  color: var(--faint);
}

.error .msg {
  color: var(--danger);
  max-width: 40ch;
  word-break: break-all;
}

/* 칸이 작을 때는 안내 문구를 줄인다 */
@container (max-height: 180px) {
  .empty .hint,
  .big-num {
    display: none;
  }
}

/* ---------- 상단 바 아이콘 ---------- */

.tb {
  flex: none;
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tb:hover {
  color: var(--text);
  background: var(--pane);
}

.tb:disabled {
  background: none;
  color: var(--faint);
  cursor: default;
}

.tb svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 영상만 보기 ---------- */

#wall {
  position: absolute;
  inset: var(--topbar) 0 0 0;
  display: none;
}

body.watch {
  background: #000;
}

body.watch.osfull {
  --topbar: 0px;
}

body.watch #grid {
  display: none;
}

body.watch #wall {
  display: block;
}

body.watch .layouts {
  opacity: 0.55;
}

body.watch .layouts:hover {
  opacity: 1;
}

/* 두 모드의 상단 바는 같다. 영상을 볼 때는 흐리게 두고 마우스를 올리면 또렷하게 */
body.watch .tb,
body.watch .set-name,
body.watch .mode-seg,
body.watch .tb-sep {
  opacity: 0.55;
}

body.watch .tb:hover,
body.watch .mode-seg:hover {
  opacity: 1;
}

.cell {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  color: var(--danger);
  font-size: 12px;
  text-align: center;
  word-break: break-all;
}

/* 칸을 끄는 동안만 빈 칸 자리를 보여 준다 */
#wall.dragging .cell.empty {
  outline: 1px dashed var(--line);
  outline-offset: -1px;
}

#wall .cell.empty.drop {
  background: rgba(79, 140, 255, 0.22);
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.wall-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}

.wall-empty p {
  margin: 0;
}

.wall-empty .chips button {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ---------- 세트 ---------- */

.tb.on {
  color: var(--accent);
}

.tb .label {
  white-space: nowrap;
}

.tb .label:empty {
  display: none;
}

.set-name {
  min-width: 0;
  margin-left: 8px;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-sep {
  flex: none;
  width: 1px;
  height: 14px;
  margin: 0 6px;
  background: var(--line);
}

.mode-seg {
  flex: none;
  display: flex;
  gap: 2px;
  margin-left: 6px;
  padding: 2px;
  border-radius: 7px;
  background: var(--pane);
}

.seg {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 5px;
  color: var(--muted);
}

.seg svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.seg:hover {
  color: #fff;
}

.seg.on {
  background: var(--line);
  color: var(--text);
}

#sets {
  position: absolute;
  inset: var(--topbar) 0 0 0;
  overflow-y: auto;
  padding: 18px 22px 40px;
  background: var(--bg);
  user-select: none;
}

#sets[hidden] {
  display: none;
}

body.modal #wall,
body.modal #grid {
  visibility: hidden;
}

.sets-head {
  position: sticky;
  top: -18px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -18px -22px 16px;
  padding: 14px 22px;
  background: var(--bg);
}

.sets-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.sets-head .count {
  color: var(--muted);
}

/* 세트 이름이 길어도 덮어쓰기 버튼이 위쪽 버튼들을 밀어내지 않게 */
.save-update .clip {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--bar);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  white-space: nowrap;
}

.btn:hover {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.btn.primary {
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn svg,
.icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
}

.icon:hover {
  background: var(--bar);
  color: var(--text);
}

.icon.more svg {
  stroke-width: 3.2;
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.set-card {
  border-radius: 12px;
  overflow: hidden;
  background: var(--pane);
  box-shadow: 0 0 0 1px var(--line);
}

.set-card.current {
  box-shadow: 0 0 0 2px var(--accent);
}

.set-card.focus {
  animation: flash 1.2s ease-out 1;
}

@keyframes flash {
  from {
    box-shadow: 0 0 0 4px var(--accent);
  }
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #000;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thumb .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.set-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* 긴 이름이 카드를 밀어내지 않게 — 넘치면 … 로 줄이고 ··· · 휴지통은 제자리에 */
  gap: 6px;
  padding: 10px 12px 12px;
}

.set-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

.set-title .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 650;
  cursor: text;
}

.set-title .rename {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  outline: none;
  background: var(--bg);
  box-shadow: 0 0 0 1.5px var(--accent);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  user-select: text;
}

.set-meta {
  color: var(--muted);
  font-size: 12px;
}

.set-warn {
  color: var(--danger);
  font-size: 12px;
}

/* 열기(영상만 보기 · 분할 화면)와 삭제: 이름 없이 아이콘만, 삭제는 오른쪽 끝에 */
.set-actions {
  display: flex;
  gap: 2px;
  margin: 2px -6px 0;
}

.set-actions .icon {
  width: 34px;
}

.set-actions .icon svg {
  width: 18px;
  height: 18px;
}

.set-actions .delete {
  margin-left: auto;
}

.set-actions .delete:hover {
  color: var(--danger);
}

.sets-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 18vh;
  color: var(--muted);
  text-align: center;
}

.sets-empty p {
  margin: 0;
}

.sets-empty .hint {
  color: var(--faint);
  line-height: 1.6;
}

.wall-empty .to-sets svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.app-toast.on {
  opacity: 1;
}

.app-toast.in-pane {
  bottom: auto;
  transform: translate(-50%, -50%);
}

/* ---------- 녹화 ---------- */

.tb.rec svg circle {
  stroke: #ff5a5a;
}

.tb.rec.on {
  color: #ff6b6b;
  opacity: 1 !important;
}

.tb.rec.on svg circle {
  fill: #ff4d4d;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

/* 녹화 중엔 영상만 보기에서도 경과 시간을 보인다 */
.tb.rec.on .label {
  font-variant-numeric: tabular-nums;
}

@keyframes rec-pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------- 요금제 · Pro 안내 ---------- */

.tb.plan {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.tb.plan.pro {
  color: var(--text);
}

#license {
  position: absolute;
  inset: var(--topbar) 0 0 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(11, 13, 16, 0.92);
}

#license[hidden] {
  display: none;
}

.lic-card {
  position: relative;
  width: min(560px, 100%);
  padding: 26px 26px 22px;
  border-radius: 16px;
  background: var(--pane);
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lic-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.lic-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.lic-reason {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.15);
  color: #cfe0ff;
}

.lic-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 18px;
}

.lic-plan {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bar);
  box-shadow: inset 0 0 0 1px var(--line);
}

.lic-plan.now {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.lic-plan.pro h3 {
  color: #ffd166;
}

.lic-plan h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.lic-plan ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.lic-plan li.minus {
  color: var(--faint);
}

.lic-plan b {
  color: var(--text);
}

.lic-form {
  display: flex;
  gap: 8px;
}

.lic-key {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font: 12px ui-monospace, Menlo, monospace;
  user-select: text;
}

.lic-key:focus {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.lic-buy,
.lic-who {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.lic-msg {
  margin: 12px 0 0;
  color: #ffd166;
}

/* ---------- 웹판: 칸(iframe) ---------- */

html,
body {
  overscroll-behavior: none; /* 옆으로 쓸어도 브라우저 뒤로 가기가 되지 않게 */
}

body.mac .topbar {
  padding-left: 12px; /* 앱의 신호등 버튼 자리가 필요 없다 */
}

#mv-views {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.mv-view {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border: 0;
  background: #000;
  pointer-events: auto;
}

/* 공용 버튼·끌기 미리보기는 칸 위에 투명하게 얹는다 */
.mv-view[data-page] {
  background: transparent;
  color-scheme: normal;
}

.mv-view[data-page='ghost.html'] {
  pointer-events: none;
}

.app-toast {
  z-index: 30;
}

.wall-empty .hint {
  font-size: 12px;
  color: var(--faint);
}

/* ---------- 웹판: 메뉴 ---------- */

.mv-menu-back {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.mv-menu {
  position: fixed;
  min-width: 170px;
  padding: 4px;
  border-radius: 8px;
  background: var(--bar);
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, 0.5);
}

.mv-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 5px 10px;
  border-radius: 5px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.mv-menu button:hover:not(:disabled) {
  background: var(--line);
  color: #fff;
}

.mv-menu button:disabled {
  color: var(--faint);
  cursor: default;
}

.mv-menu button.checked {
  color: var(--text);
  font-weight: 600;
}

.mv-menu img {
  width: 22px;
  height: 16px;
  filter: invert(1);
  opacity: 0.8;
}

.mv-menu hr {
  margin: 4px 6px;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---------- 웹판: 확인 창 ---------- */

.mv-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  border: 0;
  border-radius: 12px;
  background: var(--pane);
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, 0.5);
  color: var(--muted);
}

.mv-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.mv-dialog p {
  margin: 0 0 8px;
}

.mv-dialog .title {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.mv-dialog .row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- 웹판: Chrome 권장 안내 ---------- */

.mv-notice {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 30;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 7px 8px 7px 14px;
  border-radius: 8px;
  background: rgba(24, 28, 34, 0.94);
  box-shadow: 0 0 0 1px var(--line);
  color: var(--muted);
  font-size: 12px;
}

.mv-notice a {
  flex: none;
  color: var(--text);
}

.mv-notice button {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  font-size: 15px;
  line-height: 1;
  opacity: 0.6;
}

.mv-notice button:hover {
  color: #fff;
  opacity: 1;
}
