* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

svg.lucide {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  vertical-align: middle;
}

.dropdown-arrow svg.lucide,
.dice-emoji svg.lucide {
  width: 14px;
  height: 14px;
}

.bgm-mini-empty svg.lucide {
  width: 20px;
  height: 20px;
  color: white;
}

.sheet-open-btn svg.lucide {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}

input,
button,
select,
textarea {
  font-family: inherit;
}

/* Site palette — mapped onto the Kavalone dark game-portal tokens
   (see kavalone-tokens.css, loaded before this file). Old variable
   names are kept so every rule below still resolves correctly. */
:root {
  --primary: rgba(147, 169, 232, 0.14);
  --primary-mid: var(--periwinkle-deep, #5670c4);
  --primary-dark: var(--periwinkle-glow, #93a9e8);
  --text: var(--text-hi, #f3f1f7);
  --text-light: var(--text-mid, #b3aec2);
  --bg: #141319;
  --white: #17151c;
  --accent: var(--periwinkle-bright, #cfdaf7);
}

body {
  margin: 0;
  font-family: var(--font-body), "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg-void, #07070a);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: inherit;
}

/* ---------- Home page ---------- */

.home-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 32px 60px;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 32px;
  margin: -30px -32px 24px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0;
  box-shadow: none;
  border: none;
  border-bottom: 1px solid rgba(147, 169, 232, 0.14);
}

.site-header h1 {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-family: var(--font-display), serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--periwinkle-bright, #cfdaf7);
  text-shadow: 0 0 14px rgba(147, 169, 232, 0.35);
}

.auth-gate {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 900px 600px at 78% 15%, rgba(147, 169, 232, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 15% 85%, rgba(86, 112, 196, 0.14), transparent 60%),
    linear-gradient(160deg, #1a1820 0%, #0c0b10 45%, #050506 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 70;
}

.auth-gate.hidden {
  display: none;
}

.auth-gate-inner {
  text-align: center;
  color: var(--text-hi);
}

.auth-gate-inner h1 {
  margin: 0;
  font-family: var(--font-display), serif;
  font-size: clamp(48px, 7vw, 88px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 0 40px rgba(147, 169, 232, 0.4);
}

.auth-gate-inner p {
  margin-top: 14px;
  font-family: var(--font-display), serif;
  font-size: 14px;
  color: #7a8fd1;
  letter-spacing: 0.25em;
}

.auth-bar {
  position: relative;
  grid-column: 1;
  justify-self: start;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-size: 12px;
}

.auth-bar .auth-avatar-trigger {
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  line-height: 0;
  cursor: pointer;
}

.auth-bar .auth-user-name {
  color: var(--text);
  font-weight: bold;
  font-size: 12px;
}

.auth-bar button {
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid rgba(147, 169, 232, 0.35);
  background: rgba(147, 169, 232, 0.08);
  color: var(--periwinkle-bright, #cfdaf7);
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.auth-bar button:hover {
  background: rgba(147, 169, 232, 0.18);
  border-color: rgba(147, 169, 232, 0.7);
}

.auth-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: white;
  background: var(--periwinkle-deep, #5670c4);
}

.auth-bar .auth-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-bar .auth-icon-btn svg.lucide {
  width: 14px;
  height: 14px;
}

#account-settings-modal.account-settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 260px;
  z-index: 80;
  animation: dropdown-pop 0.15s ease-out;
}

.account-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.account-panel-header h3 {
  margin: 0;
}

.auth-error {
  color: var(--dice-fumble, #e0546b);
  font-size: 12px;
  margin: 8px 0 0;
}

.auth-switch-btn {
  width: 100%;
  margin-top: 10px;
  border: none;
  background: none;
  color: var(--primary-dark);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.page-tab-bar {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 0 -32px 24px;
  padding: 0 32px;
  border-bottom: 1px solid rgba(147, 169, 232, 0.14);
  background: rgba(0, 0, 0, 0.2);
  overflow-x: auto;
  scrollbar-width: none;
}

.page-tab-bar::-webkit-scrollbar {
  display: none;
}

.page-tab {
  font-family: inherit;
  background: none;
  border: none;
  padding: 15px 24px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-faint, #726d80);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s;
}

@media (max-width: 480px) {
  .page-tab-bar {
    justify-content: flex-start;
  }

  .page-tab {
    padding: 14px 14px;
    font-size: 13px;
  }
}

.page-tab:hover {
  color: var(--text-hi);
}

.page-tab.active {
  color: var(--text-hi);
  border-bottom-color: var(--periwinkle-glow, #93a9e8);
  text-shadow: 0 0 14px rgba(147, 169, 232, 0.5);
}

.category-bar {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding-bottom: 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-light);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.category-tab:hover {
  color: var(--text-hi);
}

.category-tab.active {
  color: var(--periwinkle-glow, #93a9e8);
  font-weight: 700;
  border-bottom-color: var(--periwinkle-glow, #93a9e8);
}

#session-page {
  max-width: 900px;
  margin: 0 auto;
}

.create-room-box {
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 6px;
  padding: 18px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.create-room-box input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.room-type-picker {
  display: flex;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  overflow: hidden;
  width: fit-content;
}

.room-type-radio {
  display: none;
}

.room-type-label {
  padding: 9px 16px;
  border-radius: 0;
  border: none;
  font-size: 12px;
  font-weight: bold;
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.room-type-radio:checked + .room-type-label {
  background: var(--periwinkle-glow, #93a9e8);
  color: #0a0a0e;
  border-color: transparent;
}

.create-room-box button {
  flex-shrink: 0;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(147, 169, 232, 0.4);
  transition: box-shadow 0.2s;
}

.create-room-box button:hover {
  box-shadow: 0 0 24px rgba(147, 169, 232, 0.65);
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-card {
  background: linear-gradient(165deg, var(--panel-top, #1c1a22), #0a090d);
  border: 1px solid rgba(147, 169, 232, 0.18);
  border-radius: 6px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}

.room-card::before {
  content: "";
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, #2a2733, #2a2733 6px, #1a1720 6px, #1a1720 12px);
}

.room-card:hover {
  transform: translateX(3px);
  border-color: rgba(147, 169, 232, 0.55);
}

.room-card > div:first-child {
  flex: 1;
  min-width: 0;
}

.room-card .room-name {
  font-weight: bold;
  font-size: 15px;
  color: var(--text-hi);
}

.room-type-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--periwinkle-glow, #93a9e8);
  background: none;
  border: 1px solid currentColor;
  padding: 1px 7px;
  border-radius: 2px;
  vertical-align: middle;
}

.room-card .room-meta {
  font-size: 12px;
  color: #8b869a;
  margin-top: 4px;
}

.room-card .enter-badge {
  flex-shrink: 0;
  background: none;
  color: var(--periwinkle-glow, #93a9e8);
  padding: 6px 14px;
  border: 1px solid rgba(147, 169, 232, 0.35);
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-light);
  padding: 30px;
  font-size: 13px;
}

.gallery-grid .empty-hint,
.profile-set-list .empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
}

/* ---------- Room page ---------- */

.room-body {
  background: var(--bg-void, #07070a);
}

#room-app {
  max-width: 820px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-void-2, #050506);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  border-left: 1px solid rgba(147, 169, 232, 0.12);
  border-right: 1px solid rgba(147, 169, 232, 0.12);
}

.room-header {
  position: relative;
  min-height: 130px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(147, 169, 232, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #14121a;
  background-size: cover;
  background-position: center;
  transition: min-height 0.2s;
}

.room-header.has-image {
  border-bottom: none;
}

.room-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(6, 5, 8, 0.9) 8%, rgba(6, 5, 8, 0.15) 60%, rgba(6, 5, 8, 0.35) 100%);
  pointer-events: none;
}

.room-header.has-image::before {
  background: linear-gradient(0deg, rgba(6, 5, 8, 0.96) 8%, rgba(6, 5, 8, 0.35) 55%, rgba(6, 5, 8, 0.55) 100%);
}

.header-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.room-header .room-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-display), serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--text-hi);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.room-header.has-image .room-title {
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.room-header.room-ended {
  filter: grayscale(0.6) brightness(0.85);
}

.room-ended-badge {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: var(--dice-fumble, #e0546b);
  background: rgba(224, 84, 107, 0.14);
  border: 1px solid rgba(224, 84, 107, 0.4);
  padding: 2px 8px;
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 4px;
}

.admin-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--periwinkle-bright, #cfdaf7);
  background: rgba(147, 169, 232, 0.14);
  border: 1px solid rgba(147, 169, 232, 0.4);
  padding: 5px 10px;
  border-radius: 2px;
  display: flex;
  align-items: center;
}

.room-header a.back-link,
.room-header .settings-btn {
  font-size: 12px;
  color: #c8c4d6;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(147, 169, 232, 0.35);
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
}

.room-header.has-image a.back-link,
.room-header.has-image .settings-btn {
  background: rgba(6, 5, 8, 0.6);
}

.room-title-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bgm-widget {
  position: relative;
  flex-shrink: 0;
}

.bgm-mini {
  width: 64px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: #0c0b10;
  position: relative;
  border: 1px solid rgba(147, 169, 232, 0.4);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.bgm-mini .bgm-player {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bgm-mini-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.35);
}

.bgm-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.3);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  padding: 12px;
  z-index: 40;
  animation: dropdown-pop 0.15s ease-out;
}

.bgm-panel-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
  background: #0c0b10;
}

.bgm-panel-video .bgm-player {
  width: 100%;
  height: 100%;
}

.bgm-player iframe {
  width: 100%;
  height: 100%;
}

.bgm-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-light);
}

.bgm-volume-row svg.lucide {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.bgm-volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--periwinkle-glow, #93a9e8);
}

.bgm-clear-btn {
  border: none;
  background: none;
  color: var(--dice-fumble, #e0546b);
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.bgm-clear-btn svg.lucide {
  width: 18px;
  height: 18px;
}

.bgm-quick-row,
.bgm-add-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.bgm-quick-row input,
.bgm-add-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.bgm-add-row input#bgm-playlist-title-input {
  flex: 0.7;
}

.bgm-quick-row button,
.bgm-add-row button {
  padding: 7px 12px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.bgm-playlist {
  display: flex;
  flex-direction: column;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 4px;
}

.bgm-playlist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  font-size: 12px;
  border-bottom: 1px solid rgba(147, 169, 232, 0.12);
}

.bgm-playlist-item .bgm-item-title {
  font-weight: bold;
  color: var(--text);
  flex-shrink: 0;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgm-playlist-item .bgm-item-yt-title {
  color: var(--text-light);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgm-playlist-item .bgm-play-btn {
  border: none;
  background: none;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.bgm-playlist-item .bgm-play-btn svg.lucide {
  width: 15px;
  height: 15px;
}

.bgm-playlist-item .bgm-delete-btn {
  border: none;
  background: none;
  color: var(--dice-fumble, #e0546b);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.7;
}

.bgm-playlist-item .bgm-delete-btn:hover {
  opacity: 1;
}

.bgm-playlist-item .bgm-delete-btn svg.lucide {
  width: 13px;
  height: 13px;
}

.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #0e0d12;
  border-bottom: 1px solid rgba(147, 169, 232, 0.14);
  flex-wrap: wrap;
}

.send-area > .profile-bar {
  margin: -10px -12px 10px;
}

.profile-dropdown {
  position: relative;
  flex: 1;
  min-width: 130px;
}

.profile-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 4px;
  border: 1px solid rgba(147, 169, 232, 0.25);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  font-weight: bold;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.profile-dropdown-trigger:hover {
  border-color: var(--primary-mid);
  box-shadow: 0 4px 16px rgba(147, 169, 232, 0.2);
}

.profile-dropdown-trigger:active {
  transform: scale(0.98);
}

.profile-dropdown.open .profile-dropdown-trigger {
  border-color: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(147, 169, 232, 0.3);
}

.profile-dropdown-trigger .dropdown-arrow {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.profile-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.profile-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--primary-mid);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.profile-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.3);
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  padding: 6px;
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
  transform-origin: top center;
  animation: dropdown-pop 0.15s ease-out;
}

@keyframes dropdown-pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  color: var(--text);
  transition: background 0.1s;
}

.profile-dropdown-item:hover {
  background: rgba(147, 169, 232, 0.08);
}

.profile-dropdown-item.active {
  background: rgba(147, 169, 232, 0.16);
  color: var(--periwinkle-bright, #cfdaf7);
}

.profile-dropdown-item .profile-dropdown-oneliner {
  font-weight: normal;
  font-size: 11px;
  color: var(--text-light);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}

.profile-dropdown-empty {
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
}

.profile-gear-btn {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
}

.profile-gear-btn svg.lucide {
  width: 14px;
  height: 14px;
}

.profile-gear-btn:hover {
  background: rgba(147, 169, 232, 0.15);
  color: var(--primary-dark);
}

.profile-add-btn {
  padding: 6px 12px;
  border-radius: 3px;
  font-size: 12px;
  border: 1.5px dashed var(--primary-mid);
  background: none;
  color: var(--periwinkle-bright, #cfdaf7);
  cursor: pointer;
}

.sheet-open-btn {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border-radius: 4px;
  border: 1px solid rgba(147, 169, 232, 0.3);
  background: rgba(147, 169, 232, 0.1);
  color: var(--periwinkle-bright, #cfdaf7);
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.sheet-open-btn:hover {
  background: rgba(147, 169, 232, 0.2);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-avatar.initial-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 16px;
}

.msg-body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 3px;
  min-width: 0;
}

.msg-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-body .msg-name {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-light);
}

.msg-time {
  font-size: 10px;
  color: var(--text-light);
  opacity: 0.7;
}

.msg-edited-tag {
  font-size: 10px;
  color: var(--text-light);
  opacity: 0.6;
}

.msg-action-btn {
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 1px 3px;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.msg-action-btn:hover {
  opacity: 1;
  color: var(--primary-dark);
}

.msg-action-btn svg.lucide {
  width: 12px;
  height: 12px;
}

.msg-deleted-text {
  font-size: 13px;
  font-style: italic;
  color: var(--text-light);
}

.msg-edit-wrap {
  display: flex;
  gap: 6px;
}

.msg-edit-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--primary-mid);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.msg-edit-wrap button {
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
}

.msg-edit-wrap button:last-child {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.msg-body .msg-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text);
}

.msg-narration {
  text-align: center;
  color: var(--text-low, #6e6a7c);
  font-style: italic;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 20px;
  line-height: 1.5;
}

.send-area {
  border-top: 1px solid rgba(147, 169, 232, 0.14);
  padding: 10px 12px;
  background: #0c0b10;
}

.host-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
  flex-wrap: wrap;
}

.host-controls select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(147, 169, 232, 0.25);
  border-radius: 4px;
  padding: 6px 26px 6px 12px;
  font-size: 12px;
  font-weight: bold;
  color: var(--text);
  background-color: #17151c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%2393a9e8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.host-controls select:hover {
  border-color: var(--primary-mid);
}

.host-controls select:focus {
  outline: none;
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 3px rgba(147, 169, 232, 0.2);
}

.host-controls select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.host-controls input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(147, 169, 232, 0.25);
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  background: #17151c;
}

.host-controls input[type="color"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.host-controls input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.host-controls input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.host-controls label.narration-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text);
  font-weight: bold;
}

#narration-style-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#narration-style-controls label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.image-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.image-preview-row img {
  height: 56px;
  width: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(147, 169, 232, 0.25);
}

.image-preview-row button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}

.image-preview-row button svg.lucide {
  width: 12px;
  height: 12px;
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.input-toolbar button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(147, 169, 232, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.input-toolbar button:hover {
  border-color: var(--primary-mid);
  background: rgba(147, 169, 232, 0.08);
}

.input-toolbar button.active {
  background: rgba(147, 169, 232, 0.16);
  border-color: var(--primary-dark);
  color: var(--periwinkle-bright, #cfdaf7);
}

.dice-panel {
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
  background: #0e0d12;
}

.dice-free-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.dice-free-row input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.dice-free-row button {
  padding: 7px 14px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
}

.dice-skill-list {
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 10px;
}

.dice-skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 3px;
  border: 1px solid var(--primary-mid);
  background: rgba(147, 169, 232, 0.08);
  color: var(--periwinkle-bright, #cfdaf7);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.dice-skill-chip:hover {
  background: rgba(147, 169, 232, 0.18);
}

.dice-skill-empty {
  font-size: 12px;
  color: var(--text-light);
}

.msg-dice {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0 auto;
  max-width: 90%;
  font-size: 13px;
}

.msg-dice .dice-emoji {
  font-size: 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.dice-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  flex: 1;
}

.dice-value-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 1px 7px;
  font-family: ui-monospace, monospace;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  font-weight: bold;
}

.dice-check-label {
  color: var(--text-light);
}

.dice-damage {
  font-weight: bold;
}

.dice-outcome-text {
  font-weight: 700;
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 3px;
}

.dice-body.outcome-bg-success,
.dice-body.outcome-bg-hard {
  background: rgba(147, 169, 232, 0.12);
  border-color: var(--dice-success, #93a9e8);
  color: var(--dice-success, #93a9e8);
}

.dice-body.outcome-bg-extreme,
.dice-body.outcome-bg-critical {
  background: rgba(163, 230, 53, 0.12);
  border-color: var(--dice-crit, #a3e635);
  color: var(--dice-crit, #a3e635);
}

.dice-body.outcome-bg-fail {
  background: rgba(138, 134, 150, 0.14);
  border-color: var(--dice-fail, #8a8696);
  color: var(--dice-fail, #8a8696);
}

.dice-body.outcome-bg-fumble {
  background: rgba(224, 84, 107, 0.14);
  border-color: var(--dice-fumble, #e0546b);
  color: var(--dice-fumble, #e0546b);
}

.dice-body.outcome-bg-success .dice-check-label,
.dice-body.outcome-bg-hard .dice-check-label,
.dice-body.outcome-bg-extreme .dice-check-label,
.dice-body.outcome-bg-critical .dice-check-label,
.dice-body.outcome-bg-fail .dice-check-label,
.dice-body.outcome-bg-fumble .dice-check-label {
  color: inherit;
  opacity: 0.75;
}

#sheet-section label {
  margin-top: 14px;
}

.skill-point-display {
  font-weight: bold;
  color: var(--primary-dark);
}

.skill-point-display.over-budget {
  color: var(--dice-fumble, #e0546b);
}

.profile-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.attribute-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.attribute-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--bg);
  border: 1px solid rgba(147, 169, 232, 0.12);
  border-radius: 4px;
  padding: 6px 4px;
}

.attribute-cell label {
  margin: 0 !important;
  font-size: 11px;
  font-weight: bold;
  color: var(--text);
}

.attribute-cell input {
  width: 100% !important;
  text-align: center;
  padding: 5px !important;
}

.luck-row {
  display: flex;
  gap: 8px;
}

.luck-row input {
  flex: 1;
}

.luck-row button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
}

.weapon-card {
  border: 1px solid rgba(147, 169, 232, 0.16);
  border-radius: 4px;
  padding: 6px;
  margin-bottom: 8px;
  background: var(--bg);
}

.weapon-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr 0.8fr 0.8fr 0.9fr auto;
  gap: 4px;
  align-items: center;
}

.weapon-skill-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.weapon-skill-row label {
  margin: 0 !important;
  font-size: 10px !important;
  white-space: nowrap;
  color: var(--text-light);
}

.weapon-skill-row input {
  flex: 1;
  padding: 6px 8px !important;
  font-size: 11px !important;
}

.weapon-row input {
  padding: 6px 6px !important;
  font-size: 11px !important;
  min-width: 0;
}

.weapon-row button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
}

.weapon-row button svg.lucide {
  width: 12px;
  height: 12px;
}

.weapon-header {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr 0.8fr 0.8fr 0.9fr auto;
  gap: 4px;
  font-size: 10px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.weapon-header span:last-child {
  width: 24px;
}

#weapon-add-row-btn {
  margin-top: 10px;
  margin-bottom: 18px;
}

.derived-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-bar-label {
  font-size: 12px;
  font-weight: bold;
  color: var(--text);
  width: 32px;
  flex-shrink: 0;
}

.stat-bar-track {
  flex: 1;
  height: 9px;
  background: #151319;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--primary-dark);
  box-shadow: 0 0 8px var(--primary-dark);
  transition: width 0.2s;
}

.stat-bar-fill.stat-hp {
  background: var(--gauge-hp, #e05572);
  box-shadow: 0 0 8px var(--gauge-hp, #e05572);
}

.stat-bar-fill.stat-mp {
  background: var(--gauge-mp, #6f8bdb);
  box-shadow: 0 0 8px var(--gauge-mp, #6f8bdb);
}

.stat-bar-fill.stat-san {
  background: var(--gauge-san, #a988d9);
  box-shadow: 0 0 8px var(--gauge-san, #a988d9);
}

.stat-bar-numbers {
  font-size: 11px;
  color: var(--text-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-bar-numbers input {
  width: 40px !important;
  padding: 3px 4px !important;
  text-align: center;
  font-size: 11px !important;
}

.sheet-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.sheet-row input[type="text"] {
  flex: 1.4;
  padding: 7px 10px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.sheet-row input[type="number"] {
  flex: 1;
  width: 0;
  padding: 7px 10px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  border-radius: 4px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.sheet-row button {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}

.sheet-row button svg.lucide {
  width: 12px;
  height: 12px;
}

.msg-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 6px;
  border: 1px solid rgba(147, 169, 232, 0.2);
  object-fit: cover;
  margin-top: 4px;
  cursor: pointer;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
}

.image-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  object-fit: contain;
}

.send-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rich-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(147, 169, 232, 0.22);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.rich-input:empty:before {
  content: attr(data-placeholder);
  color: var(--text-faint, #726d80);
}

.rich-input[contenteditable="false"] {
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.02);
  cursor: not-allowed;
}

.send-form button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(147, 169, 232, 0.35);
  transition: box-shadow 0.2s;
}

.send-form button:hover {
  box-shadow: 0 0 22px rgba(147, 169, 232, 0.6);
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 75;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.28);
  border-radius: 8px;
  padding: 24px;
  width: 300px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}

.modal-box h3 {
  margin-top: 0;
  color: var(--periwinkle-bright, #cfdaf7);
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-row h3 {
  margin: 0;
}

.modal-delete-btn {
  border: 1px solid rgba(224, 84, 107, 0.35);
  background: rgba(224, 84, 107, 0.12);
  color: var(--dice-fumble, #e0546b);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-delete-btn:hover {
  background: rgba(224, 84, 107, 0.22);
}

.modal-delete-btn svg.lucide {
  width: 15px;
  height: 15px;
}

.modal-box label {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin: 10px 0 4px;
}

.modal-box input[type="text"],
.modal-box input[type="password"],
.modal-box input[type="number"],
.modal-box textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(147, 169, 232, 0.22);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
}

.sheet-modal-box {
  width: 380px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.modal-actions .primary {
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  box-shadow: 0 0 14px rgba(147, 169, 232, 0.35);
}

.modal-actions .secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.header-preview {
  width: 120px;
  height: 60px;
  border-radius: 4px;
}

.image-picker {
  cursor: pointer;
  margin-top: 6px;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  border: 1.5px dashed rgba(147, 169, 232, 0.3);
  transition: border-color 0.15s;
}

.image-picker:hover {
  border-color: var(--primary-mid);
}

.modal-box input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: 1px solid rgba(147, 169, 232, 0.25);
  border-radius: 50%;
  cursor: pointer;
  background: #17151c;
  overflow: hidden;
}

.modal-box input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
  border-radius: 50%;
}

.modal-box input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

/* ---------- Gallery ---------- */

#gallery-page {
  max-width: 1100px;
  margin: 0 auto;
}

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  background: var(--white);
  border: 1px solid rgba(147, 169, 232, 0.16);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s;
}

.gallery-item:hover {
  border-color: rgba(147, 169, 232, 0.55);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.88), transparent 60%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  text-align: left;
  padding: 12px;
  gap: 3px;
  color: white;
  opacity: 0;
  transition: opacity 0.15s;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-title {
  font-weight: bold;
  font-size: 13px;
  word-break: break-word;
  color: var(--text-hi);
}

.gallery-item-source {
  font-size: 10.5px;
  opacity: 0.9;
  word-break: break-word;
  color: var(--periwinkle-glow, #93a9e8);
}

.gallery-item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.gallery-item-actions button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-item-actions button:hover {
  background: rgba(255, 255, 255, 0.32);
}

.gallery-item-actions svg.lucide {
  width: 13px;
  height: 13px;
}

.gallery-image-picker {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 5px;
}

.scroll-top-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(147, 169, 232, 0.45);
  z-index: 60;
  transition: box-shadow 0.2s, transform 0.1s;
}

.scroll-top-btn:hover {
  box-shadow: 0 0 28px rgba(147, 169, 232, 0.7);
}

.gallery-lightbox {
  flex-direction: column;
}

.gallery-lightbox-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  z-index: 2;
}

.lightbox-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.gallery-lightbox-scroll {
  max-width: 92vw;
  max-height: 92vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox-scroll img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
}

.gallery-lightbox-scroll img.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  cursor: zoom-out;
}

.build-bonus-display {
  font-size: 12px;
  font-weight: bold;
  color: var(--periwinkle-bright, #cfdaf7);
  background: var(--bg);
  border: 1px solid rgba(147, 169, 232, 0.16);
  border-radius: 4px;
  padding: 6px 10px;
  margin-top: 6px;
  text-align: center;
}

/* ---------- Stickers ---------- */

#sticker-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 33;
}

.sticker {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
  border-radius: 2px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}

.sticker img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  border-radius: 2px;
}

.sticker.locked {
  cursor: default;
}

.sticker.selected {
  outline: 2px dashed var(--periwinkle-glow, #93a9e8);
  outline-offset: 4px;
}

.sticker-resize-handle,
.sticker-rotate-handle {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #151319;
  border: 1px solid rgba(147, 169, 232, 0.4);
  color: var(--periwinkle-glow, #93a9e8);
  cursor: pointer;
}

.sticker.selected:not(.locked) .sticker-resize-handle,
.sticker.selected:not(.locked) .sticker-rotate-handle {
  display: flex;
}

.sticker-resize-handle {
  right: -11px;
  bottom: -11px;
  cursor: nwse-resize;
}

.sticker-rotate-handle {
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  cursor: grab;
}

.sticker-rotate-handle svg.lucide {
  width: 12px;
  height: 12px;
}

.sticker-toolbar {
  position: absolute;
  top: -34px;
  right: -6px;
  display: none;
  gap: 4px;
}

.sticker.selected .sticker-toolbar {
  display: flex;
}

.sticker-toolbar button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(147, 169, 232, 0.4);
  background: #151319;
  color: var(--periwinkle-glow, #93a9e8);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-toolbar svg.lucide {
  width: 13px;
  height: 13px;
}

.sticker-add-btn {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(147, 169, 232, 0.45);
  z-index: 60;
  transition: box-shadow 0.2s;
}

.sticker-add-btn:hover {
  box-shadow: 0 0 28px rgba(147, 169, 232, 0.7);
}

.sticker-picker-box {
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.sticker-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.sticker-picker-item {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.sticker-picker-item:hover {
  border-color: var(--primary-mid);
}

.sticker-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- D-day widget ---------- */

.dday-widget {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 100px;
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.35);
  color: var(--periwinkle-glow, #93a9e8);
  padding: 9px 8px 8px;
  border-radius: 6px;
  text-align: center;
  font-weight: 800;
  font-size: 21px;
  font-family: var(--font-display), serif;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  text-shadow: 0 0 12px rgba(147, 169, 232, 0.5);
  z-index: 61;
  user-select: none;
  transition: box-shadow 0.2s;
}

.dday-widget::before {
  content: "같이 있어 줘.";
  display: block;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-faint, #726d80);
  margin-bottom: 3px;
}

.dday-widget:hover {
  box-shadow: 0 8px 30px rgba(147, 169, 232, 0.35);
}

.dday-editor {
  position: fixed;
  top: 90px;
  right: 16px;
  background: linear-gradient(180deg, var(--panel-top, #1c1a22), var(--panel-bottom, #0c0b10));
  border: 1px solid rgba(147, 169, 232, 0.3);
  border-radius: 6px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  z-index: 62;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 180px;
}

.dday-editor label {
  font-size: 12px;
  color: var(--text-light);
}

.dday-editor input[type="date"] {
  padding: 6px 8px;
  border: 1px solid rgba(147, 169, 232, 0.22);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-hi);
  color-scheme: dark;
}

.dday-editor button {
  padding: 8px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #b7c5f2, #7690dd);
  color: #0a0a0e;
  font-weight: bold;
  cursor: pointer;
}

.dday-editor button:hover {
  box-shadow: 0 0 16px rgba(147, 169, 232, 0.5);
}

/* ---------- Profile sets ---------- */

#profile-set-list-view {
  max-width: 1000px;
  margin: 0 auto;
}

.profile-page-heading {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 18px;
}

.profile-page-heading h2 {
  font-family: var(--font-display-kr), sans-serif;
  font-size: 20px;
  color: var(--text-hi);
  margin: 0;
}

.profile-set-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.profile-set-card {
  display: block;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(165deg, var(--panel-top, #1c1a22), #0a090d);
  border: 1px solid rgba(147, 169, 232, 0.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, border-color 0.15s;
}

.profile-set-card:hover {
  transform: translateY(-4px);
  border-color: rgba(147, 169, 232, 0.5);
}

.profile-set-card img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

.profile-set-card-info {
  padding: 10px 12px 12px;
}

.profile-set-card-title {
  font-family: var(--font-display), serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-hi);
  word-break: break-word;
}

.profile-set-card-count {
  font-size: 11px;
  color: var(--periwinkle-glow, #93a9e8);
  margin-top: 2px;
}

.profile-set-add-btn {
  flex-shrink: 0;
}

.profile-detail-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.back-link-btn {
  font-size: 12.5px;
  font-weight: bold;
  color: #c8c4d6;
  background: none;
  border: none;
  padding: 6px 4px;
  border-radius: 0;
  cursor: pointer;
}

.profile-duo {
  display: flex;
  gap: 1px;
  background: rgba(147, 169, 232, 0.12);
}

.profile-duo-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
  border-radius: 0;
  background: linear-gradient(160deg, #151319, #050506);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.profile-duo-side:hover {
  background: linear-gradient(160deg, #1c1a22, #0a090d);
}

.profile-duo-portrait {
  width: 100%;
  height: 280px;
  overflow: hidden;
  margin-bottom: 14px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 88%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 88%, transparent 100%);
}

.profile-duo-portrait img {
  display: block;
  width: 150%;
  height: auto;
  margin-left: -25%;
}

.profile-duo-name-kr {
  font-size: 13px;
  color: var(--text-light);
  font-weight: bold;
  text-align: center;
}

.profile-duo-name-en {
  font-family: var(--font-display), serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 2px;
  margin-top: 4px;
  text-align: center;
  word-break: break-word;
}

.profile-duo-empty {
  min-height: 340px;
  justify-content: center;
  border: 1.5px dashed var(--primary-mid);
  background: none;
  color: var(--periwinkle-glow, #93a9e8);
  gap: 8px;
  font-weight: bold;
  font-size: 13px;
}

.profile-character-header {
  border-bottom: 2px solid rgba(147, 169, 232, 0.4);
  padding-bottom: 10px;
  margin-bottom: 24px;
}

.profile-character-name-kr {
  font-size: 13px;
  color: var(--text-mid);
  letter-spacing: 0.1em;
}

.profile-character-name-en {
  font-family: var(--font-display), serif;
  font-weight: 800;
  font-size: clamp(26px, 5vw, 40px);
  color: var(--text-hi);
  letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(147, 169, 232, 0.3);
  margin-top: 2px;
  word-break: break-word;
}

.profile-character-body {
  display: grid;
  grid-template-columns: minmax(200px, 340px) 1fr;
  gap: 44px;
  align-items: start;
}

@media (max-width: 620px) {
  .profile-character-body {
    grid-template-columns: 1fr;
  }
}

.profile-character-portrait {
  border-radius: 3px;
  overflow: hidden;
  background: repeating-linear-gradient(135deg, #221f2a, #221f2a 10px, #1a1720 10px, #1a1720 20px);
}

.profile-character-portrait.is-empty {
  aspect-ratio: 3 / 4;
}

.profile-character-portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  cursor: zoom-in;
}

.profile-character-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
}

@media (max-width: 420px) {
  .profile-character-fields {
    grid-template-columns: 1fr;
  }
}

.profile-field-row {
  border-left: 2px solid rgba(147, 169, 232, 0.35);
  padding: 0 0 0 12px;
}

.profile-field-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  font-weight: bold;
  color: var(--periwinkle-glow, #93a9e8);
  margin-bottom: 4px;
}

.profile-field-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.profile-set-banner-picker {
  width: 100%;
  aspect-ratio: 3 / 1;
  border-radius: 5px;
}

.profile-portrait-picker {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 5px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.profile-character-modal-box {
  width: 340px;
  max-height: 85vh;
  overflow-y: auto;
}

#profile-character-view {
  padding: 24px 20px 90px;
  background: linear-gradient(180deg, #050506, #0b0a0e 12%, #0b0a0e 88%, #050506);
}

.profile-character-sheet {
  position: relative;
  background: linear-gradient(155deg, var(--panel-top, #1c1a22), #0a090d 70%);
  border: 1px solid rgba(147, 169, 232, 0.22);
  border-radius: 4px;
  padding: 44px 48px 40px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  max-width: 1080px;
  margin: 0 auto;
}

.profile-character-sheet::before {
  content: "CHARACTER ARCHIVE";
  display: block;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--text-faint, #726d80);
  margin-bottom: 16px;
}

.profile-character-sheet .bracket-tl,
.profile-character-sheet .bracket-tr,
.profile-character-sheet .bracket-bl,
.profile-character-sheet .bracket-br {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--periwinkle-glow, #93a9e8);
  border-style: solid;
  border-width: 0;
}

.profile-character-sheet .bracket-tl {
  top: -1px;
  left: -1px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.profile-character-sheet .bracket-tr {
  top: -1px;
  right: -1px;
  border-top-width: 2px;
  border-right-width: 2px;
}

.profile-character-sheet .bracket-bl {
  bottom: -1px;
  left: -1px;
  border-bottom-width: 2px;
  border-left-width: 2px;
}

.profile-character-sheet .bracket-br {
  bottom: -1px;
  right: -1px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* ---------- Backup ---------- */

#backup-page {
  max-width: 760px;
  margin: 0 auto;
}

.backup-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.backup-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(165deg, var(--panel-top, #1c1a22), #0a090d);
  border: 1px solid rgba(147, 169, 232, 0.16);
  border-radius: 6px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.backup-msg-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.backup-msg-body {
  min-width: 0;
  flex: 1;
}

.backup-msg-name {
  font-size: 12px;
  font-weight: bold;
  color: var(--periwinkle-bright, #cfdaf7);
  margin-bottom: 4px;
}

.backup-msg-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Calendar ---------- */

#calendar-page {
  max-width: 780px;
  margin: 0 auto;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.calendar-month-label {
  font-family: var(--font-display), serif;
  font-size: 16px;
  font-weight: bold;
  color: var(--periwinkle-bright, #cfdaf7);
  min-width: 120px;
  text-align: center;
}

.calendar-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--text-light);
  margin-bottom: 6px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  position: relative;
  aspect-ratio: 1;
  border-radius: 5px;
  background: none;
  border: none;
  padding: 6px;
  box-shadow: none;
  overflow: hidden;
}

.calendar-day.other-month {
  background: none;
  border-color: transparent;
  box-shadow: none;
  opacity: 0.3;
}

.calendar-day.today {
  box-shadow: 0 0 0 2px var(--periwinkle-glow, #93a9e8) inset, 0 0 14px rgba(147, 169, 232, 0.35);
}

.calendar-day-num {
  position: relative;
  z-index: 2;
  font-size: 12px;
  font-weight: bold;
  color: var(--text);
}

.calendar-day.today .calendar-day-num {
  color: var(--periwinkle-bright, #cfdaf7);
}

.calendar-day.has-image .calendar-day-num {
  display: inline-block;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 6px;
  border-radius: 8px;
}

.calendar-day-content {
  position: relative;
  z-index: 1;
  height: calc(100% - 16px);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-memo-row {
  flex: 0 0 auto;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 3px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.calendar-memo-row input[type="checkbox"] {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  accent-color: var(--periwinkle-glow, #93a9e8);
}

.calendar-memo-text {
  font-size: 10px;
  font-weight: bold;
  color: #0a0a0e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.calendar-memo-text.done {
  text-decoration: line-through;
  opacity: 0.6;
}

.calendar-memo-x {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  cursor: pointer;
  padding: 0;
}

.calendar-memo-row:hover .calendar-memo-x {
  display: flex;
}

.calendar-memo-x svg.lucide {
  width: 8px;
  height: 8px;
}

.calendar-memo-add-area {
  flex: 1;
  min-height: 0;
  cursor: pointer;
}

.calendar-day-image-wrap {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  overflow: hidden;
  cursor: zoom-in;
  z-index: 0;
}

.calendar-day-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.calendar-day-image-x {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  cursor: pointer;
  padding: 0;
}

.calendar-day:hover .calendar-day-image-x {
  display: flex;
}

.calendar-day-image-x svg.lucide {
  width: 10px;
  height: 10px;
}

.calendar-slot-modal-box {
  width: 260px;
}

.calendar-slot-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.calendar-slot-form-row input[type="text"] {
  flex: 1;
}
