:root {
  --bg: #fff7f4;
  --card: #ffffff;
  --text: #2b2230;
  --muted: #6f6475;
  --accent: #ff4f8b;
  --accent-text: #ffffff;
  --line: #f1dfe6;
  --phone: #1d1a20;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1720;
    --card: #28212d;
    --text: #f5eef7;
    --muted: #b9adbf;
    --accent: #ff6b9c;
    --accent-text: #1c1720;
    --line: #3a3040;
    --phone: #0c0a0e;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", sans-serif;
  line-height: 1.6;
  word-break: keep-all;
}

/* Top bar with channel brand */
.topbar {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: "Jua", sans-serif;
  font-size: 22px;
}

.brand .logo { width: 44px; height: 44px; flex: none; }
.yt-icon { width: 28px; height: 20px; flex: none; }

/* Hero */
.hero {
  text-align: center;
  padding: 16px 16px 28px;
}

h1, h2 {
  font-family: "Jua", sans-serif;
  font-weight: 400;
  line-height: 1.35;
}

h1 { font-size: clamp(26px, 6vw, 40px); margin: 0 0 14px; }
h2 { font-size: 22px; margin: 0 0 8px; }

.lead { margin: 0 0 4px; font-size: clamp(16px, 4vw, 19px); font-weight: 700; color: var(--accent); }
.sub { margin: 0; color: var(--muted); }

.free {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 10px;
  border-radius: 999px;
  background: #ffe14d;
  color: #2b2230;
  font-weight: 700;
  font-size: 14px;
  vertical-align: middle;
}

.free-note { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.free-note strong { color: var(--accent); }

/* Layout */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
}

.maker {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "controls" "stage" "notes";
}

.maker .controls { grid-area: controls; }
.maker .stage { grid-area: stage; }
.maker .notes { grid-area: notes; }

@media (min-width: 720px) {
  .maker {
    gap: 18px 24px;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: auto 1fr;
    grid-template-areas: "controls stage" "notes stage";
    align-items: start;
  }
}


/* Inputs */
.controls { display: grid; gap: 18px; align-content: start; }

.field { display: grid; gap: 8px; font-weight: 700; }

.field input[type="text"] {
  font: inherit;
  font-size: 20px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  max-width: 280px;
}

#dim { max-width: 280px; accent-color: var(--accent); }

.backgrounds {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: 8px;
}

.bg-option {
  position: relative;
  display: grid;
  padding: 0;
  aspect-ratio: 9 / 16;
  border: 3px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  font-weight: 700;
}

.bg-option img, .bg-option.has-photo .preview-img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-option > span:last-of-type {
  grid-area: 1 / 1;
  align-self: end;
  padding: 3px 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
  text-align: center;
}

.bg-option.selected { border-color: var(--accent); }

.bg-option.upload { border: 2px dashed var(--line); align-items: center; justify-items: center; }
.bg-option.upload.selected { border: 3px solid var(--accent); }
.bg-option.upload .plus { grid-area: 1 / 1; font-size: 26px; color: var(--muted); }
.bg-option.upload.has-photo .plus { display: none; }
.bg-option.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.notes li {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 15px;
}

/* Phone-shaped frame */
.phone {
  position: relative;
  width: 100%;
  max-width: 240px;
  justify-self: center;
  padding: 10px;
  border-radius: 36px;
  background: var(--phone);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.phone::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  width: 54px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: var(--phone);
  z-index: 1;
}

.phone canvas, .phone iframe, .phone .placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  border-radius: 27px;
  background: #000;
}

.phone.wide { max-width: 100%; border-radius: 20px; }
.phone.wide::before { display: none; }
.phone.wide iframe { aspect-ratio: 16 / 9; border-radius: 12px; }

.phone .placeholder {
  display: grid;
  place-items: center;
  padding: 16px;
  color: #999;
  font-size: 13px;
  text-align: center;
  background: #2a2630;
}

/* Player controls */
.stage { display: grid; gap: 12px; }

.seek {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.seek input { width: 100%; accent-color: var(--accent); }
.seek span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.buttons, .result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

button, .button {
  font: inherit;
  font-weight: 700;
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button:disabled { opacity: 0.5; cursor: default; }

.progress { display: grid; gap: 6px; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#progress-text, .message { color: var(--muted); font-size: 14px; margin: 0; }

/* Channel */
.channel { text-align: center; }
.channel p { color: var(--muted); font-size: 15px; }
.channel .ask { color: var(--text); font-size: 16px; line-height: 1.7; }
.main-video { display: grid; margin: 16px 0; }
.main-video:empty { display: none; }
.channel { padding: 24px 0 0; }
.channel .button { display: inline-block; padding: 12px 24px; }

.videos {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.videos iframe {
  width: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  border-radius: 12px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 16px 48px;
}

/* Compact phone layout: one scrolling row of backgrounds, preview right after the inputs */
@media (max-width: 719px) {
  .topbar { padding: 10px 16px; }
  .hero { padding: 0 16px 14px; }
  h1 { font-size: 23px; margin-bottom: 6px; }
  .lead { font-size: 15px; }
  .sub { font-size: 14px; }
  .name-field, .dim-field { grid-template-columns: auto 1fr; align-items: center; gap: 12px; }
  .name-field > span, .dim-field > span { white-space: nowrap; }
  .name-field input { min-width: 0; }
  .field input[type="text"] { font-size: 18px; padding: 8px 12px; }
  .card { padding: 16px; }
  .controls { gap: 14px; }
  .backgrounds {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .bg-option { flex: 0 0 56px; scroll-snap-align: start; }
}
