/* ===== SCNX v1.1.0 Web Replica ===== */
:root {
  --bg: #1a1f2e;
  --panel: rgba(245, 247, 252, 0.96);
  --panel-solid: #f5f7fc;
  --ink: #2a2f3e;
  --muted: #6b7280;
  --accent: #4a90d9;
  --accent-dark: #3570b2;
  --yellow: #f5c542;
  --yellow-hover: #e0b236;
  --pink: #ec6b9e;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  background: #121521;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
}

/* ===== Window chrome ===== */
.app-window {
  position: fixed;
  inset: 12px;
  border-radius: 10px;
  background: #0d101c;
  box-shadow: 0 25px 80px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.titlebar {
  height: 36px;
  background: linear-gradient(180deg, #2c3142 0%, #1f2333 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
  border-bottom: 1px solid #151822;
}
.titlebar-left {
  display: flex; align-items: center; gap: 8px; color: #dce1ee; font-size: 13px;
}
.win-icon {
  width: 16px; height: 16px; border-radius: 4px;
  background: linear-gradient(135deg, #4a90d9, #8f5ae6);
}
.titlebar-btns { display: flex; gap: 8px; }
.titlebar-btns button {
  width: 13px; height: 13px; border-radius: 50%; border: none; cursor: pointer;
}
.tb-min { background: #f5c542; }
.tb-max { background: #39c05d; }
.tb-close { background: #ec6b6b; }

.app-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #151822;
}

/* ===== Stage / wallpaper ===== */
.stage { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bg-layer { position: absolute; inset: 0; pointer-events: none; }
.bg-layer img, .bg-layer svg { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.character-layer { pointer-events: auto; }
.bg-layer::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.12), transparent 45%);
  pointer-events: none;
}
.character-layer {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  height: 92%; width: auto;
  filter: drop-shadow(0 0 18px rgba(255,255,255,0.15));
  transition: filter 0.3s ease, transform 0.4s ease;
}
.character-layer img, .character-layer svg { height: 100%; width: auto; }
.chromatic .character-layer { animation: chroma 1.5s ease-in-out infinite; }
@keyframes chroma {
  0%,100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(-3px 0 0 rgba(255,0,0,0.25)) drop-shadow(3px 0 0 rgba(0,255,255,0.25)); }
}
.color-correct .bg-layer { filter: saturate(1.25) contrast(1.08) brightness(1.05); }
.color-correct .character-layer { filter: saturate(1.15) contrast(1.05) drop-shadow(0 0 22px rgba(255,255,255,0.22)); }

/* ===== Chapter overlay ===== */
.chapter-overlay {
  position: absolute; top: 28px; left: 28px; z-index: 5;
  color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.55);
  pointer-events: none;
}
.chapter-num { font-size: 18px; font-weight: 800; opacity: 0.9; letter-spacing: 1px; }
.chapter-title { font-size: 36px; font-weight: 900; margin: 4px 0; }
.chapter-sub { font-size: 14px; opacity: 0.85; }

.top-tools {
  position: absolute; top: 28px; right: 28px; z-index: 5;
  display: flex; gap: 10px;
}
.tbtn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 18px;
  cursor: pointer; backdrop-filter: blur(8px); transition: background 0.15s;
}
.tbtn:hover { background: rgba(255,255,255,0.3); }

/* ===== Dock ===== */
.dock {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  display: flex; gap: 18px;
  padding: 10px 18px;
  background: rgba(20, 24, 38, 0.78);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 34px rgba(0,0,0,0.45);
}
.ditem {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: transparent; border: none; cursor: pointer; color: #c8cee0;
  font-size: 11px; transition: color 0.15s;
  min-width: 48px;
}
.ditem .dicon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.1);
  font-size: 20px; transition: all 0.15s ease;
}
.ditem:hover .dicon { background: rgba(255,255,255,0.2); transform: translateY(-2px); }
.ditem.active { color: #fff; }
.ditem.active .dicon { background: rgba(74,144,217,0.35); box-shadow: 0 0 16px rgba(74,144,217,0.45); }

/* ===== Lobby list ===== */
.lobby-list {
  position: absolute; right: 22px; bottom: 100px; z-index: 9;
  width: 210px; max-height: 280px;
  background: rgba(20,24,38,0.82);
  border-radius: 14px; backdrop-filter: blur(14px);
  color: #e8ecf5; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transform: translateX(0); transition: transform 0.25s;
}
.ll-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; background: rgba(255,255,255,0.08);
  font-size: 13px; font-weight: 700;
}
.ll-body { padding: 6px; max-height: 190px; overflow-y: auto; }
.ll-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s;
}
.ll-item:hover { background: rgba(255,255,255,0.1); }
.ll-item.active { background: rgba(74,144,217,0.25); }
.ll-thumb { width: 36px; height: 36px; border-radius: 6px; background: #6b7280; flex-shrink: 0; }
.ll-info { flex: 1; overflow: hidden; }
.ll-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ll-meta { font-size: 10px; color: #9aa3b8; }
.ll-footer { padding: 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.ll-add {
  width: 100%; padding: 7px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.1); color: #dce1ee; font-size: 12px;
  cursor: pointer;
}
.ll-add:hover { background: rgba(255,255,255,0.18); }

/* ===== Subtitle bar ===== */
.subtitle-bar {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  z-index: 8; max-width: 70%;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  padding: 10px 24px; border-radius: 999px; color: #fff;
  font-size: 16px; opacity: 0; transition: opacity 0.3s;
}
.subtitle-bar.show { opacity: 1; }

/* ===== Modals ===== */
.modal {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(10,12,20,0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: min(720px, 90%);
  max-height: min(620px, 86%);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.25s;
}
.modal.open .modal-card { transform: translateY(0) scale(1); }
.modal-lg { width: min(920px, 94%); max-height: min(720px, 88%); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,0.06);
}
.mh-title { font-size: 18px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.mh-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.mh-icon.pink { background: linear-gradient(135deg, #ec6b9e, #d45a85); }
.mh-icon.blue { background: linear-gradient(135deg, #4a90d9, #6a70e6); }
.mh-page { font-size: 24px; font-weight: 800; color: var(--muted); }
.btn-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.08); color: var(--ink); cursor: pointer; font-size: 16px;
}
.btn-close:hover { background: rgba(0,0,0,0.15); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid rgba(0,0,0,0.06);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

/* Welcome modal */
.welcome-body { display: flex; align-items: center; gap: 28px; min-height: 240px; }
.welcome-illust {
  width: 220px; height: 220px; flex-shrink: 0;
  display: grid; place-items: center;
}
.welcome-illust svg { width: 100%; height: 100%; }
.welcome-text { flex: 1; }
.welcome-text h2 { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.welcome-text p { font-size: 14px; line-height: 1.7; color: var(--muted); }
.welcome-footer { justify-content: space-between; }
.btn-text { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.btn-text:hover { color: var(--ink); }
.nav-arrows { display: flex; gap: 10px; }
.btn-round {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 16px; cursor: pointer;
}
.btn-round:disabled { background: #c5cee0; cursor: not-allowed; }
.btn-primary {
  padding: 9px 18px; border-radius: 8px; border: none;
  background: var(--yellow); color: #5a4612; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(245,197,66,0.35);
}
.btn-primary:hover { background: var(--yellow-hover); }

/* Character grid */
.modal-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  background: rgba(0,0,0,0.02); border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-wrap: wrap;
}
.sel, .search {
  padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.12); background: #fff;
  font-size: 13px; color: var(--ink);
}
.search { width: 150px; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1);
  background: #fff; cursor: pointer; color: var(--ink); font-size: 15px;
}
.btn-icon:hover { background: #f0f2f8; }
.tb-spacer { flex: 1; }
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 14px; padding: 18px 20px;
}
.char-card {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06); cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}
.char-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
.char-card.active { border-color: var(--accent); }
.char-thumb { width: 100%; aspect-ratio: 1; background: #e4e8f2; display: grid; place-items: center; overflow: hidden; }
.char-thumb img { width: 100%; height: 100%; object-fit: cover; }
.char-thumb .placeholder { font-size: 36px; }
.char-name {
  text-align: center; padding: 7px 4px; font-size: 12px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.char-footer { justify-content: flex-start; }
.cf-status { display: flex; align-items: center; gap: 8px; flex: 1; }
.cf-count { margin-left: auto; font-size: 13px; color: var(--muted); background: rgba(0,0,0,0.05); padding: 4px 10px; border-radius: 999px; }

/* Settings */
.settings-body { display: flex; padding: 0 !important; overflow: hidden !important; }
.settings-tabs {
  width: 130px; flex-shrink: 0; background: rgba(0,0,0,0.02);
  border-right: 1px solid rgba(0,0,0,0.05); padding: 14px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.stab {
  padding: 12px 18px; border: none; background: transparent;
  text-align: left; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer;
  border-radius: 0 999px 999px 0; margin-right: 8px;
}
.stab:hover { background: rgba(74,144,217,0.08); color: var(--ink); }
.stab.active { background: var(--accent); color: #fff; }
.settings-content { flex: 1; padding: 18px 22px; overflow-y: auto; }
.s-section { margin-bottom: 22px; }
.s-title {
  font-size: 16px; font-weight: 800; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.s-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--yellow);
}
.s-desc { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.s-row { display: flex; align-items: center; gap: 18px; margin: 8px 0; }
.s-row label { font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
input[type="radio"] { accent-color: var(--accent); }
input[type="range"] { width: 180px; accent-color: var(--accent); }

/* Toast */
.toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95);
  z-index: 60; min-width: 260px; max-width: 340px;
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.toast-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; color: var(--ink); }
.toast-title::after { content: ""; display: block; width: 40px; height: 3px; background: var(--yellow); margin: 6px auto 0; border-radius: 2px; }
.toast-msg { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.toast-ok {
  padding: 8px 32px; border: none; border-radius: 8px;
  background: linear-gradient(135deg, #5ad8ff, #4a90d9); color: #fff; font-weight: 700; cursor: pointer;
}

/* Utility */
.hidden { display: none !important; }
.dragging { cursor: grabbing !important; }
