:root {
  --bg: #f2f1ee;
  --panel: #ffffff;
  --panel-2: #ececea;
  --border: #dcdad5;
  --text: #16171a;
  --text-dim: #6b6b68;
  --accent: #c8202c;
  --accent-dark: #9c1520;
  --accent-tint: #fbe9e9;
  --black: #14161a;
  --user-bubble: #fbe9e9;
  --assistant-bubble: #ffffff;
  --danger: #c8202c;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}
.dot-red { background: var(--accent); }
.dot-black { background: var(--black); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 26px; font-size: 14.5px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-outline {
  background: #fff;
  border-color: var(--black);
  color: var(--black);
}
.btn-outline:hover:not(:disabled) { background: var(--panel-2); }

.hint { color: var(--text-dim); font-size: 12.5px; }

/* ==========================================================================
   Gate (logged out)
   ========================================================================== */
.gate {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.gate-banner {
  height: 10px;
  background: repeating-linear-gradient(
    135deg,
    var(--accent) 0 18px,
    var(--black) 18px 36px
  );
}

.gate-banner-inner {
  background: var(--black);
  color: #fff;
  padding: 18px 32px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.gate-wordmark {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.03em;
}
.gate-wordmark .accent { color: var(--accent); }

.gate-powered {
  color: #9a9a98;
  font-size: 13px;
}

.gate-hero {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 60px;
  padding: 60px clamp(24px, 6vw, 90px);
  flex-wrap: wrap;
}

.gate-hero-content {
  flex: 1 1 420px;
  max-width: 560px;
}

.gate-hero-content h1 {
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.15;
  margin: 6px 0 16px;
  color: var(--black);
}

.gate-lede {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 26px;
}

.gate-hero-panel {
  flex: 1 1 320px;
  max-width: 420px;
}

.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
}

.hero-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.hero-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}
.hero-list li:last-child { border-bottom: none; }

/* ==========================================================================
   App shell (logged in) — sidebar + main, in keeping with the ODSS/Gatesman
   house style rather than a floating centered card.
   ========================================================================== */
.app {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 18px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark { font-size: 22px; line-height: 1; }
.brand-name {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--black);
}
.brand-sub {
  margin: 2px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.sidebar-nav { margin-bottom: 20px; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item-active {
  background: var(--black);
  color: #fff;
}
.nav-item-active:hover { background: var(--black); }

.sidebar-section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.plan-status {
  font-size: 13px;
  margin: 0 0 10px;
}

.update-log {
  font-size: 12.5px;
  line-height: 1.5;
}
.update-log ul { margin: 8px 0 0; padding-left: 16px; }
.update-log li { margin-bottom: 6px; }
.update-log a { color: var(--accent); }
.update-log strong { display: block; margin-bottom: 2px; font-size: 12px; }

.sidebar-spacer { flex: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.user-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 6px;
  background: var(--black);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; }
.user-email {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-org {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Main column ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}
.crumb {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg { display: flex; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 720px;
  padding: 13px 17px;
  border-radius: var(--radius);
  line-height: 1.55;
  font-size: 14.5px;
  white-space: pre-wrap;
}

.msg.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
}

.msg.user .bubble {
  background: var(--user-bubble);
  border: 1px solid #f2d3d3;
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }

.sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-dim);
}
.sources ul { margin: 6px 0 0; padding-left: 18px; }
.sources li { margin-bottom: 4px; }
.sources a { color: var(--accent); text-decoration: none; }
.sources a:hover { text-decoration: underline; }

.download-btn {
  display: inline-block;
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}
.download-btn:hover { border-color: var(--accent); }
.download-btn:disabled { opacity: 0.5; cursor: default; }

.error-bubble {
  color: var(--danger);
  border-color: var(--danger) !important;
}

.typing {
  display: inline-flex;
  gap: 4px;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.composer {
  display: flex;
  gap: 10px;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.composer textarea {
  flex: 1;
  resize: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: inherit;
  max-height: 140px;
}
.composer textarea:focus { outline: 1px solid var(--accent); }

.disclaimer {
  padding: 8px 28px 14px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* ---- Subscribe banner / plan cards ---- */
.subscribe-banner {
  margin: 20px 28px 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}
.subscribe-lede { margin: 0 0 14px; font-size: 13.5px; color: var(--text-dim); }

.plan-choices {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.plan-card {
  flex: 1;
  min-width: 220px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.plan-card-accent { border-color: var(--accent); background: var(--accent-tint); }
.plan-card h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.plan-price { margin: 0 0 8px; font-size: 22px; font-weight: 800; color: var(--black); }
.plan-price span { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.plan-desc { margin: 0 0 12px; color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }

/* ---- Invite a teammate ---- */
.invite-box {
  margin: 16px 28px 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 13px;
}
.invite-box p { margin: 0 0 8px; }
.invite-form {
  display: flex;
  gap: 8px;
}
.invite-form input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

/* ---- Small screens: stack the sidebar above the chat ---- */
@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: auto; flex: none; border-right: none; border-bottom: 1px solid var(--border); }
  .main { height: auto; }
  .chat { max-height: 60vh; }
  .gate-hero { padding: 40px 22px; gap: 32px; }
}
