:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e222e;
  --text: #e6e8ee;
  --muted: #9aa0ad;
  --accent: #6c8cff;
  --accent-2: #a06cff;
  --user-bubble: #2b4bd8;
  --bot-bubble: #232838;
  --border: #2a2f3d;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
}
.hidden { display: none !important; }

/* ===== 로그인 화면 ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); display: grid; place-items: center; padding: 20px;
}
.login-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 32px 28px; width: 100%; max-width: 360px; text-align: center;
}
.login-desc { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.login-box #gbtn { display: flex; justify-content: center; min-height: 44px; }
.login-hint { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; }

/* ===== 앱 셸 (사이드바 + 메인) ===== */
.app-shell { display: flex; height: 100dvh; }
.main { flex: 1; min-width: 0; height: 100dvh; overflow: hidden; position: relative; }
.main .screen { height: 100%; max-width: none; margin: 0; }

.sidebar {
  width: 264px; flex: 0 0 264px; height: 100dvh;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.sidebar-nav {
  padding: 10px; display: flex; flex-direction: column; gap: 4px;
  border-bottom: 1px solid var(--border);
}
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; border: none; background: transparent;
  color: var(--text); font-size: 14px; font-family: inherit; cursor: pointer;
}
.side-item:hover, .side-item.active { background: var(--panel-2); }
.side-item.active { color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.side-item .si-ic { width: 20px; text-align: center; }
.sidebar-recent { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-recent-title {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 0 4px 10px;
}

/* 최근 대화 목록 (사이드바 + 모바일 채팅화면 공용) */
.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.recent-item:hover, .recent-item.active { background: var(--panel-2); }
.recent-av {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.recent-av img { width: 100%; height: 100%; object-fit: cover; }
.recent-main { flex: 1; min-width: 0; }
.recent-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.recent-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.recent-snippet { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.recent-empty { color: var(--muted); font-size: 13px; padding: 10px; }

.recent-full { flex: 1; overflow-y: auto; padding: 8px 10px 96px; }
.recent-full .recent-item { padding: 12px 10px; border-bottom: 1px solid var(--border); border-radius: 0; }
.recent-full .recent-av { width: 48px; height: 48px; font-size: 20px; }

/* 사이드바 접기 (데스크톱) */
.app-shell.sidebar-collapsed .sidebar { display: none; }
.menu-open { display: none; }
.app-shell.sidebar-collapsed .menu-open { display: grid; }

/* 하단 탭바 (모바일 전용) */
.bottom-nav { display: none; }
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: none; color: var(--muted);
  font-size: 11px; font-family: inherit; cursor: pointer; padding: 6px 0;
}
.bn-item .bn-ic { font-size: 20px; line-height: 1; }
.bn-item.active { color: var(--accent); }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.model-badge {
  font-size: 12px; color: var(--muted);
  background: var(--panel-2);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  background: transparent; border: none; color: var(--text);
  font-size: 24px; cursor: pointer; width: 40px; height: 40px;
  border-radius: 10px; display: grid; place-items: center;
}
.icon-btn:active { background: var(--panel-2); }

/* Gallery */
.gallery { flex: 1; overflow-y: auto; padding: 22px 16px 90px; }
.gallery-head h1 { font-size: 22px; margin: 0 0 6px; }
.gallery-head p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  transition: transform .12s, border-color .12s;
}
.card:active { transform: scale(0.97); }
.card:hover { border-color: var(--accent); }
/* 이미지(캐릭터 아트)가 카드 비율(3:4)을 직접 결정 → 모바일에서도 안정적 */
.card .poster-bg {
  display: block; width: 100%; aspect-ratio: 3 / 4;
  object-fit: cover; object-position: center top;
}
.card div.poster-bg.emoji {
  display: grid; place-items: center; font-size: 52px; object-fit: initial;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.card .poster-grad {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.88) 0%, rgba(0,0,0,.4) 32%, rgba(0,0,0,0) 58%);
}
.card .poster-info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 12px 12px;
}
.card .cname {
  color: #fff; font-weight: 700; font-size: 15px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.card .ctag {
  color: rgba(255,255,255,.82); font-size: 12px; margin-top: 3px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.chat-title .avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  display: block;
}
.card .del {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25);
  color: #fff; border-radius: 8px; width: 26px; height: 26px;
  font-size: 13px; cursor: pointer; display: none;
}
.card.custom:hover .del { display: block; }
.card .view-images {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  display: none; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.25);
  color: #fff; background: rgba(0,0,0,.55); text-decoration: none; font-weight: 800;
}
.card.custom:hover .view-images { display: grid; }

.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; font-size: 30px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(108,140,255,.4);
  z-index: 20;
}
@media (min-width: 900px) { .fab { right: calc(50% - 450px + 24px); } }

/* Chat */
.chat-stage {
  width: 100%; height: 100%; min-height: 0;
  display: flex; flex-direction: column;
}
.chat-top { gap: 8px; }
.chat-top > .icon-btn { flex: 0 0 40px; }
.chat-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-title > div { flex: 1; min-width: 0; }
.chat-title .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: 0 0 auto;
  overflow: hidden;
}
.chat-name, .chat-tag {
  display: block; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.chat-name { font-weight: 600; font-size: 15px; }
.chat-tag { color: var(--muted); font-size: 12px; }

.messages {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth;
}
.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.bot { justify-content: flex-start; }
.message-stack {
  position: relative; display: flex; flex-direction: column; max-width: 82%; min-width: 0;
}
.row.user .message-stack { align-items: flex-end; }
.row.bot .message-stack { align-items: flex-start; }
.bubble {
  max-width: 100%; padding: 11px 15px; border-radius: 16px;
  line-height: 1.55; font-size: 15px; white-space: pre-wrap; word-break: break-word;
}
.row.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.row.bot .bubble { background: var(--bot-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { border-color: var(--danger); color: var(--danger); }
.bubble-note {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
.bubble .inline-img {
  display: block; max-width: 100%; height: auto;
  border-radius: 12px; margin: 8px 0 2px;
}
.bubble .genimg-ph {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 8px 0 2px; padding: 12px 16px;
  border: 1px dashed var(--border); border-radius: 12px;
  background: var(--panel-2); color: var(--muted); font-size: 13px;
}
.bubble .genimg-ph.error { border-color: var(--danger); color: var(--danger); }
.bubble .genimg-ph .spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.typing::after { content: "▍"; animation: blink 1s step-start infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.message-actions {
  display: flex; align-items: stretch; width: fit-content; margin-top: 5px;
  border: 1px solid var(--border); border-radius: 8px; background: rgba(29,32,39,.96);
  box-shadow: 0 3px 10px rgba(0,0,0,.18); opacity: .38;
  transition: opacity .15s, border-color .15s;
}
.row:hover .message-actions, .message-actions:focus-within { opacity: 1; border-color: #4d5260; }
.message-action {
  display: grid; place-items: center; min-width: 34px; height: 29px; padding: 0 9px;
  border: 0; border-right: 1px solid var(--border); background: transparent;
  color: #c8ccd5; cursor: pointer; font-size: 16px; line-height: 1;
}
.message-actions > :last-child .message-action,
.message-actions > .message-action:last-child { border-right: 0; }
.message-action:hover { color: #fff; background: rgba(255,255,255,.07); }
.message-action.more { font-size: 12px; letter-spacing: 1px; }
.message-more-wrap { position: relative; display: flex; }
.message-more-menu {
  display: none; position: absolute; bottom: calc(100% + 7px); z-index: 24;
  min-width: 128px; padding: 5px; border-radius: 9px;
  border: 1px solid var(--border); background: #202329;
  box-shadow: 0 8px 24px rgba(0,0,0,.38);
}
.row.user .message-more-menu { right: 0; }
.row.bot .message-more-menu { left: 0; }
.message-more-menu.open { display: block; }
.message-more-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  cursor: pointer; font: inherit; font-size: 13px; text-align: left; white-space: nowrap;
}
.message-more-menu button:hover { background: rgba(255,255,255,.07); }
.message-more-menu button.danger { color: #ff9c9c; }
.message-more-menu button span { width: 16px; text-align: center; }

/* Composer */
.composer {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--panel);
}
#input {
  width: 100%; resize: none; max-height: 160px; padding: 12px 14px;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
  font-size: 15px; font-family: inherit; line-height: 1.4; outline: none;
}
#input:focus { border-color: var(--accent); }
.composer-tools {
  display: flex; align-items: center; gap: 8px;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.tool-btn svg { color: var(--accent); }
.tool-btn:hover { border-color: var(--accent); }
.tool-btn:active { transform: scale(0.95); }
.tool-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.tool-btn.active svg { color: #fff; }
.tool-btn:disabled { opacity: .4; cursor: not-allowed; }
#sendBtn {
  flex: 0 0 auto; margin-left: auto;
  width: 46px; height: 46px; border: none; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
#sendBtn:active { transform: scale(0.92); }
#sendBtn:disabled { opacity: .45; cursor: not-allowed; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; z-index: 30; padding: 16px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; width: 100%; max-width: 440px;
  max-height: 90dvh; overflow-y: auto;
}
.modal-box h2 { margin: 0 0 16px; font-size: 18px; }
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal-box input, .modal-box textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
  font-size: 14px; font-family: inherit; outline: none; resize: vertical;
}
.modal-box input:focus, .modal-box textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn {
  padding: 10px 18px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.btn.ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }
.confirm-modal { z-index: 80; }
.confirm-box { max-width: 390px; }
.confirm-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ===== 채팅방 관리 패널 ===== */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 40; display: flex; justify-content: flex-end;
}
.panel-overlay.hidden { display: none; }
.panel {
  width: 100%; max-width: 380px; height: 100%;
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 0 0 calc(16px + env(safe-area-inset-bottom));
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-sec { padding: 18px; border-bottom: 1px solid var(--border); }
.panel-sec-title {
  font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 12px;
}
.panel-note { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; cursor: pointer;
}
/* 토글 스위치 */
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); transition: .18s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  border-radius: 50%; background: var(--muted); transition: .18s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }
.switch input:disabled + .slider { opacity: .4; }

/* 속도/품질 슬라이더 */
.speed-row { margin-top: 14px; }
.speed-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.speed-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  border-radius: 999px; outline: none; cursor: pointer;
  background: var(--panel-2);  /* JS가 왼쪽 채움 그라디언트로 덮어씀 */
}
.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.speed-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); cursor: pointer;
}
.speed-ticks {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 11px; color: var(--muted);
}
.speed-ticks span { flex: 1; text-align: center; }
.speed-ticks span:first-child { text-align: left; }
.speed-ticks span:last-child { text-align: right; }
.speed-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* 대화 모델 출력량 / 생각 깊이 */
.generation-settings { padding-top: 16px; padding-bottom: 20px; }
.generation-title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.generation-title-row .panel-sec-title { margin-bottom: 0; }
.generation-title-row strong { color: var(--accent); font-size: 12px; white-space: nowrap; }
.generation-slider { margin-top: 5px; }
.generation-ticks span { font-variant-numeric: tabular-nums; }
.generation-hint {
  margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.45;
}
.generation-subhead {
  display: flex; align-items: center; gap: 7px;
  margin: 22px 0 7px; font-size: 14px; font-weight: 650;
}
.beta-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 999px; background: rgba(255, 71, 168, .18); color: #ff69b4;
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
}
.thinking-ticks span:first-child { text-align: left; }
.thinking-ticks span:nth-child(2) { text-align: center; }
.thinking-ticks span:last-child { text-align: right; }
.generation-warning {
  margin-top: 14px; padding: 10px 11px; border-radius: 10px;
  border: 1px solid rgba(245, 181, 55, .25); background: rgba(245, 181, 55, .09);
  color: #d6a83d; font-size: 11px; line-height: 1.5;
}

.session-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.session-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--panel-2);
}
.session-item.active { border-color: var(--accent); }
.session-item .s-main { flex: 1; min-width: 0; cursor: pointer; }
.session-item .s-title {
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-branch {
  display: inline-block; margin-right: 6px; padding: 2px 5px; border-radius: 5px;
  background: rgba(108,140,255,.14); color: #aabaff; font-size: 9px; vertical-align: 1px;
}
.session-item .s-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.session-item button {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  cursor: pointer; font-size: 13px;
}
.session-item button:hover { border-color: var(--accent); color: var(--text); }
.panel-btn {
  width: 100%; padding: 11px; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #fff; border: none; font-size: 14px; font-weight: 600;
}
.panel-btn.ghost { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.panel-actions { display: flex; flex-direction: column; gap: 8px; }
.panel-input {
  width: 100%; margin-bottom: 8px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
  font-size: 14px; font-family: inherit; outline: none; resize: vertical;
}
.panel-input:focus { border-color: var(--accent); }
.state-vars-editor {
  min-height: 112px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; tab-size: 2;
}
.state-vars-meta { margin: -2px 0 10px; color: var(--muted); font-size: 11px; }

/* ===== 모든 이미지 뷰어 ===== */
.viewer-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg); display: flex; flex-direction: column;
}
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0;
}
.viewer-title { font-weight: 600; font-size: 15px; }
.viewer-body {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.viewer-body img {
  width: 100%; max-width: 560px; height: auto; border-radius: 12px;
  background: var(--panel-2); display: block;
}
.viewer-empty, .viewer-loading { color: var(--muted); font-size: 14px; padding: 24px; }

/* ===== 페르소나 관리 ===== */
.persona-current {
  width: 100%; text-align: left; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--text);
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2);
  cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.persona-current:hover { border-color: var(--accent); }
.persona-current:disabled { cursor: default; opacity: .7; }
.persona-current:disabled:hover { border-color: var(--border); }
.persona-current-hint { color: var(--accent); font-size: 11px; font-weight: 500; white-space: nowrap; }
.persona-mgr-body { flex: 1; overflow-y: auto; padding: 16px; max-width: 640px; width: 100%; margin: 0 auto; }
.persona-mgr-desc { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 16px; }
.persona-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.persona-group-head {
  margin: 8px 2px 0; display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; color: var(--text); font-size: 13px; font-weight: 700;
}
.persona-group-head span { color: var(--muted); font-size: 11px; font-weight: 400; text-align: right; }
.persona-item {
  position: relative; border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 40px 14px 14px; cursor: pointer; background: var(--panel);
}
.persona-item.selected { border-color: var(--accent); background: rgba(108,140,255,.08); }
.pi-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pi-badge {
  font-size: 11px; font-weight: 600; color: #fff; background: var(--accent);
  padding: 2px 8px; border-radius: 999px;
}
.pi-check { color: var(--accent); font-weight: 700; }
.pi-desc {
  color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.pi-view-link {
  margin-top: 8px; padding: 0; border: 0; background: transparent;
  color: var(--accent); font: inherit; font-size: 12px; cursor: pointer;
}
.pi-view-link:hover { text-decoration: underline; }
.pi-menu { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.pi-menu button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 12px;
}
.pi-menu button:hover { border-color: var(--accent); color: var(--text); }
.persona-form { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.pf-row { display: flex; gap: 8px; }
.pf-row #pfGender { flex: 2; }
.pf-row #pfAge { flex: 1; }
.pi-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* 페르소나 전체 설정: 본문만 독립 스크롤되어 긴 프롬프트도 휠/터치로 열람 가능 */
.persona-detail-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 16px 48px;
}
.persona-detail-card {
  width: 100%; max-width: 720px; margin: 0 auto; padding: 22px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--panel);
}
.persona-detail-scope {
  display: inline-flex; padding: 3px 9px; border-radius: 999px;
  color: #fff; background: var(--accent); font-size: 11px; font-weight: 700;
}
.persona-detail-card h2 { margin: 12px 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.persona-detail-meta { color: var(--muted); font-size: 13px; }
.persona-detail-label {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 700;
}
.persona-detail-desc {
  margin-top: 10px; color: var(--text); font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* 시작 시나리오 선택 */
.scenario-switcher {
  align-self: flex-end; display: flex; align-items: stretch; max-width: calc(100% - 32px);
  margin: 0 16px 10px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--panel-2); box-shadow: 0 4px 14px rgba(0,0,0,.18); overflow: hidden;
}
.scenario-arrow, .scenario-current {
  border: 0; background: transparent; color: var(--text); font-family: inherit; cursor: pointer;
}
.scenario-arrow {
  width: 38px; flex: 0 0 38px; color: var(--muted); font-size: 23px; line-height: 1;
}
.scenario-arrow:hover, .scenario-current:hover { background: rgba(255,255,255,.06); }
.scenario-arrow:active { background: rgba(255,255,255,.1); }
.scenario-current {
  min-width: 0; padding: 8px 10px; border-left: 1px solid var(--border);
  border-right: 1px solid var(--border); display: flex; align-items: baseline; gap: 5px;
  font-size: 13px; white-space: nowrap;
}
.scenario-current span { color: var(--muted); }
.scenario-current strong { overflow: hidden; text-overflow: ellipsis; }
.scenario-current small { color: var(--muted); font-size: 10px; }
.scenario-list { display: flex; flex-direction: column; gap: 10px; }
.scenario-item {
  border: 1px solid var(--border); border-radius: 14px; padding: 14px; cursor: pointer;
  background: var(--panel); transition: border-color .12s, background .12s;
}
.scenario-item:hover { border-color: var(--accent); background: rgba(108,140,255,.06); }
.scenario-item .sc-num { font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.scenario-item .sc-text {
  font-size: 13px; color: var(--text); line-height: 1.5; white-space: pre-wrap;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 6; -webkit-box-orient: vertical;
}
.scenario-item .sc-guide { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; line-height: 1.45; }

/* ===== 캐릭터 제작 스튜디오 ===== */
.creator-screen { background: #10131a; }
.creator-topbar { flex: 0 0 auto; min-height: 66px; }
.creator-top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.creator-top-title strong { font-size: 15px; }
.creator-top-title span { color: var(--muted); font-size: 11px; }
.creator-top-actions { display: flex; gap: 8px; }
.btn.compact { padding: 8px 14px; border-radius: 10px; }
.creator-scroll { flex: 1; overflow-y: auto; }
.creator-steps {
  position: sticky; top: 0; z-index: 8;
  display: grid; grid-template-columns: repeat(6, minmax(82px, 1fr));
  max-width: 1180px; margin: 0 auto; padding: 16px 24px 14px;
  background: rgba(16,19,26,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.creator-step {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); background: transparent; border: 0; cursor: pointer;
  font: inherit; font-size: 13px; padding: 6px;
}
.creator-step:not(:last-child)::after {
  content: ""; position: absolute; right: -12%; width: 24%; height: 1px; background: var(--border);
}
.creator-step b {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); font-size: 12px;
}
.creator-step.active { color: #fff; font-weight: 700; }
.creator-step.active b { background: var(--accent); border-color: var(--accent); }
.creator-step.done b { color: #fff; background: #3fba89; border-color: #3fba89; }
.creator-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 28px;
  max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px;
}
.creator-editor { min-width: 0; }
.creator-page { display: none; }
.creator-page.active { display: block; animation: creatorFade .18s ease; }
@keyframes creatorFade { from { opacity: .4; transform: translateY(4px); } }
.creator-page-head { margin-bottom: 24px; }
.creator-page-head.with-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.creator-page-head h1 { margin: 2px 0 8px; font-size: 25px; letter-spacing: -.02em; }
.creator-page-head p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.creator-page-head code { color: #b9c7ff; background: var(--panel-2); padding: 2px 5px; border-radius: 5px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.creator-page > .field, .creator-page > .form-grid, .choice-block, .creator-check { margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; color: var(--muted); font-size: 12px; }
.field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field em { color: #747b8c; font-style: normal; font-size: 11px; font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--border); border-radius: 11px;
  color: var(--text); background: var(--panel); outline: none;
  padding: 11px 12px; font: inherit; font-size: 14px; line-height: 1.5; resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,140,255,.1); }
.default-avatar-picker {
  display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; align-items: center; gap: 13px;
  margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--panel);
}
.default-avatar-picker img { width: 62px; height: 62px; object-fit: cover; border-radius: 12px; background: var(--panel-2); }
.default-avatar-picker div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.default-avatar-picker b { font-size: 13px; }
.default-avatar-picker span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.default-avatar-picker .btn { padding: 8px 11px; white-space: nowrap; font-size: 12px; }
.choice-block { padding: 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 13px; }
.choice-title { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px; text-align: center; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); font-size: 13px; }
.segmented input:checked + span { color: #fff; border-color: var(--accent); background: rgba(108,140,255,.16); }
.creator-check {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--panel); cursor: pointer;
}
.creator-check input { margin-top: 3px; accent-color: var(--accent); }
.creator-check span { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.creator-check small { color: var(--muted); line-height: 1.4; }
.asset-upload { display: inline-flex; flex: 0 0 auto; align-items: center; }
.asset-upload input { display: none; }
.asset-guide {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid rgba(108,140,255,.28); border-radius: 12px; background: rgba(108,140,255,.07);
  color: var(--muted); font-size: 12px;
}
.asset-guide code { color: #c6d0ff; white-space: nowrap; }
.state-guide b { color: #d3dbff; }
.asset-toolbar {
  display: grid; grid-template-columns: minmax(180px, 1fr) 150px auto auto; gap: 8px;
  align-items: center; margin-bottom: 14px;
}
.asset-toolbar > input, .asset-toolbar > select {
  min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); background: var(--panel); font: inherit; font-size: 12px; outline: none;
}
.asset-toolbar > span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.asset-pager { display: flex; align-items: center; gap: 7px; }
.asset-pager b { min-width: 48px; color: var(--muted); text-align: center; font-size: 11px; }
.creator-empty {
  min-height: 190px; display: grid; place-items: center; align-content: center; gap: 7px;
  border: 1px dashed #394052; border-radius: 15px; color: var(--muted); text-align: center;
}
.creator-empty span { font-size: 30px; filter: grayscale(.2); }
.creator-empty b { color: var(--text); font-size: 14px; }
.creator-empty small { font-size: 12px; }
.asset-list, .variable-editor-list, .scenario-editor-list, .lore-editor-list { display: flex; flex-direction: column; gap: 14px; }
.asset-item, .variable-edit, .scenario-edit, .lore-edit {
  border: 1px solid var(--border); border-radius: 15px; background: var(--panel); padding: 15px;
}
.asset-item { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 15px; }
.asset-item > img { width: 118px; aspect-ratio: 2 / 3; object-fit: cover; object-position: top; border-radius: 10px; background: var(--panel-2); }
.asset-fields .form-grid { margin-top: 12px; }
.asset-trigger-field { margin: 12px 0; }
.asset-title, .editor-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.asset-title b { font-size: 13px; }
.mini-danger { border: 0; background: transparent; color: #ff8989; cursor: pointer; font: inherit; font-size: 12px; padding: 4px 7px; }
.asset-options { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 12px; }
.asset-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.asset-options input { accent-color: var(--accent); }
.editor-card-head { margin-bottom: 15px; }
.editor-card-head span { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.editor-card-head b { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: rgba(108,140,255,.16); color: #c4ceff; }
.variable-edit > .field, .variable-edit > .form-grid, .scenario-edit > .field, .scenario-edit > .form-grid, .lore-edit > .field, .lore-edit > .form-grid { margin-bottom: 13px; }
.compact-select { max-width: 50%; }
.scenario-state-block { margin: 4px 0 15px; padding: 13px; border: 1px solid #343a4b; border-radius: 12px; background: rgba(8,10,15,.22); }
.scenario-state-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.scenario-state-title b { font-size: 12px; }
.scenario-state-title span { color: var(--muted); font-size: 10px; }
.scenario-state-block .form-grid { margin: 0; }
.reply-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.creator-foot { display: grid; grid-template-columns: 100px 1fr 100px; align-items: center; gap: 12px; margin-top: 24px; }
.creator-foot span { text-align: center; color: var(--muted); font-size: 12px; }
.creator-foot button:disabled, .creator-page-head button:disabled { opacity: .35; cursor: default; }
.preview-sticky { position: sticky; top: 78px; }
.preview-label { margin-bottom: 9px; color: var(--muted); font-size: 10px; letter-spacing: .14em; font-weight: 700; }
.preview-card { position: relative; aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; background: var(--panel); border: 1px solid var(--border); }
.preview-art { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(145deg, #354a9d, #6d3d91); background-size: cover; background-position: center top; }
.preview-gradient { position: absolute; inset: 0; background: linear-gradient(to top, rgba(4,5,9,.94), rgba(4,5,9,.15) 62%); }
.preview-copy { position: absolute; left: 18px; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.preview-copy strong { color: #fff; font-size: 20px; text-shadow: 0 2px 5px #000; }
.preview-copy span { color: rgba(255,255,255,.78); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.preview-adult { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; display: grid; place-items: center; background: #cf3144; color: #fff; border-radius: 50%; font-size: 11px; font-weight: 800; border: 2px solid rgba(255,255,255,.7); }
.preview-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.preview-summary div { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 11px; }
.preview-summary span { color: var(--muted); font-size: 10px; }
.preview-summary b { font-size: 12px; }
.preview-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preview-checks span { color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 5px 8px; border-radius: 999px; font-size: 10px; }
.preview-checks span.ok { color: #7ee3b9; border-color: rgba(63,186,137,.35); }
.preview-note { color: var(--muted); font-size: 11px; line-height: 1.5; }

/* 시작 장면 추천 답변 */
.suggested-replies { display: flex; gap: 7px; overflow-x: auto; padding: 8px 16px; background: var(--panel); border-top: 1px solid var(--border); }
.scenario-play-guide { flex: 0 0 auto; max-width: 420px; padding: 8px 11px; border-radius: 9px; color: var(--muted); background: var(--panel-2); font-size: 11px; line-height: 1.45; white-space: normal; }
.suggested-replies button { flex: 0 0 auto; max-width: 280px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--accent); color: #cbd4ff; background: rgba(108,140,255,.09); cursor: pointer; font: inherit; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 700px) {
  .message-stack { max-width: 88%; }
  .message-actions { opacity: .82; }
  .message-action { min-width: 38px; height: 32px; }
  .message-more-menu {
    position: fixed; left: 12px !important; right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom)); min-width: 0;
    padding: 7px; border-radius: 15px; z-index: 60;
  }
  .message-more-menu button { padding: 14px 13px; border-radius: 10px; font-size: 15px; }
  .gallery-head h1 { font-size: 19px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

  /* 모바일: 사이드바 숨기고 하단 탭바 사용 */
  .sidebar { display: none; }
  .menu-open { display: none !important; }
  .app-shell { height: auto; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: var(--panel); border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  }
  /* 채팅 화면일 때는 하단 탭바 숨김 (입력창과 겹침 방지) */
  body.chat-active .bottom-nav { display: none; }
  .gallery { padding-bottom: 96px; }
  .fab { display: none; }
  .card.custom .del { display: block; }
  .card.custom .view-images { display: grid; }

  .creator-topbar { padding: 8px 10px; }
  .creator-top-title span { display: none; }
  .creator-top-actions .ghost { display: none; }
  .creator-steps { grid-template-columns: repeat(6, 1fr); padding: 9px 5px; }
  .creator-step { gap: 0; }
  .creator-step span { display: none; }
  .creator-step:not(:last-child)::after { right: -18%; width: 36%; }
  .creator-layout { display: block; padding: 22px 14px 110px; }
  .creator-preview { margin-top: 30px; }
  .preview-sticky { position: static; }
  .preview-card { max-width: 280px; margin: 0 auto; }
  .creator-page-head.with-action { align-items: flex-end; }
  .creator-page-head h1 { font-size: 21px; }
  .form-grid.two, .form-grid.three, .reply-grid { grid-template-columns: 1fr; }
  .default-avatar-picker { grid-template-columns: 54px minmax(0, 1fr); }
  .default-avatar-picker img { width: 54px; height: 54px; }
  .default-avatar-picker .btn { grid-column: 1 / -1; }
  .asset-item { grid-template-columns: 82px minmax(0, 1fr); padding: 11px; }
  .asset-item > img { width: 82px; }
  .asset-item .form-grid.two { grid-template-columns: 1fr; }
  .asset-toolbar { grid-template-columns: minmax(0, 1fr) 120px; }
  .asset-toolbar > span { grid-column: 1 / -1; }
  .asset-pager { justify-content: flex-end; }
  .compact-select { max-width: none; }
  .scenario-state-title { align-items: flex-start; flex-direction: column; }
  .creator-foot { grid-template-columns: 88px 1fr 88px; }
  body:not(.chat-active) .creator-screen { padding-bottom: 64px; }
}

/* ===== PC 전용 레이아웃 ===== */
@media (min-width: 1024px) {
  .sidebar { width: 280px; flex-basis: 280px; }
  .sidebar-head { min-height: 66px; padding-inline: 18px; }
  .sidebar-nav { padding: 14px; }
  .sidebar-recent { padding: 16px 14px; }

  #galleryScreen .topbar { min-height: 66px; padding-inline: 28px; }
  .gallery {
    width: 100%; max-width: 1360px; margin: 0 auto;
    padding: 38px 40px 110px;
  }
  .gallery-head h1 { font-size: 28px; letter-spacing: -.02em; }
  .gallery-head p { margin-bottom: 28px; font-size: 15px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
  .card { border-radius: 19px; }
  .card .poster-info { padding: 14px 15px 16px; }
  .card .cname { font-size: 17px; }
  .card .ctag { font-size: 13px; }
  .fab { right: 40px; bottom: 32px; }

  #chatScreen {
    align-items: center; justify-content: center;
    padding: 20px 28px;
    background:
      radial-gradient(circle at 50% 0%, rgba(108,140,255,.09), transparent 38%),
      #0c0e13;
  }
  .chat-stage {
    max-width: 1040px; height: 100%;
    border: 1px solid var(--border); border-radius: 20px;
    background: var(--bg); overflow: hidden;
    box-shadow: 0 18px 60px rgba(0,0,0,.28);
  }
  .chat-top {
    position: static; min-height: 70px; padding: 13px 22px;
    background: rgba(23,26,35,.96);
  }
  .chat-title .avatar { width: 44px; height: 44px; }
  .chat-name { font-size: 16px; }
  .messages {
    min-height: 0; padding: 30px 36px 24px; gap: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,.012), transparent 22%);
  }
  .message-stack { max-width: min(76%, 760px); }
  .bubble { padding: 14px 18px; font-size: 15px; line-height: 1.68; }
  .bubble .inline-img { width: auto; max-width: min(100%, 600px); max-height: 620px; object-fit: contain; }
  .scenario-switcher { margin: 0 28px 12px; }
  .suggested-replies { padding: 10px 28px; }
  .composer { padding: 15px 20px 18px; }
  #input { min-height: 58px; padding: 16px 17px; }
  .composer-tools { padding-inline: 2px; }
  .tool-btn { padding: 8px 16px; }
  #sendBtn { width: 48px; height: 48px; }

  .recent-full { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 28px 110px; }
  .viewer-overlay .persona-mgr-body { padding-top: 28px; }

  .main { transition: margin-right .22s ease; }
}

/* 큰 PC에서는 관리 패널을 오버레이가 아닌 오른쪽 작업 패널로 도킹 */
@media (min-width: 1320px) {
  body.chat-panel-open .main { margin-right: 400px; }
  body.chat-panel-open #chatScreen { padding-inline: 20px; }
  .panel-overlay {
    left: auto; width: 400px; background: transparent;
    border-left: 1px solid var(--border); box-shadow: -16px 0 45px rgba(0,0,0,.22);
  }
  .panel { width: 400px; max-width: none; border-left: 0; animation: none; }
}

/* ===== 발견 홈 / 검색 / 계정 메뉴 ===== */
.home-topbar {
  min-height: 66px;
  padding: 10px 22px;
  background: rgba(15,17,23,.92);
  backdrop-filter: blur(18px);
}
.home-topbar .brand { font-size: 17px; }
.home-topbar .menu-open { display: none; }
.app-shell.sidebar-collapsed .home-topbar .menu-open { display: grid; }
.home-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.home-model-badge { display: none; }
.install-pill {
  height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border);
  color: #dfe3ee; background: #2b2f38; font: 600 13px inherit; cursor: pointer;
}
.install-pill:hover { background: #383d48; }
.top-action {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 50%; color: #f3f5fa; background: transparent;
  font: 400 29px/1 inherit; cursor: pointer;
}
.top-action:hover, .account-trigger:hover { background: rgba(255,255,255,.08); }
.top-action.has-indicator { font-size: 24px; }
.top-action.has-indicator i {
  position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%;
  background: #ff315f; box-shadow: 0 0 0 2px var(--bg);
}
.account-trigger {
  width: 40px; height: 40px; padding: 3px; border-radius: 50%; overflow: hidden;
  border: 1px solid rgba(255,255,255,.16); background: transparent; cursor: pointer;
}
.account-trigger img, .account-profile-row img {
  width: 100%; height: 100%; display: block; object-fit: cover; object-position: top; border-radius: 50%;
}

.home-feed {
  padding: 22px 26px 120px;
  background:
    radial-gradient(circle at 86% 8%, rgba(160,108,255,.10), transparent 24%),
    radial-gradient(circle at 8% 24%, rgba(108,140,255,.08), transparent 26%),
    var(--bg);
}
.home-hero {
  position: relative; min-height: 320px; max-height: 460px; aspect-ratio: 2.7 / 1;
  overflow: hidden; border: 1px solid rgba(255,255,255,.11); border-radius: 24px;
  background: var(--panel); box-shadow: 0 22px 50px rgba(0,0,0,.25);
}
.home-hero-bg {
  position: absolute; inset: -8%; width: 116%; height: 116%; object-fit: cover; object-position: center 25%;
  filter: saturate(.9); transform: scale(1.01);
}
.home-hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(5,6,10,.96) 0%, rgba(5,6,10,.79) 38%, rgba(5,6,10,.12) 76%),
              linear-gradient(0deg, rgba(5,6,10,.72), transparent 45%);
}
.home-hero-copy {
  position: absolute; z-index: 1; left: clamp(24px, 5vw, 64px); top: 50%; transform: translateY(-50%);
  width: min(47%, 560px); display: flex; flex-direction: column; align-items: flex-start;
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 14px; color: #cbd4ff;
  font-size: 11px; font-weight: 800; letter-spacing: .13em;
}
.hero-kicker::before { content: ""; width: 18px; height: 2px; background: var(--accent); }
.home-hero h1 { margin: 0; color: #fff; font-size: clamp(28px, 3vw, 48px); letter-spacing: -.04em; line-height: 1.06; }
.home-hero p {
  margin: 13px 0 22px; color: rgba(255,255,255,.75); font-size: 14px; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.hero-start, .hero-search {
  height: 42px; padding: 0 18px; border-radius: 12px; border: 0; font: 700 13px inherit; cursor: pointer;
}
.hero-start { color: #fff; background: linear-gradient(135deg, #6c8cff, #8d62f5); box-shadow: 0 8px 24px rgba(108,140,255,.28); }
.hero-search { color: #fff; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(10px); }
.hero-meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.hero-meta span { padding: 5px 8px; border-radius: 999px; color: rgba(255,255,255,.67); background: rgba(0,0,0,.32); font-size: 10px; }

.topic-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 24px 2px 5px; }
.topic-strip::-webkit-scrollbar, .home-rail::-webkit-scrollbar { display: none; }
.topic-chip {
  flex: 0 0 auto; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); background: var(--panel); font: 600 12px inherit; cursor: pointer;
}
.topic-chip:hover, .topic-chip.active { color: #fff; border-color: rgba(108,140,255,.65); background: rgba(108,140,255,.15); }
.home-section { margin-top: 34px; }
.home-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 2px 14px; }
.home-section-head .eyebrow { display: block; margin-bottom: 4px; color: #8ea5ff; font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.home-section-head h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.home-section-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.text-action { border: 0; background: transparent; color: var(--muted); font: 500 12px inherit; cursor: pointer; }
.text-action:hover { color: #fff; }
.section-count { color: var(--muted); font-size: 11px; }
.home-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(154px, 16vw, 206px);
  grid-template-rows: 1fr; gap: 14px; overflow-x: auto; overflow-y: hidden;
  padding: 2px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: none;
}
.home-rail .card { scroll-snap-align: start; min-width: 0; }
.home-rail .card .poster-bg { aspect-ratio: 3 / 4.25; }
.card-badge {
  position: absolute; z-index: 2; left: 9px; top: 9px; display: inline-flex; align-items: center;
  min-height: 24px; padding: 0 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  color: #fff; background: rgba(9,10,14,.64); backdrop-filter: blur(8px); font-size: 10px; font-weight: 700;
}
.card.has-images .card-badge { top: 43px; }
.home-empty-card {
  min-height: 190px; grid-column: 1 / -1; display: grid; place-items: center; text-align: center;
  padding: 26px; border: 1px dashed var(--border); border-radius: 16px; color: var(--muted); background: rgba(255,255,255,.018); font-size: 13px;
}

.home-recent-rail { grid-auto-columns: clamp(260px, 27vw, 340px); }
.continue-card {
  display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 11px; min-height: 84px; border: 1px solid var(--border); border-radius: 15px;
  background: var(--panel); cursor: pointer; scroll-snap-align: start;
}
.continue-card:hover { border-color: #46506b; background: #1b1f29; }
.continue-card img { width: 62px; height: 62px; border-radius: 12px; object-fit: cover; object-position: top; }
.continue-card > div { min-width: 0; }
.continue-card b, .continue-card span, .continue-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card b { font-size: 14px; }
.continue-card span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.continue-card small { margin-top: 6px; color: #6f7890; font-size: 10px; }

.home-popover {
  position: absolute; z-index: 55; top: 58px; right: 16px; width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 76px); overflow-y: auto; border: 1px solid #343842; border-radius: 15px;
  color: #f2f3f7; background: rgba(24,25,29,.98); box-shadow: 0 18px 54px rgba(0,0,0,.48);
  backdrop-filter: blur(18px);
}
.account-popover { padding: 10px; }
.account-profile-row, .account-menu-row {
  width: 100%; display: grid; align-items: center; border: 0; color: inherit; background: transparent;
  font-family: inherit; text-align: left; cursor: pointer;
}
.account-profile-row {
  grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; padding: 8px; border-radius: 11px;
  box-shadow: inset 0 -2px 0 #ff3164;
}
.account-profile-row:hover, .account-menu-row:hover { background: rgba(255,255,255,.055); }
.account-profile-row img { width: 38px; height: 38px; }
.account-profile-row span, .account-menu-row span { min-width: 0; }
.account-profile-row b, .account-profile-row small, .account-menu-row b, .account-menu-row small { display: block; }
.account-profile-row b, .account-menu-row b { font-size: 13px; }
.account-profile-row small, .account-menu-row small { margin-top: 3px; color: #8f939d; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-profile-row i, .account-menu-row i { color: #8f939d; font-style: normal; }
.account-credit-row { display: flex; justify-content: space-between; gap: 12px; padding: 14px 9px 10px; font-size: 13px; }
.account-credit-row span { display: flex; gap: 8px; }
.account-credit-row strong { color: #ff7596; }
.account-divider { height: 1px; margin: 7px 4px; background: #33353b; }
.account-label { padding: 8px 9px 4px; color: #90949f; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.account-menu-row { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 6px; padding: 9px 8px; border-radius: 10px; }
.account-menu-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: #fff; background: #090a0d; font-size: 12px; }
.account-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 8px; }
.account-setting-row > span:first-child { min-width: 0; }
.account-setting-row b, .account-setting-row small { display: block; }
.account-setting-row b { font-size: 13px; }
.account-setting-row small { margin-top: 3px; color: #8f939d; font-size: 10px; }
.account-setting-row select { max-width: 92px; padding: 7px 25px 7px 9px; border: 0; border-radius: 8px; color: #fff; background: #292b30; font: 600 11px inherit; }
.switch-setting .switch { flex: 0 0 auto; }
.account-status { display: grid; grid-template-columns: auto 1fr auto; gap: 7px; align-items: center; padding: 8px 9px 3px; color: #8f939d; font-size: 10px; }
.account-status .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4edb91; box-shadow: 0 0 8px rgba(78,219,145,.45); }
.account-status small { color: #696d77; }

.notification-popover { width: min(360px, calc(100vw - 24px)); padding: 12px; }
.popover-title { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 11px; border-bottom: 1px solid #33353b; }
.popover-title button { border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.notification-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 15px 5px 6px; }
.notification-item > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: #ffc9d6; background: rgba(255,49,100,.15); }
.notification-item b { font-size: 13px; }
.notification-item p { margin: 5px 0; color: #a0a4ae; font-size: 11px; line-height: 1.5; }
.notification-item small { color: #666b75; font-size: 10px; }

.search-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  color: var(--text); background: rgba(15,17,23,.99); animation: searchIn .16s ease-out;
}
@keyframes searchIn { from { opacity: 0; transform: translateY(-8px); } }
.search-head {
  min-height: 70px; display: grid; grid-template-columns: 40px minmax(0, 760px) 40px;
  justify-content: center; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border);
}
.search-field {
  grid-column: 2; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  height: 46px; padding: 0 13px; border: 1px solid #3a3e49; border-radius: 13px; background: #20232b;
}
.search-field > span { color: #aeb4c2; font-size: 24px; }
.search-field input { min-width: 0; border: 0; outline: 0; color: #fff; background: transparent; font: 500 15px inherit; }
.search-field input::placeholder { color: #7e8490; }
.search-field button { border: 0; color: #aeb4c2; background: transparent; cursor: pointer; }
.search-body { width: 100%; max-width: 1040px; margin: 0 auto; padding: 32px 28px 90px; overflow-y: auto; }
.search-section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.search-section-title h2 { margin: 0; font-size: 17px; }
.search-section-title button, .search-section-title span { border: 0; color: #838995; background: transparent; font: 500 11px inherit; cursor: pointer; }
.search-chips { min-height: 37px; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.search-chip { padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; color: #c7cad2; background: var(--panel); font: 500 12px inherit; cursor: pointer; }
.search-chip:hover { border-color: var(--accent); color: #fff; }
.search-empty-recent { color: #6f7582; font-size: 12px; }
.popular-title { margin-top: 42px; }
.popular-keywords { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 30px; margin-top: 14px; }
.popular-keyword { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 9px; padding: 10px 4px; border: 0; border-bottom: 1px solid rgba(255,255,255,.045); color: #d8dae0; background: transparent; text-align: left; font: 500 13px inherit; cursor: pointer; }
.popular-keyword b { color: #ff5c83; font-size: 11px; }
.search-result-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 15px; }
.search-result-meta b { font-size: 17px; }
.search-result-meta span { color: var(--muted); font-size: 11px; }
.search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; }
.search-results .card .poster-bg { aspect-ratio: 3 / 4.1; }

@media (min-width: 1180px) {
  .home-feed { padding: 30px 42px 130px; }
  .home-rail { grid-auto-columns: clamp(176px, 14vw, 220px); gap: 18px; }
  .home-section { margin-top: 42px; }
}

@media (max-width: 700px) {
  .home-topbar { min-height: 58px; padding: 8px 12px; }
  .home-topbar .brand { font-size: 14px; }
  .home-topbar .brand .dot { width: 8px; height: 8px; }
  .home-actions { gap: 3px; }
  .install-pill { display: none; }
  .top-action, .account-trigger { width: 36px; height: 36px; }
  .top-action { font-size: 25px; }
  .home-feed { padding: 12px 14px 100px; }
  .home-hero { min-height: 340px; aspect-ratio: .98 / 1; border-radius: 19px; }
  .home-hero-bg { inset: 0; width: 100%; height: 100%; object-position: center top; }
  .home-hero::after { background: linear-gradient(0deg, rgba(5,6,10,.98) 0%, rgba(5,6,10,.75) 43%, rgba(5,6,10,.05) 76%); }
  .home-hero-copy { left: 20px; right: 20px; top: auto; bottom: 22px; width: auto; transform: none; }
  .home-hero h1 { font-size: 27px; }
  .home-hero p { margin: 9px 0 15px; font-size: 12px; -webkit-line-clamp: 2; }
  .hero-kicker { margin-bottom: 9px; }
  .hero-start, .hero-search { height: 39px; padding-inline: 14px; }
  .hero-meta { display: none; }
  .topic-strip { padding-top: 18px; }
  .home-section { margin-top: 28px; }
  .home-section-head { align-items: flex-end; margin-bottom: 11px; }
  .home-section-head h2 { font-size: 18px; }
  .home-section-head p { max-width: 280px; font-size: 10px; line-height: 1.4; }
  .home-rail { grid-auto-columns: 148px; gap: 11px; margin-right: -14px; padding-right: 14px; }
  .home-rail .card { border-radius: 14px; }
  .home-rail .card .poster-info { padding: 9px 10px 11px; }
  .home-rail .card .cname { font-size: 14px; }
  .home-rail .card .ctag { font-size: 10px; }
  .home-recent-rail { grid-auto-columns: 276px; }
  .home-popover { position: fixed; top: 54px; right: 8px; max-height: calc(100dvh - 126px); }
  .search-head { grid-template-columns: 36px minmax(0, 1fr); gap: 7px; min-height: 60px; padding: 7px 10px; }
  .search-field { grid-column: 2; height: 43px; }
  .search-body { padding: 25px 16px 96px; }
  .popular-keywords { grid-template-columns: 1fr; }
  .search-results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
}

/* Calm, consistent surfaces across the library, solo chat and shared play. */
:root {
  --bg: #131719;
  --panel: #1a2023;
  --panel-2: #232b2d;
  --border: #333e40;
  --accent: #b8cba6;
  --accent-2: #a0b691;
  --user-bubble: #344a3a;
  --bot-bubble: #222c2a;
}
.dot, .account-status .status-dot { box-shadow: none; }
.home-feed { background: var(--bg); }
.home-hero { min-height: 280px; max-height: 320px; aspect-ratio: 3.1 / 1; border-radius: 12px; box-shadow: none; }
.home-hero-bg { inset: 0; width: 100%; height: 100%; transform: none; }
.home-hero h1 { font-size: clamp(27px, 2.8vw, 39px); line-height: 1.17; }
.hero-kicker { color: #cbd6bf; letter-spacing: .02em; }
.hero-kicker::before { display: none; }
.hero-start { background: #c3d3b5; color: #19231a; box-shadow: none; border-radius: 8px; }
.hero-search { border-radius: 8px; backdrop-filter: none; }
.home-section-head .eyebrow { color: #a8b89f; }
.topic-chip:hover, .topic-chip.active { border-color: #829575; background: #303d2b; }
.fab { background: #c3d3b5; color: #19231a; box-shadow: 0 4px 14px #0004; border-radius: 14px; }
.recent-av, .avatar, .card div.poster-bg.emoji { background: #34433a; }
.account-profile-row { box-shadow: none; }
.popular-keyword b { color: #bbcca9; }
.account-status .status-dot { background: #aabe9a; }
#sendBtn { background: #c3d3b5; color: #19231a; }
.btn:not(.ghost):not(.danger), .panel-btn:not(.ghost):not(.danger) { background: #b8cba6; color: #19231a; }
.account-menu-icon { background: #26302a; color: #c3d3b5; }
.home-rail .card { border-radius: 11px; }
@media (max-width: 700px) {
  .home-hero { min-height: 280px; max-height: 320px; aspect-ratio: 1.25 / 1; border-radius: 12px; }
  .home-hero h1 { font-size: 26px; }
  .home-hero-copy { left: 20px; right: 20px; bottom: 20px; }
  .home-hero p { margin: 8px 0 14px; }
}
.tool-btn.active, .tool-btn.active svg, .pi-badge, .persona-detail-scope, .creator-step.active b { color: #19231a; }
.persona-item.selected, .segmented input:checked + span { background: #2c3829; }
.suggested-replies button { color: #c8d9bb; background: #293226; }
.preview-art { background-color: #34483a; }


/* Tags are text controls shared by creation and discovery. */
.tag-field { min-width: 0; }
.tag-editor { border: 1px solid var(--border); border-radius: 10px; padding: 10px; background: var(--bg); }
.tag-editor:focus-within { border-color: var(--accent); }
.tag-editor-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.editable-tag { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 5px 4px 9px; border: 1px solid #52634a; border-radius: 6px; color: #d4dfc9; background: #2d3929; font-size: 12px; }
.editable-tag > span { overflow-wrap: anywhere; }
.editable-tag button { border: 0; background: transparent; color: #bdcbb4; font-size: 19px; line-height: 1; min-width: 24px; min-height: 24px; padding: 0; cursor: pointer; }
.tag-editor-entry { display: flex; align-items: center; gap: 8px; }
.tag-editor-chips:not(:empty) + .tag-editor-entry { margin-top: 8px; }
.tag-editor-entry input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 6px 2px; background: transparent; color: var(--text); font: inherit; font-size: 13px; box-shadow: none; }
.tag-editor-entry button { flex-shrink: 0; border: 1px solid #53614d; border-radius: 5px; padding: 6px 9px; background: #2b3527; color: #d1dec5; font-size: 11px; cursor: pointer; }
.tag-hint { color: var(--muted); font-size: 11px; line-height: 1.65; font-weight: 400; margin: 0; }
.tag-error { margin: 0; color: #efb6a0; font-size: 12px; font-weight: 400; line-height: 1.7; }
.tag-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-suggestion { padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: #a9b6a4; cursor: pointer; font-size: 10px; max-width: 100%; overflow-wrap: anywhere; }
.tag-suggestion:hover { background: #293426; border-color: #78866f; }
.tag-suggestion:disabled { opacity: .4; cursor: default; }
.character-tags { display: flex; gap: 5px; overflow-x: auto; overflow-y: hidden; margin-top: 9px; scrollbar-width: thin; scrollbar-color: #6b7863 transparent; padding-bottom: 2px; }
.character-tag { flex-shrink: 0; max-width: 135px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 6px; border: 1px solid #64745c88; border-radius: 5px; color: #dde8d5; background: #1c261de8; font-size: 10px; line-height: 1.4; cursor: pointer; }
.character-tag:hover { border-color: #b1c3a1; background: #354a2e; }
.search-tag-section { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.search-tag-section > .tag-hint { margin-top: 10px; }
.search-selected-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.search-selected-tags:not(:empty) { margin-top: 14px; }
.selected-search-tag { border: 1px solid #839a70; border-radius: 7px; background: #34462c; color: #e0ecd5; padding: 7px 10px; font-size: 12px; cursor: pointer; overflow-wrap: anywhere; max-width: 100%; }
.search-tag-input-label { display: block; margin-top: 16px; }
.search-tag-input-label input { width: min(100%, 320px); border: 1px solid var(--border); border-radius: 7px; padding: 9px 11px; outline: 0; background: #1b2420; color: var(--text); font-size: 12px; }
.search-tag-input-label input:focus { border-color: var(--accent); }
.search-tag-input-label input::placeholder { color: #8e9a88; }
.search-tag-facets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; max-height: 145px; overflow-y: auto; padding: 3px; }
.search-tag-facet { display: flex; align-items: center; gap: 7px; max-width: 100%; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: #b6c1b1; padding: 7px 9px; font-size: 12px; cursor: pointer; overflow-wrap: anywhere; }
.search-tag-facet small { font-size: 10px; color: #82907b; }
.search-tag-facet[aria-pressed="true"] { color: #e0ecd5; border-color: #8fa67f; background: #34462c; }
.search-tag-facet[aria-pressed="true"] small { color: #b2c3a5; }
.search-tag-facet:hover { border-color: #8fa67f; }
@media (max-width: 700px) {
  .tag-editor-entry input, .search-tag-input-label input { font-size: 16px; }
  .editable-tag button { min-width: 30px; min-height: 30px; }
  .character-tag { min-height: 29px; padding: 6px 7px; max-width: 110px; }
  .search-tag-section { margin-bottom: 24px; padding-bottom: 20px; }
  .search-tag-facets { max-height: 130px; }
  .search-tag-facet, .selected-search-tag { min-height: 36px; font-size: 11px; }
}
/* Saving stays visible in both the library and the play screen. */
.server-save-bar { display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding:7px 16px; flex-shrink:0; font-size:12px; color:#aaa; border-bottom:1px solid #333; }
.server-save-bar > span { flex:1; min-width:120px; }
.server-save-bar button, .server-device-dialog button { background:#25252b; color:#eee; border:1px solid #494951; border-radius:7px; padding:6px 10px; cursor:pointer; }
.server-save-bar [hidden] { display:none; }
.server-save-bar[data-state="error"] { color:#ffbaa8; }
.server-device-dialog { width:min(460px,90vw); box-sizing:border-box; border:1px solid #444; border-radius:14px; background:#18181d; color:#eee; padding:24px; }
.server-device-dialog p { line-height:1.6; overflow-wrap:anywhere; }
.server-device-dialog label { display:block; margin-top:20px; }
.server-device-dialog input { width:100%; box-sizing:border-box; margin:8px 0; padding:10px; background:#222229; color:#eee; border:1px solid #555; border-radius:7px; }
#serverDeviceCode { font-family:monospace; font-size:17px; }
#serverDeviceError { color:#ffbaa8; }
