/* ============================================================
   Daat UI — soft-rounded design system
   Surfaces float on shadow, not frames. Pill buttons, layered
   elevation, generous spacing. Inspired by Apple / Linear / Notion.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand — three logo greens */
  --brand-deep:   #1F5A35;
  --brand:        #22B07A;
  --brand-soft:   #93EFBD;
  --brand-tint:   #E8F8EF;
  --brand-tint-2: #D6F1E1;

  /* Neutrals — crisp cool whites, no warmth */
  --bg:             #FDFEFE;
  --surface:        #FFFFFF;
  --surface-raised: #F6F7F8;
  --surface-sunken: #F1F2F4;

  /* Borders — used sparingly; prefer shadows */
  --border:        #ECEEF1;
  --border-strong: #DADDE1;

  /* Ink — stronger, deeper; less washed-out grays */
  --ink:         #0E1116;
  --ink-2:       #3A3F45;
  --ink-3:       #6B7078;
  --ink-4:       #9BA0A8;
  --ink-inverse: #FFFFFF;

  /* State */
  --danger:    #B4261F;
  --danger-bg: #FCEDEB;
  --warn:      #9A6A12;
  --warn-bg:   #FBF2DF;

  /* Shadows — layered, soft, near-black at low opacity */
  --shadow-0: 0 1px 2px rgba(15, 20, 30, 0.04);
  --shadow-1: 0 1px 2px rgba(15, 20, 30, 0.04), 0 2px 8px rgba(15, 20, 30, 0.04);
  --shadow-2: 0 2px 4px rgba(15, 20, 30, 0.05), 0 8px 24px rgba(15, 20, 30, 0.06);
  --shadow-3: 0 4px 8px rgba(15, 20, 30, 0.06), 0 16px 40px rgba(15, 20, 30, 0.08);
  --shadow-focus:    0 0 0 4px rgba(34, 176, 122, 0.14);
  --shadow-focus-ink:0 0 0 4px rgba(14, 17, 22, 0.10);
  --shadow-btn:       0 1px 2px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(15, 20, 30, 0.06);
  --shadow-btn-hover: 0 2px 6px rgba(0, 0, 0, 0.12), 0 10px 24px rgba(15, 20, 30, 0.12);

  /* Radii */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-pill: 999px;

  /* Typography */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;

  /* Motion */
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 160ms;
  --t-mid:  200ms;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  letter-spacing: -0.003em;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--brand-soft); color: var(--ink); }

::-webkit-scrollbar       { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ============================================================
   Top bar shell
   ============================================================ */

.daat-topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 32px;
  background: rgba(253, 254, 254, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(15, 20, 30, 0.04);
}

.daat-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  transition: opacity var(--t-fast) var(--ease);
}
.daat-brand:hover { opacity: 0.75; }

.daat-brand-mark {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.daat-brand-word {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.daat-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  margin-left: 16px;
}

.daat-nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  white-space: nowrap;
}
.daat-nav-link:hover           { color: var(--ink); background: var(--surface-raised); }
.daat-nav-link.active          { color: var(--ink); background: var(--surface-raised); }
.daat-nav-link.demoted         { color: var(--ink-4); font-weight: 500; }
.daat-nav-link.demoted:hover   { color: var(--ink-2); background: var(--surface-raised); }

.daat-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.daat-signout {
  background: transparent;
  border: 0;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.daat-signout:hover { color: var(--ink); background: var(--surface-raised); }

.daat-topbar.in-flow .daat-nav { display: none; }

@media (max-width: 640px) {
  .daat-topbar { padding: 14px 20px; gap: 16px; }
  .daat-nav    { gap: 2px; margin-left: 8px; }
  .daat-nav-link { padding: 6px 10px; }
}

/* ============================================================
   Page wrappers
   ============================================================ */

.daat-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 32px 140px;
}
.daat-page.wide   { max-width: 960px; }
.daat-page.narrow { max-width: 560px; }

@media (max-width: 640px) {
  .daat-page { padding: 48px 20px 120px; }
}

/* ============================================================
   Typography
   ============================================================ */

.eyebrow {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.page-title {
  font-size: clamp(32px, 4.4vw, 46px);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.08;
  color: var(--ink);
  text-wrap: balance;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.3;
  color: var(--ink);
}

.lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-2);
  letter-spacing: -0.004em;
}

.body    { font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.body-sm { font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.muted   { color: var(--ink-3); }

/* ============================================================
   Buttons — pill, layered, tactile
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 24px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.btn:focus-visible   { outline: 0; box-shadow: var(--shadow-focus); }
.btn:disabled        { opacity: 0.4; cursor: not-allowed; }

/* Primary — inked pill with subtle inner highlight and elevation */
.btn-primary {
  background: linear-gradient(180deg, #1A1F27 0%, #0E1116 100%);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn-hover);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-btn);
}
.btn-primary .btn-arrow { transition: transform var(--t-fast) var(--ease); }
.btn-primary:hover:not(:disabled) .btn-arrow { transform: translateX(2px); }

/* Secondary — soft white pill with faint outline */
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-0);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.btn-secondary:active:not(:disabled) { transform: translateY(0); }

/* Ghost — text pill; fills softly on hover */
.btn-ghost {
  color: var(--ink-2);
  background: transparent;
  padding: 0 18px;
  height: 40px;
  font-size: 13px;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-raised);
}

/* Danger — quiet destructive; turns muted red on hover */
.btn-danger {
  color: var(--ink-3);
  background: transparent;
  padding: 0 16px;
  height: 36px;
  font-size: 13px;
}
.btn-danger:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Size variants */
.btn-sm { height: 38px; padding: 0 16px; font-size: 13px; gap: 8px; }
.btn-lg { height: 56px; padding: 0 32px; font-size: 15px; gap: 12px; }

.btn-arrow {
  font-size: 15px;
  line-height: 1;
  display: inline-block;
  color: inherit;
}

/* ============================================================
   Intent tabs — Apple-style segmented pill
   ============================================================ */

.intent-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface-raised);
  border-radius: var(--r-pill);
}
.intent-tab {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.003em;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  cursor: pointer;
  line-height: 1;
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.intent-tab:hover { color: var(--ink); }
.intent-tab.selected {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-0), 0 2px 6px rgba(15, 20, 30, 0.06);
}
.intent-tab:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }

/* ============================================================
   Fields — soft rounded inputs
   ============================================================ */

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.field-label .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink-4);
}

.field-input,
.field-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-0);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field-input::placeholder,
.field-textarea::placeholder { color: var(--ink-4); }
.field-input:focus,
.field-textarea:focus {
  border-color: transparent;
  box-shadow: var(--shadow-1), var(--shadow-focus);
}
.field-textarea { resize: vertical; min-height: 120px; }

/* ============================================================
   Composer — the Ask reasoning canvas
   A single soft floating surface; no internal dividers.
   ============================================================ */

.composer {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: box-shadow var(--t-mid) var(--ease);
}
.composer:focus-within {
  box-shadow: var(--shadow-2), var(--shadow-focus);
}

.composer-intent-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.composer-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex-shrink: 0;
}

.composer-query {
  width: 100%;
  border: 0;
  outline: 0;
  resize: vertical;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.012em;
  color: var(--ink);
  background: transparent;
  padding: 4px 0;
  min-height: 140px;
}
.composer-query::placeholder { color: var(--ink-4); }

.composer-focus-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.composer-focus-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  padding: 6px 0;
}
.composer-focus-input::placeholder { color: var(--ink-4); }

.composer-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.composer-hint {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.composer-hint kbd {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  color: var(--ink-2);
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(15, 20, 30, 0.06);
}

/* ============================================================
   Source modules — floating connect-page tiles
   ============================================================ */

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

.source-module {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 22px 26px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  transition:
    transform var(--t-mid) var(--ease),
    box-shadow var(--t-mid) var(--ease);
}
.source-module:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.source-mark {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: background var(--t-mid) var(--ease), color var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease);
}
.source-module[data-state="connected"] .source-mark {
  background: linear-gradient(135deg, rgba(147, 239, 189, 0.45), rgba(34, 176, 122, 0.2));
  color: var(--brand-deep);
  box-shadow: inset 0 0 0 1px rgba(34, 176, 122, 0.2);
}

.source-body { min-width: 0; }

.source-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.source-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
}

.source-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: -0.002em;
  line-height: 1.2;
}
.source-state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-4);
  box-shadow: 0 0 0 3px rgba(155, 160, 168, 0.18);
  flex-shrink: 0;
}
.source-module[data-state="connected"] .source-state { color: var(--brand-deep); }
.source-module[data-state="connected"] .source-state-dot {
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(34, 176, 122, 0.2);
}
.source-module[data-state="unprocessed"] .source-state { color: var(--warn); }
.source-module[data-state="unprocessed"] .source-state-dot {
  background: #D9A73A;
  box-shadow: 0 0 0 3px rgba(217, 167, 58, 0.22);
}

.source-desc {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  max-width: 56ch;
}

.source-meta {
  margin-top: 10px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
}
.source-meta-key {
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 500;
  margin-right: 6px;
}
.source-meta-val {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.source-action {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .source-module {
    grid-template-columns: 48px 1fr;
    gap: 16px;
    padding: 18px 20px;
  }
  .source-action {
    grid-column: 1 / -1;
    padding-top: 4px;
  }
  .source-mark { width: 44px; height: 44px; font-size: 16px; }
}

/* ============================================================
   Surface / panel primitives
   ============================================================ */

.surface {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 32px;
}
.surface-raised {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 32px;
}

.info-module {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 22px 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: baseline;
}
.info-module-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.info-module-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}
@media (max-width: 560px) {
  .info-module { grid-template-columns: 1fr; gap: 8px; }
}

/* ============================================================
   Badges (chips)
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.002em;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-raised);
  color: var(--ink-2);
  line-height: 1.2;
}
.chip-ok      { background: var(--brand-tint); color: var(--brand-deep); }
.chip-warn    { background: var(--warn-bg);    color: var(--warn); }
.chip-danger  { background: var(--danger-bg);  color: var(--danger); }

/* ============================================================
   Banners
   ============================================================ */

.banner {
  display: none;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 32px;
  box-shadow: var(--shadow-0);
}
.banner.visible { display: flex; }
.banner-ok    { background: var(--brand-tint); color: var(--brand-deep); }
.banner-error { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   Sticky action footer
   ============================================================ */

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(253, 254, 254, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 15;
  box-shadow: 0 -1px 0 rgba(15, 20, 30, 0.04);
}
.action-bar-status     { font-size: 14px; color: var(--ink-3); letter-spacing: -0.003em; }
.action-bar-status.ok  { color: var(--brand-deep); }
.action-bar-right      { display: flex; align-items: center; gap: 8px; }

@media (max-width: 640px) {
  .action-bar { padding: 14px 20px; }
}

/* ============================================================
   Spinners / progress
   ============================================================ */

@keyframes daat-spin { to { transform: rotate(360deg); } }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: daat-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.progress-rail {
  width: 100%;
  height: 6px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-deep) 0%, var(--brand) 100%);
  width: 0%;
  border-radius: var(--r-pill);
  transition: width 0.45s var(--ease);
}

/* ============================================================
   Utilities
   ============================================================ */

.stack-2  > * + * { margin-top: 8px; }
.stack-3  > * + * { margin-top: 12px; }
.stack-4  > * + * { margin-top: 16px; }
.stack-6  > * + * { margin-top: 24px; }
.stack-8  > * + * { margin-top: 32px; }
.stack-10 > * + * { margin-top: 40px; }

.text-center { text-align: center; }
.hidden { display: none !important; }
