:root {
  --ink: #17241c;
  --muted: #5d6b62;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e3d9c8;
  --green: #0f7a4a;
  --green-deep: #0b3d2e;
  --warn: #8a4b12;
  --danger: #8d2b2b;
  --shadow: 0 16px 40px rgba(23, 36, 28, 0.06);
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: var(--green-deep);
  color: #f4f0e6;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand svg { width: 32px; height: 32px; }
.brand strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 1.15rem; }
.brand span { color: #c9d7cf; font-size: 0.85rem; }
.who { display: flex; gap: 12px; align-items: center; }
.ghost {
  background: transparent;
  color: #f4f0e6;
  border: 1px solid rgba(244, 240, 230, 0.35);
  border-radius: 999px;
  padding: 8px 14px;
}

main { padding: 28px; max-width: 1100px; margin: 0 auto; }
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 560; letter-spacing: -0.02em; }
h1 { margin: 0 0 8px; font-size: 2rem; }
h2 { margin: 0 0 8px; font-size: 1.35rem; }
.lede, .muted, .footnote { color: var(--muted); }
.footnote { margin-top: 28px; font-size: 0.92rem; }

.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 120px); }
.auth-card, .account, aside, .connect {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-card { width: min(460px, 100%); padding: 28px; }
.tabs { display: flex; gap: 8px; margin: 18px 0; }
.tabs button, .row button, .connect button, form button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: #efe7d8;
  color: var(--ink);
}
.tabs button.on, form button[type="submit"], .connect button {
  background: var(--green);
  color: white;
}
label { display: grid; gap: 6px; margin-bottom: 12px; font-size: 0.92rem; }
input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
}
.error { color: var(--danger); }
.warn { color: var(--warn); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: start;
}
.connect, aside, .account { padding: 18px; }
aside {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 16px;
}
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: #efe7d8;
  color: var(--ink);
}
.scroll { overflow-y: auto; min-height: 0; max-height: calc(100vh - 220px); }
.chat-name {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 12px 4px;
  color: var(--ink);
  font-weight: 500;
}
.chat-name:hover { background: #f6f1e6; }
.admin {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.admin-scroll { overflow: auto; max-height: calc(100vh - 180px); }
.users { width: 100%; border-collapse: collapse; }
.users th, .users td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.users th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.users td div + div { margin-top: 4px; }
.users button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--green);
  color: white;
}
.pass { display: flex; gap: 8px; align-items: center; }
.pass input { width: 150px; margin: 0; }
.connect { display: flex; gap: 12px; align-items: end; margin-bottom: 14px; }
.connect label { flex: 1; margin: 0; }
.account { margin-bottom: 14px; }
.account.selected { outline: 2px solid var(--green); }
.account-head, .row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.pill {
  border-radius: 999px;
  padding: 4px 10px;
  background: #efe7d8;
  font-size: 0.82rem;
}
.pill.ready { background: #d9f3e4; color: var(--green-deep); }
.pill.bad { background: #f8e4e4; color: var(--danger); }
.qr-frame {
  margin-top: 12px;
  width: fit-content;
  background: white;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.qr-frame img { width: 260px; height: 260px; display: block; }
.row { flex-wrap: wrap; margin-top: 12px; }
.row button.danger { background: #f8e4e4; color: var(--danger); }
.config {
  width: 100%;
  min-height: 140px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}
.empty, .msg {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.msg strong { display: block; }
.msg span { color: var(--muted); font-size: 0.8rem; }

@media (max-width: 860px) {
  .layout, .connect { grid-template-columns: 1fr; display: grid; }
  .connect { align-items: stretch; }
  aside { position: static; max-height: none; }
  .scroll { max-height: 60vh; }
  main { padding: 16px; }
  .qr-frame img { width: min(260px, 70vw); height: auto; }
}
