:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #626262;
  --paper: #f5f4ef;
  --white: #fff;
  --line: #d9d7cf;
  --blue: #173f73;
  --blue-light: #e9f0f8;
  --green: #9fc436;
  --shadow: 0 24px 70px rgba(17, 25, 37, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, textarea { font: inherit; }
button { cursor: pointer; }

.site-shell { min-height: 100vh; }
.app-header { height: 76px; padding: 0 4vw; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 46px; height: 46px; object-fit: contain; border-radius: 50%; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 1rem; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.user-email { color: var(--muted); font-size: .85rem; }
.quiet-button { border: 0; background: transparent; color: var(--blue); padding: 8px; }

main { min-height: calc(100vh - 76px); }
.login-card { width: min(620px, calc(100% - 32px)); margin: 10vh auto; padding: 56px; border: 1px solid var(--line); border-radius: 24px; background: var(--white); box-shadow: var(--shadow); }
.login-card h1, .context-rail h1 { margin: 8px 0 18px; font-family: Georgia, serif; font-size: clamp(2.15rem, 4vw, 4.4rem); line-height: .98; font-weight: 500; }
.login-card p, .context-rail p { color: var(--muted); line-height: 1.6; }
.eyebrow { margin: 0; color: var(--blue) !important; font-size: .74rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.primary-button, .send-button { border: 0; border-radius: 999px; color: white; background: var(--blue); font-weight: 700; }
.primary-button { margin-top: 18px; padding: 14px 22px; }

.chat-layout { display: grid; grid-template-columns: minmax(270px, 34%) 1fr; min-height: calc(100vh - 76px); }
.context-rail { padding: clamp(34px, 5vw, 76px); border-right: 1px solid var(--line); background: linear-gradient(150deg, #fff 0%, #eef3eb 100%); }
.context-rail h1 { max-width: 620px; }
.source-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 34px; }
.source-list span { padding: 7px 11px; border: 1px solid #bfc9b3; border-radius: 999px; color: #304125; background: rgba(255,255,255,.65); font-size: .8rem; }
.prompt-starters { display: grid; gap: 9px; }
.prompt-starters button { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; text-align: left; color: var(--ink); background: rgba(255,255,255,.78); }
.prompt-starters button:hover { border-color: var(--blue); }

.chat-panel { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; max-height: calc(100vh - 76px); background: #fbfbf9; }
.mode-switcher { display: flex; gap: 9px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.mode-button { display: grid; gap: 2px; min-width: 160px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px; text-align: left; background: white; color: var(--muted); }
.mode-button strong { color: var(--ink); }
.mode-button span { font-size: .75rem; }
.mode-button.active { border-color: var(--blue); background: var(--blue-light); box-shadow: inset 0 0 0 1px var(--blue); }

.messages { padding: 28px clamp(18px, 5vw, 64px); overflow-y: auto; }
.message { display: flex; margin: 0 0 20px; }
.message > div { max-width: min(760px, 90%); padding: 16px 18px; border-radius: 18px; line-height: 1.55; white-space: pre-wrap; }
.message p { margin: 8px 0 0; }
.message.user { justify-content: flex-end; }
.message.user > div { color: white; background: var(--blue); border-bottom-right-radius: 5px; }
.message.assistant > div { border: 1px solid var(--line); background: white; border-bottom-left-radius: 5px; }
.message.pending > div { color: var(--muted); }
.response-title { display: block; margin-bottom: 8px; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 8px; margin-top: 14px; }
.metric { padding: 10px; border-radius: 10px; background: var(--paper); }
.metric strong, .metric span { display: block; }
.metric span { color: var(--muted); font-size: .75rem; }
.insight-list { margin: 14px 0 0; padding-left: 20px; }
.viz-link { display: inline-flex; margin-top: 14px; padding: 11px 16px; border-radius: 999px; color: white; background: var(--blue); font-weight: 700; text-decoration: none; }
.viz-link::after { content: " ↗"; }

.composer { padding: 16px clamp(18px, 5vw, 64px) 22px; border-top: 1px solid var(--line); background: white; }
.composer > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.composer-row { display: flex; align-items: flex-end; gap: 10px; padding: 8px; border: 1px solid #bababa; border-radius: 18px; background: white; }
textarea { flex: 1; resize: none; min-height: 48px; max-height: 180px; padding: 12px; border: 0; outline: 0; background: transparent; }
.send-button { min-width: 74px; padding: 12px 16px; }
.send-button:disabled { cursor: wait; opacity: .55; }
.status-text { margin: 7px 4px 0; color: var(--muted); font-size: .75rem; }

.dashboard-view { min-height: calc(100vh - 76px); background: white; }
.dashboard-toolbar { min-height: 88px; padding: 15px 4vw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.dashboard-toolbar > div { text-align: center; }
.dashboard-toolbar h1 { margin: 3px 0 0; font-family: Georgia, serif; font-size: clamp(1.25rem, 2vw, 1.8rem); font-weight: 500; }
.dashboard-toolbar .quiet-button { justify-self: end; text-decoration: none; }
.dashboard-back { color: var(--blue); font-weight: 700; text-decoration: none; }
.dashboard-status { margin: 0; padding: 32px 4vw; color: var(--muted); text-align: center; }
.dashboard-frame { display: block; width: 100%; height: calc(100vh - 164px); border: 0; background: var(--paper); }

@media (max-width: 850px) {
  .user-email { display: none; }
  .chat-layout { display: block; }
  .context-rail { padding: 30px 22px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .context-rail h1 { font-size: 2.25rem; }
  .context-rail > p:not(.eyebrow), .source-list { margin-bottom: 16px; }
  .prompt-starters { display: flex; overflow-x: auto; }
  .prompt-starters button { min-width: 220px; }
  .chat-panel { min-height: 70vh; max-height: none; }
  .messages { min-height: 42vh; }
  .mode-button { min-width: 0; flex: 1; }
  .dashboard-toolbar { grid-template-columns: auto 1fr; }
  .dashboard-toolbar > div { text-align: left; }
  .dashboard-toolbar .quiet-button { display: none; }
}

@media (max-width: 520px) {
  .app-header { padding: 0 16px; }
  .brand small { display: none; }
  .login-card { padding: 34px 24px; }
  .mode-switcher { padding: 12px; }
  .mode-button span { display: none; }
  .message > div { max-width: 96%; }
}
