:root {
  --teal: #0f766e;
  --teal-deep: #115e59;
  --teal-bright: #0d9488;
  --teal-soft: #ccfbf1;
  --mint: #f3fbf9;
  --ink: #134e4a;
  --muted: #5b7570;
  --line: #d7ebe6;
  --white: #ffffff;
  --danger: #b42318;
  --warn: #9a3412;
  --ok: #047857;
  --shadow: 0 10px 30px rgba(15, 118, 110, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--mint);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

.app { min-height: 100%; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 20px;
  background: var(--teal);
  color: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 36px;
  height: 36px;
  padding: 4px;
  border-radius: 10px;
  background: var(--white);
  object-fit: contain;
}

.brand strong { display: block; font-size: 17px; letter-spacing: -0.02em; }

.brand span { display: block; font-size: 12px; opacity: 0.85; }

.nav { display: flex; gap: 8px; flex-wrap: wrap; }

.nav button, .ghost, .primary, .danger {
  min-height: var(--tap);
  border-radius: 10px;
  padding: 0 14px;
  border: 1px solid transparent;
}

.nav button {
  background: transparent;
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.35);
}

.nav button[aria-current="page"] { background: var(--white); color: var(--teal-deep); }

.primary { background: var(--teal); color: var(--white); border-color: var(--teal); }

.ghost { background: var(--white); border-color: var(--line); }

.danger { background: var(--white); color: var(--danger); border-color: #f3c7c3; }

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
}

.sidebar, .main {
  min-height: 0;
}

.sidebar {
  overflow: auto;
  padding: 16px;
  background: var(--white);
  border-right: 1px solid var(--line);
}

.side-head, .room-head, .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.side-head h2, .room-head h2, .admin h2, .card h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }

.room-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.room-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 12px;
  padding: 10px 12px;
}

.room-btn.active { border-color: var(--teal); background: var(--teal-soft); }

.room-btn strong { display: block; }

.room-btn small, .muted { color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; }

.room-head, .pins, .composer, .admin { padding: 16px 20px; }

.room-head { background: var(--white); border-bottom: 1px solid var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  padding: 4px 10px;
  font-size: 13px;
}

.pins {
  background: #fffdf6;
  border-bottom: 1px solid #f3e7c3;
  max-height: 34vh;
  overflow: auto;
}

.pin { margin-top: 12px; }

.pin header { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

.transcript { flex: 1; overflow: auto; padding: 16px 20px 8px; }

.message {
  max-width: 720px;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.message header { display: flex; justify-content: space-between; gap: 12px; }

.message .who { font-weight: 650; }

.message time, .deliveries { color: var(--muted); font-size: 13px; }

.message .body { white-space: pre-wrap; margin: 8px 0 0; }

.deliveries { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.pill {
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--mint);
}

.pill.sent { color: var(--ok); }
.pill.failed, .pill.rate_limited { color: var(--warn); }
.pill.pending { color: var(--teal); }

.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.files img { max-width: min(100%, 420px); border-radius: 10px; }

.md {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--mint);
}

.md :first-child { margin-top: 0; }
.md :last-child { margin-bottom: 0; }

.file-link { color: var(--teal-deep); }

.composer { background: var(--white); border-top: 1px solid var(--line); }

.composer textarea, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--white);
}

.composer textarea { min-height: 76px; resize: vertical; }

.composer .actions, .modal .actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f0;
  color: var(--danger);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(440px, 100%);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card img { width: 48px; height: 48px; object-fit: contain; }

.card h1 { margin: 12px 0 4px; letter-spacing: -0.03em; }

.admin { overflow: auto; }

.stack { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

.field.wide { grid-column: 1 / -1; }

.key-once {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--teal-soft);
  overflow-wrap: anywhere;
}

.checks { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }

.check { display: flex; gap: 8px; align-items: center; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(19, 78, 74, 0.35);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.empty { color: var(--muted); padding: 24px 4px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; height: auto; min-height: calc(100dvh - 64px); }
  .sidebar { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { min-height: 70vh; }
  .grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
}
