:root,
[data-theme="night"] {
  --bg: #0c0b09;
  --rail: #141210;
  --sheet: #1b1814;
  --sheet-2: #221e19;
  --line: rgba(228, 196, 138, 0.16);
  --text: #f6f1e7;
  --muted: #a89b8c;
  --gold: #e4c48a;
  --gold-deep: #9a7040;
  --ok: #8fbf9a;
  --danger: #e08b7a;
  --in: #2a241c;
  --out: #3a3124;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

[data-theme="paper"] {
  --bg: #f3eee6;
  --rail: #efe7db;
  --sheet: #fffaf3;
  --sheet-2: #f7f0e6;
  --line: rgba(70, 48, 24, 0.12);
  --text: #241c14;
  --muted: #7a6a58;
  --gold: #8a5a24;
  --gold-deep: #6d4518;
  --ok: #2f7d4a;
  --danger: #a33b32;
  --in: #fff;
  --out: #f3e2c8;
  --shadow: 0 18px 40px rgba(70, 48, 24, 0.08);
}

[data-theme="forest"] {
  --bg: #0d1612;
  --rail: #12201a;
  --sheet: #173026;
  --sheet-2: #1d3a2e;
  --line: rgba(176, 214, 186, 0.16);
  --text: #eef6f0;
  --muted: #9db5a6;
  --gold: #c6e2c4;
  --gold-deep: #6ea57a;
  --ok: #b7e0bf;
  --danger: #f0b0a4;
  --in: #143028;
  --out: #245041;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(228, 196, 138, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  letter-spacing: 0.01em;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 18px;
  background: linear-gradient(180deg, var(--rail), transparent 140%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.mark { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.mark-seal {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--gold), var(--gold-deep));
  color: #1a140c;
  font-family: Fraunces, Georgia, serif;
  font-weight: 640;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.mark-name {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  line-height: 1;
}
.mark-sub { color: var(--muted); font-size: 0.75rem; margin-top: 3px; }

.who {
  display: flex; gap: 10px; align-items: center;
  text-align: left;
  width: 100%;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--sheet);
  box-shadow: var(--shadow);
}
.who:hover { border-color: var(--gold); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold); color: #1a140c;
  font-weight: 650; flex: none;
}
.who-copy { min-width: 0; display: grid; }
.who-copy strong, .who-copy em {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-copy em { font-style: normal; color: var(--muted); font-size: 0.78rem; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex; justify-content: space-between; align-items: center;
  border: 0; background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted);
}
.nav-btn.active, .nav-btn:hover {
  background: var(--sheet);
  color: var(--text);
}
.pill {
  min-width: 1.4rem; height: 1.4rem; padding: 0 6px;
  border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: 0.72rem; display: grid; place-items: center;
}
.pill[hidden] { display: none; }
::placeholder { color: var(--muted); opacity: 0.85; }
input[type="color"] { padding: 0; height: 36px; }
.rail-foot {
  margin-top: auto;
  display: flex; gap: 8px; align-items: center;
  color: var(--muted); font-size: 0.8rem; padding: 0 8px;
}
.live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(224, 139, 122, 0.12);
}
.live.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(143, 191, 154, 0.15); }

.stage {
  padding: 18px 20px 18px;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.view[data-view="ads"],
.view[data-view="post"],
.view[data-view="accounts"],
.view[data-view="settings"] { overflow: auto; }
.view.hidden { display: none; }
.stage-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 18px;
}
.kicker {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  color: var(--gold);
}
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 560; margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -0.03em; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.search, input, textarea, select {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
.search { min-width: 260px; }
input:focus, textarea:focus, select:focus, .search:focus {
  outline: 2px solid rgba(228, 196, 138, 0.45);
  border-color: transparent;
}
.btn {
  border: 0; border-radius: 12px;
  padding: 11px 16px;
  background: linear-gradient(180deg, var(--gold), #c9a56a);
  color: #1a140c;
  font-weight: 650;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }

.split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.pane {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list { overflow: auto; }
.chat-folders { display: flex; gap: 6px; }
.folder {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
}
.folder.active { color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }
.conv {
  width: 100%; text-align: left;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 12px 14px;
  cursor: pointer;
}
.conv.deleted { opacity: 0.42; }
.conv-arch {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 4px 0 4px 6px;
}
.trash { display: block; }
.conv-ava {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sheet-2); color: var(--gold);
  font-weight: 700;
}
.conv.active { background: var(--sheet-2); }
.conv.unread .conv-name { color: var(--gold); }
.conv-top, .ad-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 650; }
.muted, .hint, time { color: var(--muted); }
.conv-ad, .conv-preview { margin-top: 4px; font-size: 0.86rem; }
.conv-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread { display: flex; flex-direction: column; min-height: 0; }
.blank { margin: auto; padding: 28px; max-width: 360px; text-align: center; }
.blank h2 { margin-bottom: 8px; }
.chat-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.chat-head h2 { display: flex; align-items: center; gap: 8px; }
.chat-head.deleted h2,
.chat-head.deleted .muted { opacity: 0.45; }
.messages {
  flex: 1; overflow: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 72%; display: grid; gap: 4px; }
.msg.out { align-self: end; justify-items: end; }
.bubble {
  padding: 10px 12px; border-radius: 16px;
  background: var(--in); white-space: pre-wrap;
  border: 1px solid var(--line);
}
.msg.out .bubble { background: var(--out); }
.send {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.send .wide { grid-column: 1 / -1; justify-self: start; }
.send textarea { resize: vertical; min-height: 48px; }

.ads { display: grid; gap: 12px; }
.ad {
  display: grid; grid-template-columns: 1fr auto;
  gap: 16px; padding: 16px 18px;
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 18px;
}
.ad h3 { margin: 0 0 6px; font-size: 1.05rem; }
.ad-actions { display: flex; flex-direction: column; gap: 6px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 0.75rem; color: var(--muted);
}

.composer-grid { display: grid; grid-template-columns: minmax(0, 640px) 280px; gap: 16px; }
.sheet {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 20px; padding: 18px; display: grid; gap: 12px;
  box-shadow: var(--shadow);
}
.sheet.narrow { max-width: 640px; }
.sheet label, .slider { display: grid; gap: 6px; color: var(--muted); font-size: 0.86rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-field { display: grid; gap: 8px; }
.photo-drop {
  display: grid; place-items: center; width: 100%;
  min-height: 72px; padding: 12px;
  border: 1px dashed var(--line); border-radius: 16px;
  background: var(--sheet-2); color: var(--text); cursor: pointer;
}
.field-photos {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.post-windows {
  position: fixed;
  z-index: 30;
  left: 16px;
  right: 16px;
  bottom: 16px;
  top: auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  pointer-events: none;
}
.post-windows[hidden] { display: none; }
.post-window {
  pointer-events: auto;
  min-width: 0;
  max-height: 460px;
  overflow: auto;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
}
.post-window input,
.post-window textarea,
.post-window select { font-size: 0.78rem; padding: 6px 8px; }
.post-window .photo-drop { min-height: 36px; padding: 6px; }
.post-window .photo-thumb,
.post-window .photo-thumb img { width: 48px; height: 48px; flex-basis: 48px; }
.post-window .suggest { max-height: 120px; }
.win-ready {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.win-ready[hidden] { display: none; }
.win-ready-photo { width: 100%; height: 84px; object-fit: cover; border-radius: 10px; }
.win-ready-meta, .win-ready-desc { margin: 0; }
.win-ready-desc { white-space: pre-wrap; max-height: 64px; overflow: auto; color: var(--muted); }
.win-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.win-top .kicker { margin: 0; }
.win-close {
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 999px;
  background: var(--sheet-2); color: var(--text);
}
.photo-drop.over { border-color: var(--text); }
.photo-strip { display: flex; gap: 8px; overflow: auto; }
.photo-strip:empty { display: none; }
.photo-thumb { position: relative; flex: 0 0 72px; width: 72px; height: 72px; }
.photo-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; display: block; }
.photo-thumb button {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 999px;
  background: #111; color: #fff; line-height: 22px;
}
.preview-photo {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 14px; background: var(--sheet-2);
}
.preview-photo[hidden] { display: none; }
.post-actions { display: flex; gap: 8px; }
.post-actions .btn { flex: 1; }
button:disabled { opacity: 0.55; cursor: default; }
.suggest {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  max-height: 240px;
  background: var(--sheet-2);
}
.suggest[hidden] { display: none; }
.suggest button {
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--text);
}
.suggest button small { display: block; color: var(--muted); font-size: 0.75rem; }
.suggest button:hover,
.suggest button.active { background: var(--sheet); }
.picked {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--sheet-2);
}
.picked[hidden] { display: none; }
#preview-desc { white-space: pre-wrap; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.active { border-color: var(--gold); }
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--stripe, var(--gold));
}
.card h3 { margin: 8px 0 4px; font-size: 1.25rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.themes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.theme-card,
.theme-card:hover,
.theme-card:focus,
.theme-card:active {
  grid-column: span 2;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  border-radius: 16px;
  padding: 14px;
  border: 1px solid transparent;
  background: var(--card-bg, var(--sheet));
  color: var(--card-ink, var(--text));
  opacity: 1;
  overflow-wrap: anywhere;
}
.theme-card:nth-child(4) { grid-column: 2 / span 2; }
.theme-card:nth-child(5) { grid-column: 4 / span 2; }
.theme-card span,
.theme-card:hover span,
.theme-card:focus span {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--card-sub, var(--muted));
  opacity: 1;
}
.theme-card:hover { outline: 2px solid var(--gold); outline-offset: 2px; }
.theme-card.active { box-shadow: inset 0 0 0 2px var(--gold); }
.theme-card[data-theme="night"] { --card-bg: #1b1814; --card-ink: #f6f1e7; --card-sub: #cbbba6; }
.theme-card[data-theme="paper"] { --card-bg: #fffaf3; --card-ink: #241c14; --card-sub: #7a6a58; }
.theme-card[data-theme="forest"] { --card-bg: #173026; --card-ink: #eef6f0; --card-sub: #b7d0c2; }
.theme-card[data-theme="speyn"] { --card-bg: #ff4f9a; --card-ink: #fff; --card-sub: #ffe4f2; }
.theme-card[data-theme="blur"] { --card-bg: #2a241c; --card-ink: #f6f1e7; --card-sub: #cbbba6; }

.proxy-board { margin-bottom: 16px; }
.proxy-head, .proxy-head h2 { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; }
.proxy-head h2 { margin: 0; font-size: 1.35rem; }
.proxy-balance { margin: 0; font-weight: 700; }
.proxy-current {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--sheet-2);
  border: 1px solid var(--line);
  word-break: break-all;
  white-space: pre-wrap;
  font-size: 0.92rem;
}
.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.check input { width: auto; }

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(520px, 94vw);
  max-height: calc(100vh - 24px);
}
dialog::backdrop { background: rgba(8, 7, 5, 0.62); }
.dialog-sheet {
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: var(--sheet);
}
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
#toast {
  position: fixed; right: 18px; bottom: 18px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--sheet); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px);
  transition: 0.2s ease; pointer-events: none;
  max-width: min(380px, 90vw);
}
#toast.show { opacity: 1; transform: none; }
#toast[data-kind="err"] { border-color: var(--danger); }
.link { color: var(--gold); text-decoration: none; }

[data-theme="speyn"] {
  --bg: #ffd0e6;
  --rail: #ffb7d8;
  --sheet: #fff0f7;
  --sheet-2: #ffd6ea;
  --line: rgba(190, 40, 110, 0.22);
  --text: #7a1248;
  --muted: #c43b7a;
  --gold: #ff4f9a;
  --gold-deep: #e43286;
  --ok: #ff7eb3;
  --danger: #c4176a;
  --in: #ffe4f1;
  --out: #ffb3d4;
  --shadow: 0 16px 36px rgba(214, 60, 130, 0.18);
}
[data-theme="speyn"] body {
  font-family: Nunito, Outfit, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, #fff 0 10px, transparent 11px),
    radial-gradient(circle at 18% 12%, #ff4f9a 0 7px, transparent 8px),
    radial-gradient(circle at 8% 24%, #ff8ec4 0 6px, transparent 7px),
    radial-gradient(circle at 78% 12%, #fff 0 12px, transparent 13px),
    radial-gradient(circle at 84% 8%, #ff4f9a 0 8px, transparent 9px),
    radial-gradient(circle at 88% 18%, #ffb3d9 0 7px, transparent 8px),
    radial-gradient(circle at 30% 80%, #fff 0 14px, transparent 15px),
    radial-gradient(circle at 36% 74%, #ff5fa2 0 9px, transparent 10px),
    radial-gradient(circle at 24% 86%, #ffc2e0 0 8px, transparent 9px),
    radial-gradient(circle at 70% 78%, #fff 0 11px, transparent 12px),
    radial-gradient(circle at 76% 72%, #ff4f9a 0 7px, transparent 8px),
    radial-gradient(circle at 64% 84%, #ff9ecb 0 6px, transparent 7px),
    linear-gradient(160deg, #ffd6ec, #ff8ec8 55%, #ffc1df);
}
[data-theme="speyn"] body::before {
  content: "✿  ❀  ✿  ♡  ❀  ✿  ♡  ❀  ✿  ♡  ❀  ✿  ♡  ❀";
  position: fixed;
  inset: auto 0 12px 0;
  text-align: center;
  letter-spacing: 0.45em;
  color: #ff4f9a;
  font-size: 1.15rem;
  pointer-events: none;
  opacity: 0.55;
}
[data-theme="speyn"] h1,
[data-theme="speyn"] h2,
[data-theme="speyn"] .mark-name {
  font-family: Pacifico, Nunito, cursive;
  letter-spacing: 0;
}
[data-theme="speyn"] .mark-seal,
[data-theme="speyn"] .btn,
[data-theme="speyn"] .avatar,
[data-theme="speyn"] .conv-ava {
  background: linear-gradient(160deg, #ff8ec4, #ff4f9a);
  color: #fff;
}
[data-theme="speyn"] .pane,
[data-theme="speyn"] .sheet,
[data-theme="speyn"] .card,
[data-theme="speyn"] .who {
  border-radius: 28px;
}

.theme-dock { display: none; }
[data-theme="blur"] .shell {
  filter: blur(18px) saturate(0.25);
  pointer-events: none;
  user-select: none;
}
[data-theme="blur"] .theme-dock {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 40;
}
[data-theme="blur"] .dock-card {
  width: min(420px, 92vw);
  padding: 22px;
  border-radius: 22px;
  background: rgba(18, 16, 14, 0.92);
  color: #f6f1e7;
  border: 1px solid rgba(228, 196, 138, 0.35);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
[data-theme="blur"] .dock-card .hint { color: #cbbba6; }
[data-theme="blur"] .dock-themes {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
[data-theme="blur"] .dock-themes button {
  border-radius: 12px;
  border: 1px solid rgba(228, 196, 138, 0.35);
  background: transparent;
  color: #f6f1e7;
  padding: 10px 12px;
  text-align: left;
}
[data-theme="blur"] .dock-themes button[data-theme="blur"] {
  border-color: #e4c48a;
  color: #e4c48a;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky; top: 0; height: auto; z-index: 3;
    border-right: 0; border-bottom: 1px solid var(--line);
    background: var(--rail);
  }
  .nav { flex-direction: row; overflow: auto; }
  .nav-btn { white-space: nowrap; }
  .split, .composer-grid, .ad, .row2, .post-windows { grid-template-columns: 1fr; }
  .post-windows { overflow: auto; }
  .stage { padding: 18px 14px 32px; }
  h1 { font-size: 1.7rem; }
  .search { min-width: 0; width: 100%; }
  .stage-head, .head-actions { flex-direction: column; align-items: stretch; }
}
@media (max-width: 720px) {
  .themes { grid-template-columns: 1fr 1fr; }
  .theme-card,
  .theme-card:nth-child(4),
  .theme-card:nth-child(5) { grid-column: auto; }
}
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 7, 5, 0.72);
}
.login-gate[hidden] { display: none; }
.login-card { width: min(420px, 100%); }
