:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --card: #17171f;
  --line: #26262f;
  --text: #f2f0f5;
  --dim: #9a97a5;
  --accent: #7b5bff;
  --accent2: #b399ff;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; }

#app { display: flex; min-height: 100vh; }

/* 사이드바 */
.sidebar {
  width: 92px; flex-shrink: 0; padding: 22px 10px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 30px; align-items: center;
  position: sticky; top: 0; height: 100vh;
}
.logo-img { width: 44px; height: 44px; border-radius: 13px; display: block; margin: 0 auto 8px; }
.logo { font-weight: 900; font-size: 15px; letter-spacing: -0.5px; text-align: center; line-height: 1.2; }
.logo span { color: var(--accent2); }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.sidebar nav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px; border-radius: 12px; font-size: 11px; color: var(--dim);
}
.sidebar nav a .ic { font-size: 18px; line-height: 0; display: flex; align-items: center; justify-content: center; height: 20px; }
.sidebar nav a.active { color: var(--text); background: linear-gradient(180deg, rgba(123,91,255,.22), rgba(123,91,255,.06)); }
.sidebar nav a:hover { color: var(--text); }

main { flex: 1; min-width: 0; padding: 20px 32px 80px; }

/* 상단바 */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.topbar .hello { font-size: 13px; color: var(--dim); }
.topbar .hello b { display: block; font-size: 19px; color: var(--text); }
.topbar .right { display: flex; gap: 10px; align-items: center; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.chip.balance { border-color: rgba(123,91,255,.5); }
.chip.balance em { font-style: normal; color: var(--accent2); }
.btn {
  background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 700; transition: transform .1s, opacity .2s;
}
.btn:hover { opacity: .9; } .btn:active { transform: scale(.97); }
.btn.ghost { background: var(--card); border: 1px solid var(--line); color: var(--text); }
.btn.big { padding: 14px 28px; font-size: 15px; }
.btn:disabled { opacity: .4; cursor: default; }

/* USP 배지 */
.usp {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, rgba(123,91,255,.16), rgba(77,214,168,.10));
  border: 1px solid rgba(123,91,255,.4); border-radius: 999px; padding: 9px 18px;
}
.usp .usp-txt { font-size: 13px; color: var(--dim); }
.usp .usp-txt em { font-style: normal; font-weight: 800; color: var(--text); margin-right: 8px; }
.eq { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 16px; }
.eq i { width: 3px; background: linear-gradient(180deg, #4dd6a8, var(--accent2)); border-radius: 2px; animation: eqb 1s ease-in-out infinite; }
.eq i:nth-child(1) { animation-delay: 0s; } .eq i:nth-child(2) { animation-delay: .2s; }
.eq i:nth-child(3) { animation-delay: .4s; } .eq i:nth-child(4) { animation-delay: .1s; }
@keyframes eqb { 0%,100% { height: 5px; } 50% { height: 16px; } }

/* 히어로 */
.hero {
  position: relative; border-radius: 20px; overflow: hidden; margin-bottom: 36px;
  padding: 46px 44px; min-height: 320px; display: flex; flex-direction: column; justify-content: flex-end;
  border: 1px solid var(--line);
}
.hero .glyph { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); font-size: 200px; opacity: .16; pointer-events: none; }
.hero .genre { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--accent2); margin-bottom: 10px; }
.hero h1 { font-size: 40px; font-weight: 900; letter-spacing: -1px; margin-bottom: 10px; max-width: 640px; }
.hero p { color: var(--dim); font-size: 15px; max-width: 560px; line-height: 1.6; margin-bottom: 22px; }
.hero .meta { font-size: 13px; color: var(--dim); margin-bottom: 20px; }
.hero .meta b { color: #f5c542; }
.hero .actions { display: flex; gap: 10px; }

/* 스토리 그리드 */
.section-title { font-size: 20px; font-weight: 800; margin: 34px 0 16px; letter-spacing: -0.4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.card { cursor: pointer; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.cover {
  aspect-ratio: 1; border-radius: 14px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; padding: 14px;
  border: 1px solid var(--line);
}
.cover .glyph { position: absolute; right: -14px; bottom: -20px; font-size: 110px; opacity: .22; }
.cover .plays { font-size: 11px; font-weight: 700; background: rgba(0,0,0,.45); align-self: flex-start; padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(4px); }
.cover .cover-title { font-size: 19px; font-weight: 900; line-height: 1.25; letter-spacing: -0.5px; text-shadow: 0 2px 12px rgba(0,0,0,.5); position: relative; }
.cover .live { position: relative; margin-top: 8px; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: #7dffb0; }
.cover.has-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.has-img .cover-grad { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(5,5,9,.88)); }
.cover .cover-bottom { position: relative; z-index: 2; margin-top: auto; }
.cover.has-img .plays { position: relative; z-index: 2; }
.card .card-meta { margin-top: 10px; }
.card .card-meta .t { font-size: 14px; font-weight: 700; }
.card .card-meta .s { font-size: 12px; color: var(--dim); margin-top: 3px; }
.card .card-meta .r { color: #f5c542; font-weight: 700; }

/* 스토리 상세 */
.detail { display: grid; grid-template-columns: 340px 1fr; gap: 36px; align-items: start; }
.detail .cover { aspect-ratio: 1; border-radius: 20px; padding: 22px; }
.detail .cover .cover-title { font-size: 30px; }
.detail h1 { font-size: 32px; font-weight: 900; letter-spacing: -0.8px; margin-bottom: 8px; }
.detail .meta { color: var(--dim); font-size: 14px; margin-bottom: 16px; }
.detail .meta b { color: #f5c542; }
.detail .desc { color: var(--dim); line-height: 1.75; font-size: 15px; margin-bottom: 28px; max-width: 620px; }
.char-card {
  display: flex; align-items: center; gap: 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 12px; max-width: 620px;
}
.char-card .avatar.img { padding: 0; overflow: hidden; }
.char-card .avatar.img img { width: 100%; height: 100%; object-fit: cover; }
.char-card .avatar {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 900; color: #fff;
}
.char-card .info { flex: 1; min-width: 0; }
.char-card .info .n { font-weight: 800; font-size: 16px; }
.char-card .info .n small { color: var(--accent2); font-weight: 600; margin-left: 8px; font-size: 12px; }
.char-card .info .d { color: var(--dim); font-size: 13px; margin-top: 4px; }
.back { display: inline-block; color: var(--dim); font-size: 13px; margin-bottom: 18px; }
.back:hover { color: var(--text); }

/* 대화 화면 */
.chat {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center;
  background-color: var(--bg);
  padding: 32px 20px calc(28px + env(safe-area-inset-bottom));
}
.chat .chat-head { text-align: center; }
.chat .chat-head .st { font-size: 12px; color: var(--dim); letter-spacing: 1px; }
.chat .chat-head .cn { font-size: 24px; font-weight: 900; margin-top: 4px; }
.chat .orb-wrap { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
.orb {
  width: 190px; height: 190px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 56px; font-weight: 900; color: #fff;
  box-shadow: 0 0 90px rgba(123,91,255,.35);
  transition: transform .3s;
}
.orb.img { overflow: hidden; border: 3px solid rgba(255,255,255,.25); }
.orb.img img { width: 100%; height: 100%; object-fit: cover; }
.orb.speaking { animation: pulse 1.4s ease-in-out infinite; }
.orb.listening { box-shadow: 0 0 90px rgba(77,214,168,.4); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.chat .status { margin-top: 18px; font-size: 14px; color: var(--dim); min-height: 20px; text-align: center; }
.captions {
  width: 100%; max-width: 640px; height: 150px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; margin: 18px 0; padding: 4px 14px 4px 8px;
  mask-image: linear-gradient(to bottom, transparent, black 22%);
  scrollbar-width: thin; scrollbar-color: rgba(179,153,255,.35) transparent;
}
.captions::-webkit-scrollbar { width: 4px; }
.captions::-webkit-scrollbar-track { background: transparent; }
.captions::-webkit-scrollbar-thumb { background: rgba(179,153,255,.35); border-radius: 4px; }
.captions::-webkit-scrollbar-thumb:hover { background: rgba(179,153,255,.6); }
.captions .line { font-size: 14px; line-height: 1.55; }
.captions .line.user { color: var(--dim); text-align: right; }
.captions .line.ai { color: var(--text); }
.captions .line b { color: var(--accent2); font-weight: 700; margin-right: 6px; }
.chat .controls { display: flex; gap: 14px; align-items: center; }
.round {
  width: 58px; height: 58px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; line-height: 0;
}
.ctl { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ctl-label { font-size: 11px; color: var(--dim); }
.round.danger { background: #e5484d; border-color: #e5484d; }
.round.muted { background: #3a2b2b; border-color: #6c3b3b; }
.chat .timer { font-size: 13px; color: var(--dim); margin-top: 14px; }
.chat .timer em { font-style: normal; color: var(--accent2); font-weight: 700; }

/* 스토어 */
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; max-width: 860px; }
.pack {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.pack.best { border-color: var(--accent); position: relative; }
.pack.best::before { content: attr(data-best); position: absolute; top: -11px; left: 20px; background: var(--accent); font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.pack .mins { font-size: 26px; font-weight: 900; }
.pack .mins small { font-size: 13px; color: var(--dim); font-weight: 500; }
.pack .price { font-size: 18px; font-weight: 700; color: var(--accent2); margin-bottom: 8px; }
.pack .per { font-size: 12px; color: var(--dim); }

/* 내 기록 */
.table { width: 100%; max-width: 760px; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--dim); font-size: 12px; font-weight: 600; }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 32px; width: 100%; max-width: 400px; }
.modal h2 { font-size: 22px; font-weight: 900; margin-bottom: 6px; }
.modal .sub { color: var(--dim); font-size: 13px; margin-bottom: 22px; line-height: 1.5; }
.modal label { display: block; font-size: 12px; color: var(--dim); margin: 14px 0 6px; }
.modal input {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 14px; font-family: inherit;
}
.modal input:focus { outline: none; border-color: var(--accent); }
.modal .btn { width: 100%; margin-top: 22px; padding: 13px; }
.modal .switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--dim); }
.modal .switch a { color: var(--accent2); cursor: pointer; }

select.chip.lang, .studio-form select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b399ff' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding: 9px 36px 9px 16px; font-size: 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--text);
}
select.chip.lang:focus, .studio-form select:focus { outline: none; border-color: var(--accent); }
.studio-form select { border-radius: 10px; padding: 12px 40px 12px 14px; font-size: 14px; }
.file-wrap { display: flex; align-items: center; gap: 12px; }
.file-wrap input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px dashed rgba(179,153,255,.5); color: var(--accent2);
  padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.file-btn:hover { border-color: var(--accent); background: rgba(123,91,255,.08); }
.file-name { font-size: 12px; color: var(--dim); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.avatar-fb { position: absolute; }
.char-card .avatar { position: relative; overflow: hidden; }
.char-card .avatar img { position: relative; z-index: 1; }
.btn.kakao { display: block; width: 100%; background: #FEE500; color: #191919; text-align: center; padding: 13px; border-radius: 10px; font-weight: 700; margin-bottom: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#google-btn { display: flex; justify-content: center; margin-top: 4px; }
.table-wrap { overflow-x: auto; }

/* 스튜디오 */
.studio-form { max-width: 640px; }
.studio-form label { display: block; font-size: 12px; color: var(--dim); margin: 14px 0 6px; }
.studio-form input, .studio-form textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 14px; font-family: inherit; resize: vertical;
}
.studio-form input:focus, .studio-form textarea:focus { outline: none; border-color: var(--accent); }
.studio-form select.chip.lang { width: auto; border-radius: 10px; }
.ep-row { justify-content: space-between; }

.studio-form .help { font-size: 12px; color: var(--dim); margin-top: 6px; }

.enter-world { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; background: linear-gradient(90deg, var(--accent), #4d8fd6); }

/* 전역 플레이어 */
.player-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 80;
  width: min(680px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px;
  background: rgba(18,18,26,.92); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 14px; backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.player-bar .p-art { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; background: #241a2e; color: var(--accent2); }
.player-bar .p-art img { width: 100%; height: 100%; object-fit: cover; }
.player-bar .p-info { flex: 1; min-width: 0; cursor: pointer; }
.player-bar .p-t { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .p-s { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .p-time { font-size: 11px; color: var(--dim); }
.player-bar .p-btn { background: none; border: 0; color: var(--text); font-size: 15px; padding: 6px; cursor: pointer; display: inline-flex; align-items: center; }
.player-bar .p-btn.big { font-size: 20px; }
.player-bar .p-progress { position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2px; background: rgba(255,255,255,.1); border-radius: 2px; }
.player-bar .p-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #4dd6a8); border-radius: 2px; }
@media (max-width: 760px) {
  .player-bar { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 16px); }
}

.ibar { position: relative; background: rgba(255,255,255,.06); border-radius: 6px; height: 22px; min-width: 120px; overflow: hidden; }
.ibar-fill { height: 100%; border-radius: 6px; opacity: .75; }
.ibar span { position: absolute; right: 8px; top: 3px; font-size: 11px; color: var(--text); }

.gem { width: .95em; height: .95em; vertical-align: -0.08em; margin-right: .18em; }
.chip.balance em { display: inline-flex; align-items: center; gap: 5px; } .chip.balance .gem { vertical-align: 0; }

/* 토스트 */
#toast-root { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #24242e; border: 1px solid var(--line); padding: 12px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.empty { color: var(--dim); font-size: 14px; padding: 40px 0; text-align: center; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; min-height: 0; max-height: 72px;
    flex-direction: row; align-items: center; justify-content: space-around; gap: 0;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
    background: rgba(10,10,15,.94); backdrop-filter: blur(10px); z-index: 60;
  }
  .sidebar .logo { display: none; }
  .sidebar nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .sidebar nav a { padding: 6px 4px; flex: 1; }
  main { padding: 14px 14px 120px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar .right { flex-wrap: wrap; }
  .usp { order: 3; width: 100%; justify-content: center; padding: 8px 12px; }
  .usp .usp-txt { font-size: 12px; }
  .hero { padding: 24px 18px; min-height: 240px; border-radius: 16px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 13px; }
  .hero .actions .btn.big { padding: 12px 18px; font-size: 14px; }
  .section-title { font-size: 17px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cover .cover-title { font-size: 15px; }
  .detail { grid-template-columns: 1fr; gap: 20px; }
  .detail .cover { max-width: none; }
  .detail h1 { font-size: 24px; }
  .char-card { padding: 14px; gap: 12px; flex-wrap: wrap; }
  .char-card .btn { flex-basis: 100%; }
  .packs { grid-template-columns: 1fr; }
  .chat { padding: 20px 16px calc(88px + env(safe-area-inset-bottom)); }
  .orb { width: 150px; height: 150px; font-size: 44px; }
  .captions { height: 120px; }
  .modal { padding: 24px 20px; }
}
