/* ── Swastha design system ──────────────────────────────────────────────
   Matches the olive-green landing page (Fraunces display + Inter body, no
   gradients). Claude-style two-pane layout with a left sidebar (Tools → New
   chat → Chat history) and a centered chat.
   NOTE: the --teal-* variable names are kept for stability but now hold the
   landing page's OLIVE values. */

:root {
  --teal-800: #353f22;
  --teal-700: #46532c;
  --teal-600: #586b33;
  --teal-500: #6e823f;
  --teal-100: #ecefe2;
  --teal-050: #f5f7ee;
  --accent: #6e823f;

  --bg: #fbfcf7;
  --surface: #ffffff;
  --sidebar-bg: #28301a;
  --sidebar-text: #d7ddc9;
  --sidebar-muted: #9caa86;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(110, 130, 63, 0.3);

  --bubble-bot: #eef1e3;
  --bubble-bot-border: #e2e7d5;
  --text: #1b1f15;
  --text-soft: #6b7160;
  --line: #e2e7d5;

  --shadow-sm: 0 1px 2px rgba(20, 25, 15, 0.06);
  --shadow-md: 0 8px 30px rgba(20, 25, 15, 0.08);
  --shadow-lg: 0 18px 50px rgba(20, 25, 15, 0.14);

  --r-lg: 12px;
  --r-md: 9px;
  --r-bubble: 12px;
  --r-pill: 999px;
  --r-btn: 8px;
  --sidebar-w: 272px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button {
  font-family: inherit;
}
/* The `hidden` attribute must win over our display:grid/flex screen rules,
   otherwise all screens (onboarding / gated / app) render on top of each
   other. Without this, the empty gated overlay covers everything. */
[hidden] {
  display: none !important;
}

/* ════════════════ Onboarding wizard ════════════════ */
.onboarding,
.gated {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
  z-index: 50;
}
.onboarding__card,
.gated__card {
  width: min(560px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 24px;
  animation: fadeUp 0.4s ease both;
}
.onboarding__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--teal-700);
  margin-bottom: 18px;
}
.onboarding__logo {
  height: 30px;
  width: auto;
}
.onboarding__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--teal-050);
  border-radius: var(--r-pill);
}
.onboarding__progress {
  height: 6px;
  background: var(--teal-050);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: 22px;
}
.onboarding__progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--teal-600);
  border-radius: var(--r-pill);
  transition: width 0.35s ease;
}
.onboarding__body {
  min-height: 180px;
}
.onboarding__body h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.25;
  color: var(--text);
}
.onboarding__body p.lead {
  margin: 0 0 18px;
  color: var(--text-soft);
  line-height: 1.55;
}
.ob-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  background: var(--bg);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
textarea.ob-input {
  resize: vertical;
  min-height: 110px;
  line-height: 1.55;
}
.ob-input:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 4px var(--teal-050);
}
.ob-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ob-option {
  text-align: left;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  padding: 14px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.16s ease;
}
.ob-option:hover {
  border-color: var(--teal-500);
  background: var(--teal-050);
}
.ob-option.selected {
  border-color: var(--teal-500);
  background: var(--teal-050);
  color: var(--teal-800);
  font-weight: 600;
  box-shadow: 0 0 0 3px var(--teal-050);
}
.onboarding__error {
  margin-top: 12px;
  color: #b4452f;
  font-size: 0.88rem;
}
.onboarding__nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}
.btn {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--r-btn);
  border: none;
  cursor: pointer;
  transition: all 0.16s ease;
}
.btn--block {
  width: 100%;
  margin: 0 !important;
}
.btn--primary {
  color: #fff;
  background: var(--teal-600);
  margin-left: auto;
}
.btn--primary:hover {
  background: var(--teal-700);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn--ghost {
  color: var(--text-soft);
  background: transparent;
  border: 1.5px solid var(--line);
}
.btn--ghost:hover {
  background: var(--bg);
}
.onboarding__disclaimer {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-soft);
}

/* gated */
.gated__card {
  text-align: center;
  max-width: 480px;
}
.gated__mark {
  font-size: 40px;
}
.gated__card p {
  margin: 14px 0 0;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* ════════════════ App shell ════════════════ */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 14px;
}
.sidebar__title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 0 6px;
}
.tool {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--sidebar-text);
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.16s ease;
}
.tool:hover {
  background: var(--sidebar-hover);
}
.tool--active {
  background: var(--sidebar-active);
  font-weight: 600;
}
.tool__icon {
  font-size: 1.05rem;
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  background: var(--teal-600);
  border: none;
  padding: 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.sidebar__history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.history-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}
.history-item {
  text-align: left;
  font-size: 0.88rem;
  color: var(--sidebar-text);
  background: transparent;
  border: none;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease;
}
.history-item:hover {
  background: var(--sidebar-hover);
}
.history-item.active {
  background: var(--sidebar-active);
  font-weight: 600;
}
.history-empty {
  font-size: 0.82rem;
  color: var(--sidebar-muted);
  padding: 8px 12px;
}

.sidebar__footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}
.sidebar__reset {
  width: 100%;
  font-size: 0.82rem;
  color: var(--sidebar-muted);
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.sidebar__reset:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

/* ── Main pane ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.topbar__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__spacer {
  flex: 1;
}
.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  border-radius: var(--r-md);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg);
}

/* ── Chat scroll area ── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.msg {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  animation: fadeUp 0.32s ease both;
}
.msg--user {
  flex-direction: row-reverse;
}
.msg__avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--teal-100);
  margin-top: 2px;
}
.msg--user .msg__avatar {
  background: var(--teal-600);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.bubble {
  padding: 12px 16px;
  border-radius: var(--r-bubble);
  line-height: 1.6;
  font-size: 0.96rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg--bot .bubble {
  background: var(--bubble-bot);
  border: 1px solid var(--bubble-bot-border);
  color: var(--text);
  border-top-left-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.msg--user .bubble {
  background: var(--teal-600);
  color: #fff;
  border-top-right-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.bubble p {
  margin: 0 0 0.6em;
}
.bubble p:last-child {
  margin-bottom: 0;
}
.bubble strong {
  font-weight: 700;
}
.bubble em {
  font-style: italic;
}
.bubble ul,
.bubble ol {
  margin: 0.4em 0;
  padding-left: 1.2em;
}
.bubble li {
  margin: 0.25em 0;
}
.bubble code {
  background: rgba(70, 83, 44, 0.1);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 0.88em;
}
.msg--user .bubble code {
  background: rgba(255, 255, 255, 0.22);
}

/* thinking dots inside an assistant bubble (no text label) */
.thinking {
  display: inline-flex;
  gap: 5px;
  padding: 2px 0;
}
.thinking .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal-500);
  animation: bounce 1.3s infinite ease-in-out;
}
.thinking .dot:nth-child(2) {
  animation-delay: 0.18s;
}
.thinking .dot:nth-child(3) {
  animation-delay: 0.36s;
}

/* ── Empty state (Claude-style centered greeting) ── */
.empty {
  margin: auto;
  text-align: center;
  max-width: 560px;
  padding: 30px 16px;
  animation: fadeUp 0.4s ease both;
}
.empty__mark {
  font-size: 44px;
  margin-bottom: 8px;
}
.empty h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--text);
}
.empty__logo {
  height: 48px;
  width: auto;
  margin: 0 auto 14px;
  display: block;
}
.empty__sub {
  margin: 0 0 22px;
  color: var(--text-soft);
  line-height: 1.55;
}
.empty__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.chip {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--teal-700);
  background: var(--teal-050);
  border: 1.5px solid var(--teal-100);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.16s ease;
}
.chip:hover {
  background: var(--teal-100);
  transform: translateY(-1px);
}

/* ── Composer ── */
.composer {
  padding: 10px 16px 14px;
  background: var(--surface);
}
.composer__form {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 6px 6px 6px 18px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.composer__form:focus-within {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 4px var(--teal-050);
}
.composer__input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 0.96rem;
  line-height: 1.5;
  color: var(--text);
  max-height: 160px;
  padding: 9px 0;
}
.composer__input::placeholder {
  color: var(--text-soft);
}
.send-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--r-pill);
  color: #fff;
  background: var(--teal-600);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.send-btn:hover {
  transform: scale(1.05);
}
.send-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.composer__disclaimer {
  max-width: 760px;
  margin: 9px auto 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-soft);
}

/* ── Mobile sidebar ── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 24, 0.45);
  z-index: 30;
}
@media (max-width: 820px) {
  .icon-btn {
    display: grid;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }
}

/* ── Animations ──
   Entrance uses transform only (no opacity), so content is NEVER left invisible
   if the animation is paused (e.g. background tab) or doesn't complete. */
@keyframes fadeUp {
  from {
    transform: translateY(8px);
  }
  to {
    transform: translateY(0);
  }
}
@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.chat::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
  width: 8px;
}
.chat::-webkit-scrollbar-thumb {
  background: var(--teal-100);
  border-radius: var(--r-pill);
}
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--r-pill);
}

/* ════════════ Shared form controls ════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.field__hint {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.field__opt {
  color: var(--text-soft);
  font-weight: 400;
}
.input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
textarea.input {
  resize: vertical;
  line-height: 1.5;
}
.input:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px var(--teal-050);
}
.pw {
  position: relative;
  display: flex;
}
.pw .input {
  padding-right: 46px;
  flex: 1;
}
.pw__eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 8px;
}
.pw__eye:hover {
  color: var(--teal-700);
}
.pw__eye--off .pw__icon {
  opacity: 0.5;
}
.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.45;
  cursor: pointer;
}
.checkbox input {
  margin-top: 2px;
  width: 17px;
  height: 17px;
  accent-color: var(--teal-600);
  flex: 0 0 auto;
}
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.choice {
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  padding: 11px 18px;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: all 0.15s ease;
}
.choice:hover {
  border-color: var(--teal-500);
}
.choice.selected {
  border-color: var(--teal-600);
  background: var(--teal-050);
  color: var(--teal-800);
  font-weight: 600;
}

/* ════════════ Auth screen ════════════ */
.auth {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}
.auth__panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  margin: auto;
}
.auth__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
  text-decoration: none;
}
.auth__logo {
  height: 30px;
  width: auto;
}
.auth__brandtext {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--teal-700);
}
.auth__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--text);
  text-align: center;
  margin: 0 0 6px;
}
.auth__sub {
  text-align: center;
  color: var(--text-soft);
  margin: 0 0 24px;
  font-size: 0.95rem;
}
.auth__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}
.auth__divider::before,
.auth__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth__error {
  font-size: 0.86rem;
  color: #b4452f;
  background: #fbeae6;
  border: 1px solid #f3cfc6;
  padding: 10px 12px;
  border-radius: var(--r-md);
}
.auth__switch {
  text-align: center;
  margin: 18px 0 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}
.auth__switch button {
  background: none;
  border: none;
  color: var(--teal-600);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn--google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 11px 18px;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn--google:hover {
  background: var(--bg);
  border-color: #c9d2b6;
}

/* ════════════ Onboarding (full screen) ════════════ */
.ob {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
}
.ob__wrap {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 56px 24px 72px;
}
.ob__logo {
  height: 34px;
  width: auto;
  margin-bottom: 18px;
}
.ob__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--text);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.ob__sub {
  color: var(--text-soft);
  font-size: 1.02rem;
  margin: 0;
  line-height: 1.55;
  max-width: 48ch;
}
.ob__form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 30px;
}
.ob__form .field > label {
  font-size: 0.98rem;
}

/* ════════════ Loading transition ════════════ */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
}
.loader {
  position: relative;
  width: 84px;
  height: 84px;
}
.loader__ring {
  width: 84px;
  height: 84px;
}
.loader__track {
  fill: none;
  stroke: var(--teal-100);
  stroke-width: 6;
}
.loader__spin {
  fill: none;
  stroke: var(--teal-600);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 50 201;
  animation: loaderspin 1.1s linear infinite;
}
@keyframes loaderspin {
  to {
    stroke-dashoffset: -201;
  }
}
.loader__logo {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.loading__msg {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--teal-800);
  margin: 0;
  text-align: center;
  min-height: 1.5em;
}

/* gated + sidebar user */
.gated__card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.sidebar__user {
  font-size: 0.8rem;
  color: var(--sidebar-muted);
  padding: 0 8px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (prefers-reduced-motion: reduce) {
  .loader__spin {
    animation: none;
  }
}
