:root {
  --bg: #14110f;
  --panel: #1e1a17;
  --panel-2: #272220;
  --accent: #c9962e;
  --accent-2: #7a4b2b;
  --text: #ece5da;
  --muted: #9a8f81;
  --gm: #e8ddc7;
  --player: #8fc7e8;
  --dice: #f0c86b;
  --state: #7fd48a;
  --danger: #e57373;
  --border: #3a322c;
  --topbar: 52px; /* 상단 고정 유저바 높이만큼 콘텐츠를 내리는 여백 */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* 랜딩 배경 영상 + 어둡게 덮는 오버레이 (카드 가독성 확보) */
.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at center, rgba(20, 17, 15, 0.35) 0%, rgba(20, 17, 15, 0.72) 100%),
    linear-gradient(rgba(20, 17, 15, 0.5), rgba(20, 17, 15, 0.7));
}
/* 게임 플레이 중에는 배경 영상을 숨겨 로그에 집중 + 자원 절약 */
body.in-game .bg-video,
body.in-game .bg-overlay {
  display: none;
}

.hidden {
  display: none !important;
}

/* ---------- 캐릭터 생성 ---------- */
.setup {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}
.setup-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
/* 갤러리·세계관 편집처럼 항목이 많은 화면은 더 넓게 */
.setup-card.wide {
  max-width: 880px;
}
.setup-card h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}
.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 0.9rem;
}
.setup-card label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 600;
  font-size: 0.9rem;
}
input[type='text'],
input[type='password'],
select#setProvider {
  width: 100%;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
input[type='text']:focus,
input[type='password']:focus,
select#setProvider:focus {
  outline: none;
  border-color: var(--accent);
}
select#setProvider {
  cursor: pointer;
}

/* 인증 / 사용자 바 / 설정 */
.auth-error {
  background: #3a1f1f;
  border: 1px solid #5c2b2b;
  color: #f0b0b0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.85rem;
  margin-top: 14px;
}
.auth-toggle {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 16px 0 0;
}
.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.auth-toggle a:hover {
  text-decoration: underline;
}
.auth-terms {
  margin-top: 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}
.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.auth-check input {
  width: auto;
  margin: 3px 0 0;
  flex: none;
  cursor: pointer;
}
.auth-terms a,
.auth-legal a {
  color: var(--accent);
  text-decoration: none;
}
.auth-terms a:hover,
.auth-legal a:hover {
  text-decoration: underline;
}
.auth-legal {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.user-bar {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 26, 23, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  backdrop-filter: blur(4px);
}
.user-bar #userName {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  padding: 0 4px;
}
.mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--accent);
  color: #211a0e;
}

/* 캐릭터 챗 화면 */
.chat-screen {
  display: flex;
  height: 100vh;
  box-sizing: border-box;
  padding-top: var(--topbar); /* 고정 유저바와 겹치지 않게 */
}
.chat-screen .log-pane {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.setup-card textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 12px;
  margin-bottom: 4px;
  resize: vertical;
}
.setup-card textarea:focus {
  outline: none;
  border-color: var(--accent);
}
/* 캐릭터 편집기 */
.cp-characters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.cp-char {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.cp-char-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.cp-char-head input {
  flex: 1;
  margin-bottom: 0;
}
.cp-char-del {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  flex: 0 0 auto;
}
.cp-char-del:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.cp-char textarea {
  margin-bottom: 0;
}
.cp-add {
  margin-bottom: 8px;
}
/* 이미지 편집기 */
.cp-images {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.cp-image {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.cp-image img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  flex: 0 0 auto;
  background: #000;
}
.cp-image-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.cp-image-fields input {
  margin-bottom: 0;
}
/* 공개 설정 */
.publish-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 6px;
}
.publish-row select {
  flex: 1;
  margin-bottom: 0;
}
.publish-row button {
  flex: 0 0 auto;
}
/* 갤러리 */
.gallery-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
/* 홈: 모드 선택 카드 */
.home-choices {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.home-card {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.home-card:hover {
  border-color: var(--accent);
}
.home-card .hc-icon {
  font-size: 1.8rem;
}
.home-card .hc-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}
.home-card .hc-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
/* 갤러리 정렬·태그 필터 */
.gallery-controls {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.gallery-controls select {
  width: auto;
  margin-bottom: 0;
  flex: 0 0 auto;
}
.tag-filter,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
}
.tag-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.tag-chip:hover {
  color: var(--text);
  border-color: var(--accent-2);
}
.tag-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #211a0e;
  font-weight: 700;
}
.tag-chip.static {
  cursor: default;
  color: var(--accent);
}
/* 프로필 합계 */
.profile-totals {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.pt-item {
  flex: 1 1 90px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.pt-num {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}
.pt-key {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}
/* 상세 모달: 추천 + 댓글 */
.detail-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 18px;
}
.detail-actions button {
  flex: 1;
  width: auto;
  margin-top: 0;
}
#dtLike.liked {
  color: var(--danger);
  border-color: var(--danger);
}
.comment-list {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.comment {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  margin-bottom: 6px;
}
.comment .c-head {
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 3px;
}
.comment .c-body {
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment .c-del {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
}
.comment .c-del:hover {
  color: var(--danger);
}
.comment-form {
  display: flex;
  gap: 8px;
}
.comment-form input {
  flex: 1;
  margin-bottom: 0;
}
.comment-form button {
  width: auto;
  margin-top: 0;
  flex: 0 0 auto;
  padding: 10px 16px;
}
.gallery-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 10px 0;
}
.gallery-card-item {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap; /* 버튼이 많아지면 아래 줄로 */
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.gallery-card-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
  background: #000;
}
.gi-body {
  flex: 1 1 200px; /* 최소 폭을 확보해 제목이 한 글자씩 쪼개지지 않게 */
  min-width: 0;
}
.gi-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.gi-meta {
  font-size: 0.74rem;
  color: var(--accent);
  margin-bottom: 4px;
}
.gi-sum {
  font-size: 0.8rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* button.primary의 width:100%를 이기려면 특이성을 높여야 한다(안 그러면 버튼이 카드를 다 먹음) */
.gallery-card-item .gi-play {
  width: auto;
  margin-top: 0;
  padding: 8px 16px;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.82rem;
}
.gi-title {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
/* 대화 중 표시되는 장면 이미지 */
.chat-img {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.disclaimer {
  margin-top: 16px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--muted);
}
.disclaimer b {
  color: var(--accent);
}
.consent-list {
  margin: 8px 0;
  padding-left: 18px;
}
.consent-list li {
  margin-bottom: 4px;
}
.consent-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  cursor: pointer;
}
.consent-line input {
  width: auto;
  margin: 2px 0 0;
  flex: none;
  cursor: pointer;
}
.class-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.class-card {
  text-align: left;
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s;
}
.class-card:hover {
  border-color: var(--accent-2);
}
.class-card.selected {
  border-color: var(--accent);
}
.class-card .cname {
  font-weight: 700;
  font-size: 1rem;
}
.class-card .cdesc {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 3px 0 5px;
  line-height: 1.4;
}
.class-card .cstats {
  font-size: 0.72rem;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  line-height: 1.4;
}
.class-card .cmoves {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
/* 위저드 스텝 */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.step {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  padding: 7px 4px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.step.active {
  color: #211a0e;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}
.step.done {
  color: var(--accent);
  border-color: var(--accent-2);
}
.step-panel {
  min-height: 60px;
}
.opt {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.82rem;
}
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 8px 0;
}
.hint.error {
  color: var(--danger);
}
.stat-mode {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.toggle {
  flex: 1;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
}
.toggle.active {
  border-color: var(--accent);
  color: var(--text);
}
.stat-assign {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-assign .srow {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stat-assign .srow .k {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-assign .srow .v {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.stat-assign select {
  width: 100%;
  padding: 5px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 1rem;
  text-align: center;
}
/* 장비 선택 */
.base-gear {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.6;
}
.base-gear .bg-label {
  color: var(--accent);
}
.gear-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}
.gear-group-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.gear-group-opts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.gear-armor-note {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  padding-top: 4px;
}
.gear-tags {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 3px;
}
.gear-chip.selected .gear-tags {
  color: var(--dice);
}
.weapon-box {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 0.85rem;
}
.weapon-box .wb-label {
  color: var(--muted);
  font-size: 0.78rem;
}
.weapon-box .wb-tags {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--dice);
}
.coin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 7px 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}
.coin-row .coin-label {
  color: var(--muted);
  font-size: 0.8rem;
}
.coin-row b {
  color: var(--accent);
  font-size: 0.95rem;
}
.gear-chip {
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  text-align: center;
  color: var(--text);
  transition: border-color 0.15s;
}
.gear-chip:hover:not(.disabled) {
  border-color: var(--accent-2);
}
.gear-chip.selected {
  border-color: var(--accent);
  background: #2a2410;
}
.gear-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.learn-moves {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.learn-move {
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 7px;
  padding: 8px 11px;
}
.learn-move .lm-name {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.88rem;
}
.learn-move .lm-desc {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
  line-height: 1.4;
}

.sheet-summary {
  margin-top: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.sheet-summary .lbl {
  color: var(--muted);
}
.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  align-items: stretch;
}
/* 두 버튼의 높이·세로위치를 맞춘다(primary의 margin-top:24px 상쇄). */
.wizard-nav .ghost,
.wizard-nav .primary {
  margin-top: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wizard-nav .ghost {
  flex: 0 0 auto;
}
.wizard-nav .primary {
  flex: 1;
}

button {
  font-family: inherit;
}
button.primary {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  background: var(--accent);
  color: #211a0e;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
button.primary:hover {
  filter: brightness(1.08);
}
button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 게임 레이아웃 ---------- */
.game {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  height: 100vh;
  box-sizing: border-box;
  padding-top: var(--topbar); /* 고정 유저바와 겹치지 않게 */
}

/* 좌측 필드 패널 (적/동료) */
.field-pane {
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.field-pane h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.field-pane h3:not(:first-child) {
  margin-top: 20px;
}
.npc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.npc {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 8px 11px;
}
.npc.enemy {
  border-left-color: var(--danger);
}
.npc.ally {
  border-left-color: var(--state);
}
.npc .n-name {
  font-weight: 700;
  font-size: 0.9rem;
}
.npc .n-hp {
  font-size: 0.78rem;
  color: var(--accent);
  font-family: ui-monospace, monospace;
}
.npc .n-note {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.npc-list .empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.82rem;
}
.log-pane {
  display: flex;
  flex-direction: column;
  /* 상단 유저바 여백 때문에 실제 칸은 100vh보다 작다 → 칸을 채우도록 100% */
  height: 100%;
  min-height: 0;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.log-pane .log {
  min-height: 0; /* flex 자식이 내용보다 작아질 수 있게 (입력창이 밀려나지 않도록) */
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  background: var(--panel);
}
.header-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  align-items: center;
}
/* 모델명이 길어도 헤더가 넘치지 않게 버튼 라벨 말줄임 */
#gameModelBtn,
#chatModelBtn {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 슬롯(저장 게임) 칩 바 */
.slot-bar {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  overflow-x: auto;
  min-width: 0;
}
.slot-chip {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel-2);
}
.slot-chip.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.slot-chip .slot-main {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slot-chip.active .slot-main {
  color: var(--accent);
}
.slot-chip .slot-main:hover {
  color: var(--text);
}
.slot-chip .slot-del {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0 7px;
  cursor: pointer;
}
.slot-chip .slot-del:hover {
  color: var(--danger);
}
#gameModelBtn.warn {
  border-color: var(--danger);
  color: var(--danger);
}
#gameModelBtn.warn:hover {
  color: var(--danger);
}
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
button.ghost:hover {
  color: var(--text);
  border-color: var(--accent-2);
}
button.ghost.pulse {
  color: var(--accent);
  border-color: var(--accent);
  animation: btnPulse 1.4s ease-in-out infinite;
}
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 160, 90, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(212, 160, 90, 0); }
}

.log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}
.log-inner {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.entry {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.entry.gm {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--gm);
}
.entry.player {
  align-self: flex-end;
  background: #1b2b36;
  border: 1px solid #2c4657;
  color: var(--player);
}
.entry.dice {
  align-self: center;
  background: #2a2410;
  border: 1px solid #4a3f18;
  color: var(--dice);
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: 0.9rem;
  text-align: center;
  max-width: 96%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dice-faces {
  display: flex;
  gap: 12px;
}
.die {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--dice);
}
.entry.dice.rolling .die {
  animation: dieTumble 0.22s infinite;
}
@keyframes dieTumble {
  0%, 100% { transform: rotate(-14deg) scale(1); }
  50% { transform: rotate(14deg) scale(1.14); }
}
.entry.dice.settled .die {
  animation: dieLand 0.45s ease;
}
@keyframes dieLand {
  0% { transform: scale(1.45); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.entry.dice.tier-strong .die { color: var(--state); }
.entry.dice.tier-miss .die { color: var(--danger); }
.entry.dice.tier-weak .die { color: var(--dice); }
.dice-caption { font-size: 0.86rem; }
.entry.state {
  align-self: center;
  background: #16281a;
  border: 1px solid #2c4a33;
  color: var(--state);
  font-size: 0.88rem;
}
.entry.system {
  align-self: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.thinking {
  padding: 6px 18px 10px;
  color: var(--accent);
  font-size: 0.85rem;
  font-style: italic;
  font-variant-numeric: tabular-nums; /* 초 숫자가 흔들리지 않게 */
  animation: thinkPulse 1.6s ease-in-out infinite;
}
@keyframes thinkPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 10px;
}
.suggestion-chip {
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  color: var(--text);
  border-radius: 16px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.suggestion-chip:hover {
  border-color: var(--accent);
  background: #2a2410;
}

.input-bar {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.suggest-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.input-bar input {
  flex: 1;
}
.input-bar button.primary {
  width: auto;
  margin: 0;
  padding: 11px 22px;
}

/* ---------- 상태창 ---------- */
.status-pane {
  background: var(--panel);
  padding: 18px;
  overflow-y: auto;
}
.status-pane h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  /* 긴 "이름 · 클래스"가 유저바 아래에서 잘리지 않게 줄바꿈 허용 */
  line-height: 1.3;
  word-break: keep-all;
}
.status-pane h3 {
  margin: 20px 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.level-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.level-badge {
  background: var(--accent);
  color: #211a0e;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  white-space: nowrap;
}
.xp-wrap {
  flex: 1;
}
.xp-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.xp-bar-outer {
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.xp-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6a8fc9, #c9962e);
  transition: width 0.4s ease;
}

.hp-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: relative;
}

/* ---------- 전투 효과 / 애니메이션 ---------- */
/* 주사위 박스 (눈 굴림은 위 .die 애니메이션에서 처리) */
.entry.dice.settled {
  animation: dicePop 0.4s ease;
}
@keyframes dicePop {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.entry.dice.tier-strong {
  border-color: var(--state);
  box-shadow: 0 0 14px rgba(127, 212, 138, 0.5);
}
.entry.dice.tier-weak {
  border-color: var(--dice);
  box-shadow: 0 0 12px rgba(240, 200, 107, 0.4);
}
.entry.dice.tier-miss {
  border-color: var(--danger);
  box-shadow: 0 0 14px rgba(229, 115, 115, 0.5);
}

/* 피해/회복 부동 숫자 */
.float-num {
  position: absolute;
  right: 14px;
  top: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  pointer-events: none;
  animation: floatUp 1s ease forwards;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.float-num.dmg { color: var(--danger); }
.float-num.heal { color: var(--state); }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(8px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-24px); }
}

/* 피해 시 상태창 흔들림 + HP바 번쩍 */
.status-pane.shake {
  animation: shakeX 0.45s;
}
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
.hp-bar-inner.flash-dmg { animation: hpDmg 0.6s; }
.hp-bar-inner.flash-heal { animation: hpHeal 0.6s; }
@keyframes hpDmg {
  0% { filter: brightness(2.4) saturate(2); }
  100% { filter: none; }
}
@keyframes hpHeal {
  0% { filter: brightness(1.7) hue-rotate(20deg); }
  100% { filter: none; }
}

/* NPC 카드 등장 */
.npc { animation: npcIn 0.35s ease; }
@keyframes npcIn {
  0% { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}
.hp-label {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 6px;
}
.hp-bar-outer {
  height: 14px;
  background: #3a1f1f;
  border-radius: 7px;
  overflow: hidden;
}
.hp-bar-inner {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d15a5a, #7fd48a);
  transition: width 0.4s ease;
}
.armor {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stat .k {
  font-size: 0.7rem;
  color: var(--muted);
}
.stat .v {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.inventory {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inventory li {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 0.88rem;
}
.inventory li.empty {
  color: var(--muted);
  font-style: italic;
  border-style: dashed;
}
.moves {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.moves li {
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 0.85rem;
}
.moves li .mname {
  font-weight: 700;
  color: var(--accent);
}
.moves li .mdesc {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.moves li.empty {
  color: var(--muted);
  font-style: italic;
  border-style: dashed;
  border-color: var(--border);
}

/* 레벨업 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--accent-2);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
}
.modal-card h2 {
  margin: 0 0 4px;
}
.modal-sub {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}
/* 무료 체험 모드 유의사항 박스 */
.free-notice {
  margin: 10px 0 4px;
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}
.free-notice b {
  color: var(--text);
}
.free-notice ul {
  margin: 6px 0 6px;
  padding-left: 18px;
}
.free-notice li {
  margin-bottom: 3px;
}
.free-notice .fn-good {
  color: var(--state);
}
.free-notice .fn-warn {
  color: var(--dice);
}
.free-notice a {
  color: var(--accent);
}
.model-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px 0 8px;
}
.model-actions button {
  flex: 1 1 auto;
  font-size: 0.78rem;
}
.modal-card h3 {
  margin: 18px 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.lu-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.lu-stat {
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
}
.lu-stat:hover:not(.disabled) {
  border-color: var(--accent-2);
}
.lu-stat.selected {
  border-color: var(--accent);
}
.lu-stat.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.lu-stat .k {
  font-size: 0.72rem;
  color: var(--muted);
}
.lu-stat .v {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.lu-moves {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lu-move {
  background: var(--panel-2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.lu-move:hover {
  border-color: var(--accent-2);
}
.lu-move.selected {
  border-color: var(--accent);
}
.lu-move .mname {
  font-weight: 700;
}
.lu-move .mdesc {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}
.lu-move.none {
  font-style: italic;
  color: var(--muted);
}
.flash {
  animation: flash 0.9s ease;
}
@keyframes flash {
  0% {
    background: var(--accent);
    color: #211a0e;
  }
  100% {
  }
}
.model-note {
  margin-top: 24px;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

@media (max-width: 900px) {
  .game {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
  }
  .log-pane {
    order: 0;
    border-right: none;
  }
  .field-pane {
    order: 1;
    max-height: 28vh;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .status-pane {
    order: 2;
    max-height: 40vh;
    border-top: 1px solid var(--border);
  }
}

/* ---------- 운영자 접속 통계 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.stat-card strong {
  display: block;
  font-size: 22px;
  color: var(--accent);
  line-height: 1.2;
}
.stat-card span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.stat-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 88px;
  padding: 6px 4px 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}
.stat-bar {
  flex: 1 1 0;
  min-width: 14px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
}
.stat-bar i {
  display: block;
  width: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px 2px 0 0;
}
.stat-bar span {
  font-size: 10px;
  color: var(--muted);
  flex: 0 0 auto;
}

/* ==========================================================================
   캐릭터 챗 전용 앱 셸  (body.app-chat)
   --------------------------------------------------------------------------
   챗을 "TRPG 앱 위에 뜬 패널"이 아니라 독립 앱처럼 보이게 하는 레이어다.
   갤러리를 홈으로 두고 하단 탭으로 이동하며, 카드 껍데기(가운데 정렬·최대폭·
   드롭섀도)를 벗겨 화면을 꽉 채운다. 모바일 기준으로 잡고 넓은 화면은 아래쪽
   미디어쿼리에서 폭만 제한한다.
   play.html 은 이 클래스가 없으므로 전혀 영향받지 않는다.
   ========================================================================== */

body.app-chat {
  --topbar-h: calc(52px + env(safe-area-inset-top));
  --tabbar-h: calc(56px + env(safe-area-inset-bottom));
  height: 100vh;      /* dvh 미지원 브라우저 폴백 */
  height: 100dvh;     /* 모바일 주소창 접힘까지 따라간다 */
  overflow: hidden;
  overscroll-behavior: none;
}

/* 챗에서는 배경 영상을 쓰지 않는다 — 떠 있는 느낌의 주범 */
body.app-chat .bg-video,
body.app-chat .bg-overlay {
  display: none;
}

/* ---------- 상단 바: 떠 있는 알약 → 화면 폭 앱 바 ---------- */
body.app-chat .user-bar {
  top: 0;
  left: 0;
  right: 0;
  border-radius: 0;
  border-width: 0 0 1px;
  background: var(--panel);
  backdrop-filter: none;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  justify-content: flex-end;
  gap: 6px;
}
/* 홈·모드토글·로그아웃은 프로필 탭으로 옮겼다 (앱 안에 앱이 있는 느낌 제거) */
body.app-chat #homeBtn,
body.app-chat .mode-toggle,
body.app-chat #logoutBtn {
  display: none;
}

/* ---------- 화면(스크린) 공통: 카드 껍데기 벗기기 ---------- */
body.app-chat .setup {
  display: block;
  height: 100dvh;
  padding: 0;
}
body.app-chat .setup-card,
body.app-chat .setup-card.wide {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--topbar-h) + 14px) 16px calc(var(--tabbar-h) + 24px);
}
body.app-chat .setup-card h1 {
  font-size: 1.35rem;
}
body.app-chat .subtitle {
  margin-bottom: 18px;
}

/* 설정 폼의 저장/취소 바는 길어진 폼 아래에 붙여둔다 */
body.app-chat .sticky-nav {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  padding: 12px 0 4px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}

/* ---------- 대화 화면: 전체 화면 점유 ---------- */
/* 대화 중에는 상단 유저바를 감춘다 — 헤더가 두 겹으로 쌓여 대화가 밀려났다.
   뒤로·이름·모델·편집이 대화 헤더에 다 있어서 유저바가 할 일이 없다. */
body.app-chat.chat-open .user-bar {
  display: none;
}
body.app-chat .chat-screen {
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
}
body.app-chat .chat-screen .log-pane {
  max-width: none;
  border-left: 0;
  border-right: 0;
}
body.app-chat .log-header {
  gap: 8px;
  padding: 8px 10px;
}
/* 대화 상대 이름 — 예전 슬롯 칩 자리를 대신한다 */
.chat-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}
.icon-btn {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:hover {
  background: var(--panel-2);
}
/* 입력창은 홈 인디케이터를 피한다 */
body.app-chat .input-bar {
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
/* 좁은 화면에서는 모델명이 헤더를 다 먹어 캐릭터 이름이 "안…"으로 잘렸다.
   모델 버튼은 아이콘만 남기고 남는 폭을 이름에 준다. */
@media (max-width: 560px) {
  body.app-chat #chatModelLabel {
    display: none;
  }
  body.app-chat #chatModelBtn {
    max-width: none;
    padding-left: 10px;
    padding-right: 10px;
  }
  body.app-chat .chat-title {
    font-size: 1.02rem;
    font-weight: 700;
  }
}

/* ---------- 하단 탭바 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 2px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
}
.tabbar .tab .ti {
  font-size: 1.2rem;
  line-height: 1;
}
.tabbar .tab.active {
  color: var(--accent);
}
/* 대화 중에는 탭바를 숨겨 대화가 화면을 온전히 쓰게 한다 */
body.app-chat.chat-open .tabbar {
  display: none;
}

/* ---------- 내 대화 목록 ---------- */
.chats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.chat-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.chat-row.active {
  border-color: var(--accent);
}
.chat-row .cr-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 14px 14px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-row .cr-del {
  flex: 0 0 auto;
  background: none;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0 15px;
  cursor: pointer;
}
.chat-row .cr-del:hover {
  color: var(--danger);
}
button.primary.block {
  display: block;
  width: 100%;
}

/* ---------- 프로필의 링크 행 ---------- */
.link-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.link-row:hover {
  border-color: var(--accent-2);
}
.link-row.danger {
  color: var(--danger);
}

/* ---------- 작품 상세: 모바일에서는 바텀시트 ---------- */
body.app-chat .modal-overlay {
  align-items: flex-end;
}
body.app-chat .modal-card.sheet {
  width: 100%;
  max-width: none;
  max-height: 88dvh;
  border-radius: 18px 18px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

/* ---------- 넓은 화면: 폭만 제한하고 앱 셸은 유지 ---------- */
@media (min-width: 900px) {
  body.app-chat .setup-card,
  body.app-chat .setup-card.wide {
    max-width: 760px;
    margin: 0 auto;
  }
  body.app-chat .chat-screen .log-pane {
    max-width: 860px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .tabbar .tab {
    flex: 0 1 190px;
    flex-direction: row;
    gap: 8px;
    font-size: 0.82rem;
  }
  .tabbar {
    justify-content: center;
  }
  body.app-chat .modal-overlay {
    align-items: center;
  }
  body.app-chat .modal-card.sheet {
    max-width: 620px;
    max-height: 86dvh;
    border-radius: 14px;
  }
  .sheet-grip {
    display: none;
  }
}

/* ---------- 갤러리 카드: 큰 커버 이미지의 세로형 카드 ----------
   기존 카드는 72px 썸네일 + 한 줄 텍스트의 가로형이라 피드가 휑해 보였다.
   마크업(img + .gi-body + 버튼들)은 그대로 두고 배치만 뒤집는다. */
body.app-chat .gallery-card-item {
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
}
body.app-chat .gallery-card-item img {
  flex: 0 0 auto;
  /* 카드 패딩을 음수 마진으로 되물려 이미지가 위쪽을 꽉 채우게 한다.
     커버를 등록하지 않은 항목도 기본 커버(cover-default.svg)가 들어오므로
     모든 카드가 같은 높이로 선다. */
  width: calc(100% + 24px);
  height: auto;
  aspect-ratio: 16 / 10;
  margin: -12px -12px 6px;
  border-radius: 14px 14px 0 0;
}
body.app-chat .gi-body {
  flex: 1 1 100%;
}
body.app-chat .gi-title {
  font-size: 1.08rem;
  margin-bottom: 3px;
}
body.app-chat .gi-meta {
  font-size: 0.78rem;
  margin-bottom: 5px;
}
body.app-chat .gi-sum {
  font-size: 0.86rem;
}
/* 버튼은 남은 폭을 고르게 나눠 한 줄에 */
body.app-chat .gi-play {
  flex: 1 1 0;
  min-width: 0;
}
body.app-chat .gallery-list {
  gap: 14px;
}

/* 대표 이미지 지정 토글 (설정 폼의 이미지 행) */
.cp-cover-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 9px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.cp-cover-btn:hover {
  color: var(--accent);
  border-color: var(--accent-2);
}
.cp-cover-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #211a0e;
}

/* ---------- 구 duckdns 주소 종료 안내 ----------
   상단에 얇게 깔린다. 챗의 앱 셸은 상단바 높이를 --topbar-h 로 계산하므로
   배너가 떠 있는 동안 그만큼 밀어준다(안 그러면 유저바와 겹친다). */
.legacy-notice {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: var(--accent-2);
  color: #f6ecd9;
  font-size: 0.84rem;
  line-height: 1.45;
  border-bottom: 1px solid var(--accent);
}
.legacy-notice .ln-text {
  flex: 1 1 auto;
  word-break: keep-all;
}
.legacy-notice .ln-close {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid rgba(246, 236, 217, 0.35);
  color: inherit;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}
.legacy-notice .ln-close:hover {
  background: rgba(246, 236, 217, 0.15);
}

/* 배너가 있는 동안 고정 요소들을 아래로 민다 */
body.has-legacy-notice .user-bar {
  top: 42px;
}
body.app-chat.has-legacy-notice {
  --topbar-h: calc(94px + env(safe-area-inset-top));
}
body.app-chat.has-legacy-notice .user-bar {
  top: 42px;
}
body.app-chat.has-legacy-notice.chat-open .chat-screen {
  padding-top: calc(42px + env(safe-area-inset-top));
}

@media (max-width: 560px) {
  .legacy-notice {
    font-size: 0.78rem;
    padding-left: 12px;
    padding-right: 12px;
  }
}
