:root {
  --ink: #14221c;
  --ink-soft: #3d4a43;
  --paper: #f3efe6;
  --card: #fffcf7;
  --line: #e4dccf;
  --gold: #e7c27a;
  --opening: #0f6e56;
  --opening-soft: #e5f4ee;
  --retention: #9a4d2e;
  --retention-soft: #f8ebe4;
  --danger: #8d2f2f;
  --shadow: 0 24px 60px rgba(20, 34, 28, 0.14);
  --surface: #fff;
  --rail: #f7f4ee;
  --muted: #8a8174;
  --button: #14221c;
  --on-button: #f6f1e7;
  --dash: #cfc6b6;
  --room-head: rgba(255, 252, 247, 0.86);
  --hover: rgba(20, 34, 28, 0.035);
  color-scheme: light;
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-weight: 380;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4efe4;
  --ink-soft: #c9c1b2;
  --paper: #101614;
  --card: #1b2420;
  --line: #33423b;
  --opening: #8fd8b4;
  --opening-soft: #16352c;
  --retention: #e7b394;
  --retention-soft: #3a261e;
  --danger: #f0b0a8;
  --surface: #24302b;
  --rail: #17211d;
  --muted: #b3a898;
  --button: #e7c27a;
  --on-button: #14221c;
  --dash: #4d6258;
  --room-head: rgba(23, 33, 29, 0.94);
  --hover: rgba(244, 239, 228, 0.06);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(320px, 0.95fr);
}
.auth-panel {
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(231, 194, 122, 0.18), transparent 55%),
    linear-gradient(165deg, #1b3128 0%, var(--ink) 58%, #101a16 100%);
  color: #f6f1e7;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 580;
  color: var(--gold);
}
.auth-panel h1, .brand h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 560;
  font-size: 64px;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 0.95;
}
.lede {
  max-width: 420px;
  font-size: 18px;
  line-height: 1.5;
  color: rgba(246, 241, 231, 0.82);
}
.desk-list {
  list-style: none;
  padding: 0;
  margin: 36px 0 0;
  display: grid;
  gap: 14px;
}
.desk-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid rgba(246, 241, 231, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.desk-list strong { display: block; font-weight: 580; }
.desk-list span { color: rgba(246, 241, 231, 0.72); font-size: 14px; }
.dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 99px;
  flex: none;
}
.dot.opening { background: #7dcea8; }
.dot.retention { background: #e0a07a; }

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 8vw;
  background: var(--card);
}
.tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.tab {
  border: 0;
  background: transparent;
  padding: 8px 2px 10px;
  margin-right: 16px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--ink);
  border-color: var(--ink);
  font-weight: 580;
}
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; font-weight: 580; }
.field input, .composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
.field input:focus, .composer textarea:focus {
  border-color: #9db5aa;
  box-shadow: 0 0 0 4px rgba(15, 110, 86, 0.12);
}
.form-error {
  min-height: 1.2em;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 14px;
}
.primary {
  border: 0;
  background: var(--button);
  color: var(--on-button);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 580;
}
.primary:disabled { opacity: 0.55; cursor: wait; }
.fine { color: var(--ink-soft); font-size: 13px; line-height: 1.45; }
.pick-label { margin: 0 0 8px; font-size: 13px; font-weight: 580; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.pick-card {
  display: grid;
  grid-template-columns: 10px 1fr;
  column-gap: 8px;
  row-gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
}
.pick-card .dot { grid-row: 1 / span 2; align-self: center; margin-top: 0; }
.pick-card strong { font-weight: 580; }
.pick-card span:last-child { color: var(--ink-soft); font-size: 12px; }
.pick-card.selected.opening,
.pick-card[data-team="opening"].selected {
  border-color: var(--opening);
  background: var(--opening-soft);
  box-shadow: inset 0 0 0 1px var(--opening);
}
.pick-card[data-team="retention"].selected {
  border-color: var(--retention);
  background: var(--retention-soft);
  box-shadow: inset 0 0 0 1px var(--retention);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 28px 18px 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
  overflow: auto;
}
.brand h1 { font-size: 34px; }
.rail .eyebrow { color: var(--opening); }
.rail-label {
  margin: 22px 8px 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 580;
}
.teams, .groups { display: grid; gap: 8px; }
.groups { max-height: 180px; overflow: auto; }
.quiet { margin: 0 8px; color: var(--muted); font-size: 13px; }
.leader-panel { display: grid; gap: 8px; margin-top: 8px; }
.leader-row { display: grid; gap: 6px; padding: 0 8px; }
.leader-row span { font-size: 13px; font-weight: 580; }
.leader-row select, .admin-select, .modal input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
}
.primary.slim { padding: 8px 12px; }
.new-group {
  margin: 8px 8px 0;
  border: 1px dashed var(--dash);
  border-radius: 12px;
  padding: 8px 10px;
  background: transparent;
  text-align: left;
  font-weight: 580;
}
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 34, 28, 0.46);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}
.modal {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  font-weight: 560;
}
.checks { display: grid; gap: 6px; max-height: 220px; overflow: auto; margin-bottom: 8px; }
.check { display: flex; gap: 8px; align-items: center; padding: 6px 2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.team-btn {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.team-btn strong { display: block; font-weight: 580; }
.team-btn span { display: block; color: var(--ink-soft); font-size: 12px; }
.team-btn.active {
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(20, 34, 28, 0.04);
}
.people {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  overflow: auto;
  display: grid;
  gap: 4px;
  align-content: start;
  flex: 1;
}
.person {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border-radius: 10px;
}
.person small { color: var(--muted); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 580;
  flex: none;
  position: relative;
}
.avatar.online::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 2px solid var(--rail);
  background: #1f9d62;
  border-radius: 99px;
  right: -3px;
  bottom: -3px;
}
.me {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}
.me-copy { min-width: 0; }
.me-copy strong, .me-copy span { display: block; }
.me-copy span { color: var(--ink-soft); font-size: 12px; }
.me-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-btn {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px;
}
.text-btn:hover { color: var(--ink); }

.room {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
  background: var(--paper);
}
.leader-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.leader-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.leader-card strong { grid-column: 1 / -1; font-weight: 580; }
.leader-card select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
}
.leader-card.opening { box-shadow: inset 3px 0 0 var(--opening); }
.leader-card.retention { box-shadow: inset 3px 0 0 var(--retention); }
.leader-error { grid-column: 1 / -1; margin: 0; }
.room-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 26px 32px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--room-head);
}
.room-head h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 34px;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.blurb { margin: 4px 0 0; color: var(--ink-soft); }
.presence-count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  white-space: nowrap;
}
.room.opening .room-head h2 { color: var(--opening); }
.room.retention .room-head h2 { color: var(--retention); }
.stream {
  overflow: auto;
  padding: 18px 24px 8px;
}
.day {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 16px 0 8px;
}
.msg {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
}
.msg.grouped { padding-top: 1px; }
.msg:hover { background: var(--hover); }
.msg .who { font-weight: 580; margin-right: 8px; }
.msg time { color: var(--muted); font-size: 12px; }
.msg p {
  margin: 3px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--opening);
  border: 1px solid #b7d8cb;
  border-radius: 99px;
  padding: 1px 6px;
  vertical-align: 1px;
}
.badge.leader { color: var(--retention); border-color: #e2c2b2; }
.delete-msg {
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  padding: 0 4px;
}
.msg:hover .delete-msg { opacity: 1; }
.empty {
  margin: 12vh auto 0;
  max-width: 360px;
  text-align: center;
  color: var(--ink-soft);
}
.empty strong {
  display: block;
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  color: var(--ink);
  font-weight: 560;
  margin-bottom: 6px;
}
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 24px 20px;
}
.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
}
.attach, .admin-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 580;
}
.attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 10px;
}
.chip button, .file-link {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 580;
}
.file-link { border: 1px solid var(--line); padding: 8px 10px; margin-top: 6px; }
.photo {
  display: block;
  margin-top: 6px;
  max-width: min(320px, 100%);
  max-height: 280px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.admin-select { width: calc(100% - 16px); margin: 0 8px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.admin-btn { padding: 8px 10px; }
.composer textarea {
  resize: none;
  min-height: 48px;
  max-height: 160px;
  line-height: 1.4;
}

.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 6;
  border: 1px solid rgba(20, 34, 28, 0.16);
  background: #fffcf7;
  color: #14221c;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 580;
}
html[data-theme="dark"] .theme-toggle {
  background: #24302b;
  color: #f4efe4;
  border-color: #4d6258;
}

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-panel { padding: 36px 24px 28px; }
  .auth-panel h1 { font-size: 48px; }
  .auth-card { padding: 28px 20px 40px; }
  .shell { grid-template-columns: 1fr; }
  .rail { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .people { max-height: 160px; }
  .room { min-height: auto; }
  .room-head, .composer { padding-left: 16px; padding-right: 16px; }
  .room-head h2 { font-size: 28px; }
  .leader-bar { grid-template-columns: 1fr; padding-left: 16px; padding-right: 16px; }
}
