/* 디자인: 시안 B(밝은 격자 + 아래 메뉴 3칸). 어둡게는 같은 배치에 색만 바꾼다. */
:root {
  --bg: #fbfbfc;
  --card: #ffffff;
  --line: #ecedf1;
  --soft: #eeeff3;
  --text: #1b1c22;
  --sub: #6d7180;
  --dim: #9a9eae;
  --accent: #3b4fb8;
  --accent-soft: #e7eaf6;
  --accent-softer: #f0f2fb;
  --green: #23764a;
  --green-soft: #e6f3ea;
  --code-bg: #1b1c22;
  --code-text: #cfd3e6;
}
html[data-theme="dark"] {
  --bg: #17181d;
  --card: #20222a;
  --line: #2a2c36;
  --soft: #2a2c36;
  --text: #f1f2f5;
  --sub: #9a9eae;
  --dim: #6d7180;
  --accent: #9db0ff;
  --accent-soft: #2c3150;
  --accent-softer: #262a40;
  --green: #7fd4a4;
  --green-soft: #213a2c;
  --code-bg: #0f1014;
  --code-text: #cfd3e6;
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, sans-serif;
  user-select: none; overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── 머리 ── */
#head { display: flex; align-items: center; padding: 10px 8px 8px 18px; flex: none; min-height: 56px; }
#head.back { padding-left: 6px; }
#head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#head.back h2 { font-size: 17px; }
#head .sp { flex: 1; min-width: 8px; }
.iconbtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--sub); flex: none; }
.iconbtn:active { background: var(--soft); }
.iconbtn.accent { color: var(--accent); }
.mode { display: flex; padding: 3px; border-radius: 10px; background: var(--soft); margin-right: 4px; flex: none; }
.mode button { padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--sub); border-radius: 7px; }
.mode button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(20,22,30,.12); }

/* ── 본문 ── */
#body { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; scrollbar-width: none; }
#body::-webkit-scrollbar { display: none; }
#body.flush { overflow: hidden; }
.pad-b { height: 14px; }
.empty { padding: 48px 28px; text-align: center; color: var(--dim); font-size: 13px; line-height: 1.7; }
.lbl { padding: 18px 18px 10px; font-size: 12.5px; font-weight: 700; color: var(--sub); }

/* ── 아래 메뉴 ── */
#nav { display: flex; padding: 6px 10px 8px; border-top: 1px solid var(--line); background: var(--card); flex: none; }
#nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--dim); }
#nav button.on { color: var(--text); }
#nav .pill { width: 52px; height: 28px; border-radius: 14px; display: grid; place-items: center; }
#nav .on .pill { background: var(--accent-soft); color: var(--accent); }

/* ── 작품 ── */
.search { margin: 2px 14px 12px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 12px; border-radius: 12px; background: var(--soft); color: var(--sub); }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); background: var(--card); }
.search .ic { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: 14px; color: var(--text); user-select: text; }
.search input::placeholder { color: var(--dim); }
.search .clear { width: 30px; height: 30px; border-radius: 15px; display: grid; place-items: center; color: var(--sub); }
.search .clear .ic { width: 16px; height: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; padding: 0 14px; }
.work .th { aspect-ratio: 2 / 3; border-radius: 14px; background: var(--soft) center top / cover no-repeat; box-shadow: 0 0 0 1px rgba(20,22,30,.06) inset; }
.work .nm { margin-top: 7px; padding: 0 2px; font-size: 13.5px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work:active .th { opacity: .8; }

.hero { margin: 0 14px; display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.hero .th { width: 64px; height: 96px; border-radius: 10px; background: var(--soft) center top / cover no-repeat; flex: none; }
.hero .t { font-size: 16px; font-weight: 800; letter-spacing: -.3px; line-height: 1.35; }
.hero .s { font-size: 12px; color: var(--sub); margin-top: 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 14px; }
.tile { height: 92px; border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); padding: 14px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; }
.tile:active { background: var(--soft); }
.tile .dot { width: 30px; height: 30px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.tile .dot .ic { width: 17px; height: 17px; }
.tile b { font-size: 14px; font-weight: 700; }

/* ── 테마곡 재생기(시안 B): 이 화면만 어둡고, 커버 색이 배경에 번진다 ── */
#bg { position: absolute; inset: -40px; background: #14151a center / cover no-repeat; filter: blur(34px) saturate(1.3); transform: scale(1.2); z-index: 0; }
#bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(12,13,18,.45), rgba(12,13,18,.82)); }
#head, #body, #mini, #nav { position: relative; z-index: 1; }
body[data-screen="player"] { background: #14151a; }
body[data-screen="player"] #head h2 { color: #fff; }
body[data-screen="player"] #head .iconbtn { color: rgba(255,255,255,.75); }
body[data-screen="player"] #head .iconbtn:active { background: rgba(255,255,255,.12); }
body[data-screen="player"] #nav { background: #14151a; border-top-color: rgba(255,255,255,.08); }
body[data-screen="player"] #nav button { color: rgba(255,255,255,.45); }
body[data-screen="player"] #nav button.on { color: #fff; }
body[data-screen="player"] #nav .on .pill { background: rgba(255,255,255,.14); color: #fff; }
.ic.fill { fill: currentColor; stroke: none; }

.pl { position: absolute; inset: 0; color: #fff; display: flex; flex-direction: column; align-items: center; overflow: hidden; }
.pl .disc { margin-top: 4px; width: min(46vw, 30vh); aspect-ratio: 1; border-radius: 50%; background: #2a2c36 center / cover no-repeat; position: relative; flex: none;
  box-shadow: 0 14px 34px rgba(0,0,0,.45), 0 0 0 6px rgba(255,255,255,.10); animation: spin 14s linear infinite; }
.pl .disc.paused { animation-play-state: paused; }
.pl .disc::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: repeating-radial-gradient(circle, rgba(0,0,0,0) 0 5px, rgba(0,0,0,.10) 5px 6px); }
.pl .disc::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; transform: translate(-50%, -50%); border-radius: 50%; background: #14151a; box-shadow: 0 0 0 5px rgba(255,255,255,.85); }
@keyframes spin { to { transform: rotate(360deg); } }
.pl .t { margin-top: 16px; padding: 0 22px; max-width: 100%; font-size: 20px; font-weight: 800; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .s { padding: 0 22px; max-width: 100%; font-size: 12px; color: rgba(255,255,255,.65); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl input[type="range"] { align-self: stretch; margin: 12px 20px 0; height: 20px; accent-color: #fff; }
.pl .time { align-self: stretch; display: flex; justify-content: space-between; padding: 0 22px; font-size: 11px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.pl .ctl { margin-top: 0; gap: 22px; }
.pl .ctl button { color: #fff; }
.pl .ctl button:active { background: rgba(255,255,255,.12); }
.pl .ctl .play { width: 54px; height: 54px; border-radius: 27px; background: #fff; color: #14151a; }
html[data-theme="dark"] .pl .ctl .play { color: #14151a; }

/* 곡 목록: 아래에 접혀 있다가 누르면 올라온다 */
.sheet { position: absolute; left: 10px; right: 10px; bottom: 0; height: 68px; border-radius: 16px 16px 0 0; background: rgba(40,42,54,.72); backdrop-filter: blur(14px); display: flex; flex-direction: column; transition: height .22s ease; }
.sheet.open { height: calc(100% - 8px); background: rgba(24,25,32,.92); }
.sheet .sh { display: block; width: 100%; padding: 8px 16px 6px; text-align: left; color: rgba(255,255,255,.75); flex: none; }
.sheet .sh::before { content: ""; display: block; width: 34px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.4); margin: 0 auto 7px; }
.sheet .h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; }
.sheet .nextline { padding: 2px 16px 0; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet .nextline em { font-style: normal; color: rgba(255,255,255,.55); margin-right: 8px; font-weight: 500; }
.sheet.open .nextline { display: none; }
.sheet .rows { display: none; flex: 1; overflow-y: auto; padding: 4px 8px 10px; scrollbar-width: none; }
.sheet .rows::-webkit-scrollbar { display: none; }
.sheet.open .rows { display: block; }
.sheet .track { color: #fff; padding: 8px; }
.sheet .track:active { background: rgba(255,255,255,.08); }
.sheet .track .cv { width: 38px; height: 38px; border-radius: 8px; background: #2a2c36 center / cover no-repeat; flex: none; }
.sheet .track .t { margin: 0; padding: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; }
.sheet .track .s { margin: 0; padding: 0; color: rgba(255,255,255,.55); }
.sheet .track .tx { flex: 1; min-width: 0; }
.sheet .track.on { background: rgba(255,255,255,.12); }
.sheet .track.on .t { color: #fff; }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; color: #fff; flex: none; }
.eq i { width: 3px; border-radius: 1.5px; background: currentColor; height: 100%; transform-origin: bottom; animation: eq 0.9s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
.eq.paused i { animation-play-state: paused; }
@keyframes eq { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

/* ── 재생기 공통(조작 버튼, 재생 중 띠) ── */
.now { margin: 0 14px; padding: 14px 16px 12px; border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.now .t { font-size: 16px; font-weight: 800; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now .s { font-size: 12px; color: var(--sub); margin-top: 2px; min-height: 18px; }
.now input[type="range"] { width: 100%; margin: 10px 0 2px; accent-color: var(--accent); height: 20px; }
.now .time { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.ctl { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 4px; }
.ctl button { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; color: var(--text); }
.ctl button:active { background: var(--soft); }
.ctl .play { width: 52px; height: 52px; border-radius: 26px; background: var(--accent); color: #fff; }
html[data-theme="dark"] .ctl .play { color: #17181d; }
.ctl .play .ic, .mini .ic.fill { fill: currentColor; stroke: none; }
.tracks { padding: 12px 14px 0; display: flex; flex-direction: column; gap: 2px; }
.track { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 12px; text-align: left; width: 100%; }
.track:active { background: var(--soft); }
.track .n { width: 20px; text-align: center; font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; flex: none; }
.track .t { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .s { font-size: 12px; color: var(--sub); }
.track.on { background: var(--accent-softer); }
.track.on .t, .track.on .n { color: var(--accent); }

.mini { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-top: 1px solid var(--line); background: var(--card); flex: none; }
.mini .txt { flex: 1; min-width: 0; }
.mini .t { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .s { font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 프로필(시안 5-A 표정 도감): 위젯 기본 화면 그대로, 캐릭터 색(--pa)만 얹는다 ── */
.pf-strip { display: flex; gap: 4px; padding: 2px 10px 8px; overflow-x: auto; scrollbar-width: none; }
.pf-strip::-webkit-scrollbar { display: none; }
.pf-strip button { flex: none; width: 54px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px; font-size: 10.5px; font-weight: 600; color: var(--dim); }
.pf-strip img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--soft); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--line); }
.pf-strip span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-strip .on { color: var(--text); font-weight: 800; }
.pf-strip .on img { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4.5px var(--pa); }
.pf-view { position: relative; margin: 0 14px; border-radius: 16px; overflow: hidden; background: var(--soft); }
.pf-slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.pf-slides::-webkit-scrollbar { display: none; }
.pf-slides figure { flex: none; width: 100%; aspect-ratio: 1216 / 832; scroll-snap-align: center; scroll-snap-stop: always; }
.pf-slides img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.pf-count { position: absolute; left: 10px; bottom: 10px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(20,22,30,.66); color: #fff; white-space: pre; pointer-events: none; }
.pf-dots { display: flex; justify-content: center; gap: 4px; padding: 8px 14px 0; }
.pf-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.pf-dots i.on { background: var(--pa); width: 14px; border-radius: 3px; }
.pf-forms { margin: 10px 14px 0; }
.pf-name { padding: 12px 16px 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pf-name b { font-size: 22px; font-weight: 900; letter-spacing: -.5px; }
.pf-name span { font-size: 12.5px; color: var(--sub); font-weight: 600; }
.pf-meta { padding: 3px 16px 0; font-size: 12.5px; color: var(--dim); }
.pf-meta b { color: var(--text); font-weight: 700; }
.pf-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 14px 0; }
.pf-tags span { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--soft); color: var(--sub); }
.pf .lbl { padding: 14px 16px 6px; }
.pf-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.pf-chips span { padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: color-mix(in srgb, var(--pa) 13%, var(--card)); color: color-mix(in srgb, var(--pa) 62%, var(--text)); }
.pf-kv { margin: 12px 14px 0; border-radius: 14px; background: var(--card); box-shadow: 0 0 0 1px var(--line); font-size: 13px; user-select: text; }
.pf-kv div { display: flex; gap: 10px; padding: 9px 13px; border-top: 1px solid var(--line); }
.pf-kv div:first-child { border-top: 0; }
.pf-kv span { width: 34px; color: var(--dim); font-weight: 700; flex: none; }
.pf-kv p { flex: 1; min-width: 0; line-height: 1.5; }

/* ── 보관함 ── */
.seg { margin: 0 14px 12px; display: flex; padding: 3px; border-radius: 12px; background: var(--soft); }
.seg button { flex: 1; text-align: center; padding: 7px 0; font-size: 12.5px; font-weight: 600; color: var(--sub); border-radius: 9px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(20,22,30,.12); }
.cards { padding: 0 14px; display: flex; flex-direction: column; gap: 10px; }
.card { border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); padding: 12px 12px 12px 14px; }
.card .row { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 10.5px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); flex: none; }
.chip.un { background: var(--green-soft); color: var(--green); }
.card .t { font-size: 14px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--accent); padding: 6px 10px; border-radius: 9px; background: var(--accent-softer); flex: none; }
.copy .ic { width: 14px; height: 14px; stroke-width: 2; }
.copy.done { background: var(--text); color: var(--bg); }
.card p { margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-break: break-all; }

.form { padding: 0 14px; display: flex; flex-direction: column; gap: 10px; }
.form input[type="text"], .form textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 0; outline: 0; box-shadow: 0 0 0 1px var(--line); border-radius: 12px; padding: 11px 13px; user-select: text;
}
.form input:focus, .form textarea:focus { box-shadow: 0 0 0 2px var(--accent); }
.form textarea { height: 150px; resize: none; line-height: 1.55; font-size: 13px; }
.form .seg { margin: 0; }
.acts { display: flex; gap: 8px; }
.btn { flex: 1; text-align: center; padding: 11px 0; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--soft); color: var(--text); }
.btn.pri { background: var(--accent); color: #fff; }
html[data-theme="dark"] .btn.pri { color: #17181d; }
.btn.danger { flex: 0 0 72px; color: #c8433d; }

/* ── HTML 미리보기: 머리와 아래 메뉴 사이를 다 쓴다 ── */
.pick { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 44px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.pick::-webkit-scrollbar { display: none; }
.pick button { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--sub); background: var(--soft); white-space: nowrap; flex: none; }
.pick button.on { background: var(--text); color: var(--bg); }
.pick em { margin-left: auto; padding-left: 8px; font-style: normal; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.htmlwrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.htmlwrap .stage { flex: 1; position: relative; border-top: 1px solid var(--line); min-height: 0; }
.htmlwrap .pick + .stage { border-top: 0; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.stage textarea {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; outline: 0; resize: none;
  background: var(--code-bg); color: var(--code-text); font: 12px/1.7 monospace; padding: 14px 16px 70px; white-space: pre; user-select: text;
}
.stage .acts { position: absolute; left: 12px; right: 12px; bottom: 12px; }
.stage .acts .btn:not(.pri) { background: #2c2f3a; color: #cfd3e6; }
.fab { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 14px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 6px 18px rgba(59,79,184,.35); }
html[data-theme="dark"] .fab { color: #17181d; }
.fab .ic { width: 16px; height: 16px; stroke-width: 2; }
.toast { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); padding: 8px 14px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* ── 설정 ── */
.field { margin: 0 14px 10px; padding: 14px; border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.field-head { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 700; font-size: 13.5px; }
.field-head output { color: var(--sub); font-weight: 600; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field .seg { margin: 0; }
