:root {
  --bg: #11151C;
  --panel: #212D40;
  --panel2: #364156;
  --ink: #E6E8E6;
  --muted: #CED0CE;
  --line: #364156;
  --accent: #D66853;
  --accent-dim: #D66853;
  --mine: #364156;
  --highlight: #D66853;
  --danger: #DB504A;
  --ok: #4fae4e;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 280px;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font);
  background: var(--bg); display: flex; flex-direction: column; min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  flex-shrink: 0; z-index: 5;
}
.brand { color: #FFFFFF; font-weight: 700; letter-spacing: 0.02em; font-size: 1.1rem; }
.brand span { color: #FFFFFF; }
nav { display: flex; gap: 0.65rem; align-items: center; flex-wrap: wrap; }
nav a { color: var(--muted); font-size: 0.9rem; }
nav a:hover, nav a.active { color: var(--accent); }
.who { color: var(--muted); font-size: 0.85rem; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.1rem; height: 1.1rem; padding: 0 0.3rem;
  background: var(--highlight); color: var(--bg); border-radius: 999px; font-size: 0.7rem; font-weight: 700;
}
.inline { display: inline; margin: 0; }
button, .btn {
  background: var(--highlight); color: var(--bg); border: none; padding: 0.55rem 0.9rem;
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
}
button:hover, .btn:hover { background: var(--accent); color: var(--bg); }
.btn.ghost, button.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.app {
  flex: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0; max-width: 1200px; width: 100%; margin: 0 auto;
}
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.sidebar-head { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); }
.sidebar-head h2 { margin: 0; font-size: 1rem; }
.side-nav { list-style: none; margin: 0; padding: 0.4rem 0; overflow: auto; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 1rem; color: var(--ink); font-size: 0.95rem;
}
.side-nav a:hover { background: var(--panel2); }
.side-nav li.active a { background: var(--panel2); }
.side-nav .ico { width: 1.5rem; text-align: center; opacity: 0.7; color: var(--muted); }
.side-nav a:hover .ico, .side-nav li.active .ico { color: var(--accent); opacity: 1; }
.main { display: flex; flex-direction: column; min-height: 0; background: var(--bg);
  background-image: radial-gradient(ellipse at top, #212D40 0%, transparent 55%);
}
.layout-pad { padding: 1.25rem; overflow: auto; flex: 1; }
.hero h1 { font-size: 1.75rem; margin: 0 0 0.35rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.chat {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.chat-head {
  padding: 0.75rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.chat-head h1 { margin: 0; font-size: 1.05rem; }
.messages {
  flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.45rem;
}
.bubble {
  max-width: min(75%, 520px); padding: 0.5rem 0.75rem;
  background: var(--panel); border-radius: var(--radius); align-self: flex-start;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.bubble.mine { align-self: flex-end; background: var(--mine); color: var(--ink); }
.meta { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.15rem; font-weight: 600; }
.bubble img.media {
  display: block; max-width: 100%; max-height: 280px; border-radius: 8px; margin-top: 0.35rem;
}
.composer {
  display: flex; gap: 0.4rem; align-items: center;
  padding: 0.65rem 0.85rem; background: var(--panel); border-top: 1px solid var(--line);
}
.composer input[type="text"], .composer input[type="search"], .composer textarea, select,
.stack input, .stack textarea {
  flex: 1; background: var(--panel2); border: none; color: var(--ink);
  padding: 0.7rem 0.85rem; font: inherit; border-radius: 10px;
}
.composer input[type="file"] { max-width: 8rem; color: var(--muted); font-size: 0.8rem; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.error { color: var(--danger); }
.small { font-size: 0.85rem; }
.panel {
  background: var(--panel); border-radius: var(--radius); padding: 1.25rem;
  max-width: 640px;
}
.box { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--panel2); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 0.55rem; }
.flashes { list-style: none; padding: 0.5rem 1rem; margin: 0; }
.flashes .error { color: var(--danger); }
.card-list { list-style: none; padding: 0; margin: 0; }
.card-list li {
  padding: 0.75rem; border-bottom: 1px solid var(--panel2);
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: center;
}
.feed-post {
  background: var(--panel); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem;
}
.feed-post .meta { margin-bottom: 0.4rem; }
.feed-post img { max-width: 100%; border-radius: 8px; margin-top: 0.5rem; }
.search-results li { padding: 0.55rem 0; border-bottom: 1px solid var(--panel2); }
.mobile-toggle {
  display: none; background: transparent; border: none; color: var(--ink);
  font-size: 1.4rem; padding: 0.25rem 0.5rem; cursor: pointer;
}
.mobile-toggle:hover { background: transparent; color: var(--accent); }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--sidebar-w));
    transform: translateX(-105%); transition: transform 0.2s; z-index: 20;
    box-shadow: 8px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-block; }
  .backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 15;
  }
  .backdrop.show { display: block; }
}

/* Launcher iframe embed (?embed=1) — keep DM UI, hide Sendlett chrome */
body.embed .top,
body.embed .sidebar,
body.embed .backdrop,
body.embed .mobile-toggle {
  display: none !important;
}
body.embed .app {
  display: block;
  min-height: 100vh;
}
body.embed .main {
  margin: 0;
  max-width: none;
  min-height: 100vh;
}
body.embed .chat.dm {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.embed .chat.dm .messages {
  flex: 1;
}
body.embed .chat-head .small a[href*="/dm"] {
  display: none;
}

.start-wrap { max-width: 520px; margin: 2rem auto; padding: 0 1rem 2rem; }
.start-card { background: var(--panel); border-radius: var(--radius); padding: 1.25rem; }
.start-card h1 { margin: 0 0 0.75rem; font-size: 1.35rem; }
.start-logo { font-size: 1.6rem; margin-bottom: 0.8rem; display: inline-block; }
.start-card label { display: flex; flex-direction: column; gap: 0.35rem; }
.start-card input[type="text"],
.start-card input[type="email"],
.start-card input[type="password"],
.start-card input[type="tel"] {
  background: var(--panel2); color: var(--ink); border: none; border-radius: 10px;
  padding: 0.7rem 0.85rem; font: inherit;
}
.field-note { color: var(--muted); font-size: 0.85rem; margin: 0.15rem 0 0; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.reg-legal { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; }
.reg-check { flex-direction: row; align-items: flex-start; gap: 0.5rem; }
.req { color: var(--ink); }

.field-with-tip { position: relative; }
.field-label-row { position: relative; display: flex; align-items: center; gap: 0.4rem; }
.field-label-text { line-height: 1.25; }
.start-card button.field-tip-btn {
  flex: 0 0 auto; width: 1.25rem; height: 1.25rem; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel2);
  color: var(--muted); font-size: 0.72rem; font-weight: 700; line-height: 1;
  cursor: help; display: inline-flex; align-items: center; justify-content: center;
}
.start-card button.field-tip-btn:hover,
.start-card button.field-tip-btn:focus-visible,
.start-card button.field-tip-btn[aria-expanded="true"] {
  background: var(--panel2); color: var(--accent); border-color: var(--accent);
}
.field-tip {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 0.28rem);
  display: none; margin: 0; padding: 0.55rem 0.7rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel2); color: var(--ink);
  font-size: 0.82rem; font-weight: 400; line-height: 1.4;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}
.field-tip[hidden] { display: none !important; }
.field-with-tip.is-tip-open .field-tip { display: block !important; }
@media (hover: hover) and (pointer: fine) {
  .field-tip-btn:hover + .field-tip,
  .field-tip-btn:focus-visible + .field-tip { display: block !important; }
}

h1 { color: #FFFFFF; }
button.ghost:hover, .btn.ghost:hover { background: transparent; color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 1px solid var(--accent); outline-offset: 1px;
}
html { scrollbar-color: #364156 #11151C; }
