/* Layout: a control column (paper desk) beside a 9:16 stage, like a score next to a monitor. */
:root {
  --paper: #e9f0f1;      /* the visualizer's own background */
  --desk: #dfe7e9;       /* stage surround */
  --sheet: #f6f9f9;      /* control surfaces */
  --ink: #2b303b;
  --grey: #6f7783;
  --line: #c3cbd0;
  --accent: #7a6fd0;     /* clock / long-note purple */
  --note: #4096d6;       /* tap-note blue */
  --warm: #e2be76;       /* bell gold, used for the paid tag */
  --f-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --f-mark: "Unbounded", "JetBrains Mono", sans-serif;
  --r: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 14px/1.55 var(--f-ui);
  display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding-block: 14px; border-bottom: 1.4px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.mark { font: 700 20px/1 var(--f-mark); letter-spacing: 0.18em; }
.brand-sub { font: 500 12px/1 var(--f-mono); letter-spacing: 0.32em; color: var(--grey); }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: s; flex: 1; min-width: 0; flex-wrap: wrap; }
.steps li { white-space: nowrap; counter-increment: s; font: 500 12px/1 var(--f-mono); color: var(--grey); padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; letter-spacing: 0.04em; }
.steps li::before { content: "0" counter(s) " "; opacity: 0.6; }
.steps li.on { color: var(--ink); border-color: var(--ink); }
.top-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pro { font: 700 12px/1 var(--f-mono); letter-spacing: 0.06em; padding: 9px 12px; border-radius: 99px; border: 1px dashed var(--accent); background: transparent; color: var(--accent); cursor: pointer; }
.pro[aria-pressed="true"] { background: var(--accent); color: #fff; border-style: solid; }
body.paid .lock { display: none; }
body.paid .chip.locked { color: var(--ink); }
.lock-tag { display: inline-flex; margin-left: 4px; }
.lock-tag .lock { position: static; }
.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.sel-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sel-field select { width: 100%; font: 500 13px/1.2 var(--f-ui); color: var(--ink); background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; cursor: pointer; }
.sel-field select:disabled { color: var(--grey); cursor: not-allowed; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--sheet); }
.lang button { font: 700 12px/1 var(--f-mono); letter-spacing: 0.06em; background: none; border: 0; color: var(--grey); padding: 8px 12px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.wave-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--grey); font-size: 13px; pointer-events: none; }
.demo-badge { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: max-content; max-width: 88%; background: rgba(43, 48, 59, 0.86); color: #fff; font-size: 12px; line-height: 1.45; padding: 7px 12px; border-radius: 99px; text-align: center; pointer-events: none; }
.plan { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 99px; background: var(--sheet); border: 1px solid var(--line); cursor: default; }
.plan-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--note); }

/* work area */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 28px; padding-block: 20px; }
.panel { min-width: 0; overflow-y: auto; padding-right: 6px; display: flex; flex-direction: column; gap: 4px; }
.sec { display: flex; flex-direction: column; gap: 12px; padding-block: 14px 18px; border-bottom: 1px solid var(--line); }
.sec.last { border-bottom: 0; }
.sec h2 { margin: 0; display: flex; align-items: center; gap: 10px; font: 600 15px/1.2 var(--f-ui); }
.n { font: 500 12px/1 var(--f-mono); color: var(--grey); width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; display: inline-grid; place-items: center; }
.len { margin-left: auto; font: 500 12px/1 var(--f-mono); color: var(--grey); letter-spacing: 0.05em; }
.note { margin: 0; color: var(--grey); font-size: 13px; }

.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drop { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 12px 12px 11px; background: var(--sheet); border: 1px dashed var(--line); border-radius: var(--r); cursor: pointer; min-width: 0; transition: border-color .15s, background .15s; }
.drop:hover, .drop.drag { border-color: var(--ink); background: #fff; }
.drop.ok { border-style: solid; border-color: var(--note); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-k { font: 700 13px/1.2 var(--f-mono); letter-spacing: 0.08em; }
.drop-v { grid-column: 1 / -1; font: 400 12px/1.4 var(--f-mono); color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req { font-size: 11px; color: var(--note); font-weight: 600; }
.drop .x { position: absolute; z-index: 2; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: var(--sheet); color: var(--grey); font: 500 16px/1 var(--f-ui); display: grid; place-items: center; cursor: pointer; padding: 0; }
.drop .x:hover { color: #fff; background: var(--ink); border-color: var(--ink); }
.drop.ok .req { visibility: hidden; }
.file-foot { display: flex; align-items: flex-start; gap: 12px; }
.file-foot .note { flex: 1; min-width: 0; }
.link { flex: none; border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; cursor: pointer; }
.req.opt { color: var(--grey); }

.wave { position: relative; height: 92px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; touch-action: none; cursor: grab; }
.wave canvas { width: 100%; height: 100%; display: block; }
.sel { position: absolute; top: 0; bottom: 0; left: 0; width: 20%; border: 1.5px solid var(--ink); border-radius: 4px; background: rgba(122, 111, 208, 0.12); pointer-events: none; }
.sel-l, .sel-r { position: absolute; bottom: 3px; font: 500 11px/1 var(--f-mono); background: var(--ink); color: #fff; padding: 3px 5px; border-radius: 3px; }
.sel-l { left: 3px; } .sel-r { right: 3px; }
.grip { display: none; position: absolute; top: 50%; width: 8px; height: 30px; margin-top: -15px; background: var(--ink); border-radius: 3px; box-shadow: 0 0 0 2px var(--sheet); }
.grip::after { content: ""; position: absolute; left: 3px; top: 8px; width: 2px; height: 14px; background: rgba(255, 255, 255, 0.7); border-radius: 1px; }
.grip.l { left: 2px; } .grip.r { right: 2px; }
.sel.resizable .grip { display: block; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); pointer-events: none; }
.wave.dragging { cursor: grabbing; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--r); border: 1px solid var(--ink); background: transparent; cursor: pointer; font-weight: 500; }
.btn:hover:not(:disabled) { background: #fff; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #3a4150; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { border-color: var(--line); color: var(--grey); cursor: not-allowed; }
.ico { font-size: 11px; width: 12px; text-align: center; }

.sync { display: flex; flex-direction: column; gap: 6px; }
.sync-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--grey); }
.sync-head output { font: 500 13px/1.5 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.sync-row { display: flex; align-items: flex-start; gap: 10px; }
.sync-fine { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.btn.step { padding: 6px 9px; font: 500 12px/1.2 var(--f-mono); flex: none; }
.ticks { display: flex; justify-content: space-between; font: 400 11px/1 var(--f-mono); color: var(--grey); }
input[type="range"] { width: 100%; accent-color: var(--ink); }
input[type="range"]:disabled { accent-color: var(--line); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-k { font-size: 13px; color: var(--grey); display: flex; justify-content: space-between; }
.field-k b { font: 500 13px/1.5 var(--f-mono); color: var(--ink); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sw { position: relative; aspect-ratio: 1; max-width: 100%; border-radius: var(--r); border: 1px solid var(--line); cursor: pointer; padding: 0; overflow: hidden; display: grid; grid-template-rows: 1fr 6px; }
.sw .sw-bg { display: block; }
.sw .sw-bar { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.sw[aria-checked="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.lock { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%; background: rgba(43, 48, 59, 0.75); display: grid; place-items: center; }
.lock::before { content: ""; width: 5px; height: 4px; border: 1.4px solid #fff; border-bottom: 0; border-radius: 3px 3px 0 0; transform: translateY(-2px); }
.lock::after { content: ""; position: absolute; width: 7px; height: 5px; background: #fff; border-radius: 1px; transform: translateY(1.5px); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--sheet); }
.seg button { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 6px; font: 500 13px/1.2 var(--f-ui); color: var(--grey); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.seg.small button { padding: 6px; font-size: 12px; }
.seg input[type="color"] { width: 22px; height: 18px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
body:not(.paid) .seg.locked button:not([data-v="preset"]):not([data-v="theme"]):not([data-v="normal"]) { opacity: 0.55; }
.color-auto { display: flex; gap: 10px; align-items: center; }
.color-auto .seg { flex: 1; }
.color-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.color-pick input, .cc-item input { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.cc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.cc-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink); min-width: 0; }
.cc-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-insts { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.cc-insts input { width: 28px; height: 24px; }
.cc-warn { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: #fbeee7; color: #8a3d22; border-radius: var(--r); padding: 8px 10px; font-size: 12px; }
.cc-row { display: flex; gap: 8px; margin-top: 14px; }
.color-custom { display: grid; gap: 8px; }
.cc-mine { display: flex; gap: 6px; flex-wrap: wrap; }
.cc-mine button { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); padding: 0; cursor: pointer; overflow: hidden; display: grid; grid-template-rows: 1fr 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { position: relative; padding: 7px 12px 7px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--sheet); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chip[aria-checked="true"] { border-color: var(--ink); background: #fff; font-weight: 600; }
.chip.locked { color: var(--grey); }
.chip .lock { position: static; }
.mini { min-width: 0; }
.paid-end { display: inline-flex; align-items: center; gap: 5px; }
.paid-end .lock { position: relative; top: auto; right: auto; width: 13px; height: 13px; }

/* stage */
.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--desk); border-radius: 10px; padding: 18px; }
.frame { position: relative; flex: 1; min-height: 0; aspect-ratio: 9 / 16; max-width: 100%; box-shadow: 0 1px 0 rgba(43, 48, 59, 0.08), 0 12px 32px rgba(43, 48, 59, 0.14); }
.frame canvas { width: 100%; height: 100%; display: block; background: var(--paper); }
.drop-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(233, 240, 241, 0.88); border: 2px dashed var(--ink); font-weight: 600; }
.transport { display: flex; gap: 16px; font: 400 12px/1 var(--f-mono); color: var(--grey); font-variant-numeric: tabular-nums; }
.tc { color: var(--ink); }

/* tooltip */
.tip { position: fixed; z-index: 50; width: 324px; max-width: calc(100vw - 24px); background: var(--ink); color: #f1f4f6; border-radius: 8px; padding: 12px; box-shadow: 0 10px 30px rgba(20, 24, 32, 0.28); opacity: 0; transform: translateY(4px); transition: opacity .14s, transform .14s; pointer-events: none; }
.tip.on { opacity: 1; transform: none; }
.tip::after { content: ""; position: absolute; left: calc(var(--ax, 50%) - 6px); bottom: -6px; width: 12px; height: 12px; background: var(--ink); transform: rotate(45deg); border-radius: 2px; }
.tip.below::after { bottom: auto; top: -6px; }
.tip-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tip-title { font-weight: 600; font-size: 14px; }
.tip-tag { font: 600 11px/1 var(--f-mono); color: var(--ink); background: var(--warm); padding: 3px 6px; border-radius: 3px; letter-spacing: 0.04em; }
.tip canvas { width: 100%; height: auto; display: block; border-radius: 5px; margin-bottom: 8px; background: var(--paper); }
.tip-body { margin: 0; font-size: 13px; line-height: 1.6; color: #d6dbe1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 60; max-width: calc(100vw - 32px); }

@media (max-width: 860px) {
  body { height: auto; }
  .work { grid-template-columns: 1fr; }
  .panel { overflow: visible; padding-right: 0; }
  .stage { order: -1; }
  .top { gap: 12px; }
  .steps { order: 3; flex-basis: 100%; }
  .top-r { margin-left: auto; }
  .frame { flex: none; width: min(100%, 360px); }
}
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }

/* ---- export */
.export-info { font: 400 12px/1.5 var(--f-mono); color: var(--grey); margin-bottom: 8px; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:disabled { background: transparent; color: var(--grey); border-color: var(--line); cursor: not-allowed; }
.xp { width: min(460px, calc(100vw - 32px)); border: 0; border-radius: 12px; padding: 22px; background: var(--sheet); color: var(--ink); box-shadow: 0 24px 64px rgba(43, 48, 59, 0.3); display: none; gap: 20px; align-items: center; }
.xp[open] { display: flex; }
.xp::backdrop { background: rgba(43, 48, 59, 0.5); }
.xp-thumb { flex: none; width: 108px; aspect-ratio: 9 / 16; border-radius: 6px; overflow: hidden; background: var(--line); box-shadow: 0 0 0 1px var(--line); }
.xp-thumb canvas { width: 100%; height: 100%; display: block; }
.xp-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
.xp h2 { margin: 0; font-size: 18px; }
.xp-stage { margin: 0; font-size: 13px; color: var(--grey); min-height: 1.4em; }
.export-bar { position: relative; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.export-bar i { position: relative; display: block; height: 100%; width: 0; background: var(--ink); border-radius: 5px; transition: width .25s linear; overflow: hidden; }
/* a light sweep that keeps moving even while the page is busy (transform animations run off the main thread) */
.export-bar i::after { content: ""; position: absolute; inset: 0; width: 60px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); animation: xp-sweep 1.2s linear infinite; }
@keyframes xp-sweep { from { transform: translateX(-60px); } to { transform: translateX(460px); } }
@media (prefers-reduced-motion: reduce) { .export-bar i::after { animation: none; } }
.export-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--grey); }
.export-row b { font: 700 22px/1 var(--f-mono); color: var(--ink); }
.xp-note { margin: 2px 0 4px; font-size: 12px; line-height: 1.5; color: var(--grey); }
.xp .btn { justify-self: start; }
@media (max-width: 420px) { .xp { flex-direction: column; } .xp-thumb { width: 90px; } .xp .btn { justify-self: stretch; } }
body.busy .panel > .sec:not(.last), body.busy .top-r { pointer-events: none; opacity: .5; }

/* ---- account */
.acct { position: relative; }
.acct-btn { font: 600 13px/1 var(--f-ui); padding: 9px 14px; border-radius: 99px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn.in { background: var(--sheet); color: var(--ink); border-color: var(--line); }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 230px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(43, 48, 59, 0.16); padding: 12px; display: grid; gap: 6px; }
.acct-email { font-weight: 600; font-size: 13px; word-break: break-all; }
.acct-plan { font: 400 12px/1.4 var(--f-mono); color: var(--grey); margin-bottom: 4px; }
.acct-link { text-align: left; font: 500 13px/1.2 var(--f-ui); color: var(--ink); background: none; border: 0; border-top: 1px solid var(--line); padding: 9px 0 3px; cursor: pointer; text-decoration: none; }
.login { width: min(400px, calc(100vw - 32px)); border: 0; border-radius: 10px; padding: 28px 24px 20px; background: var(--sheet); color: var(--ink); box-shadow: 0 24px 64px rgba(43, 48, 59, 0.3); }
.login::backdrop { background: rgba(43, 48, 59, 0.45); }
.login h2 { margin: 0 0 6px; font-size: 20px; }
.login-sub { margin: 0 0 18px; color: var(--grey); font-size: 13px; line-height: 1.5; }
.login-x { position: absolute; right: 12px; top: 10px; font-size: 22px; line-height: 1; border: 0; background: none; color: var(--grey); cursor: pointer; padding: 4px 8px; }
.btn.google { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 600; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--grey); font-size: 12px; margin: 16px 0 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-form { display: grid; gap: 8px; }
.login-form input { font: 400 15px/1.2 var(--f-ui); padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; color: var(--ink); }
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-input { font: 600 24px/1 var(--f-mono) !important; letter-spacing: 0.4em; text-align: center; }
.login-sent { font-size: 13px; line-height: 1.5; margin: 0 0 12px; }
.login-row { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; }
.login-err { min-height: 18px; margin: 10px 0 0; color: #b4472a; font-size: 12px; line-height: 1.5; }
.login-note { margin: 6px 0 0; color: var(--grey); font-size: 11px; }

/* ---- footer (business info, legal links) */
.foot { flex: none; display: flex; justify-content: space-between; gap: 6px 18px; flex-wrap: wrap; padding: 8px 0 10px; border-top: 1px solid var(--line); color: var(--grey); font-size: 11px; line-height: 1.5; }
.foot a, .login-note a { color: inherit; }
.foot-links { white-space: nowrap; }
