:root {
  --paper: #f3eee4;
  --ink: #2a241c;
  --muted: #7a7266;
  --rule: #d8d0c4;
  --panel: #ece6d9;

  --pwa-bg: #141413;
  --pwa-surface: #1c1b19;
  --pwa-elevated: #252320;
  --pwa-border: #33302b;
  --pwa-text: #f3eee4;
  --pwa-muted: #9e9587;
  --accent-claude: #d97757;
  --accent-agy: #4f8ff7;
  --accent-keel: #e5a93c;
  --accent-webgpu: #10a37f;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "Times New Roman", serif;
  line-height: 1.48;
}

body.pwa-active {
  background: var(--pwa-bg);
  color: var(--pwa-text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100dvh;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.sans {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ================= LANDING & DOWNLOAD VIEW ================= */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.4rem 6vw 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.kicker {
  margin-top: 0.15rem;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.landing-main {
  padding: 6vh 6vw 8vh;
  max-width: 92rem;
  margin: 0 auto;
}

.landing-hero {
  max-width: 58rem;
  margin-bottom: 3rem;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.landing-hero h1 {
  font-size: clamp(2.4rem, 5.8vw, 4.2rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.07;
}

.landing-hero p.lead {
  margin-top: 1.1rem;
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 46rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

.card-plate {
  background: var(--panel);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--rule);
}

.card-plate.dark-plate {
  background: #171614;
  color: var(--paper);
  border-color: #2f2c27;
}

.card-plate h2 {
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  margin: 0.4rem 0 0.7rem;
}

.card-plate p.desc {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.dark-plate p.desc {
  color: #b5ac9e;
}

.dl-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.8rem 0 1.2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.78rem 1.2rem;
  font-size: 0.88rem;
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover {
  background: #463c2e;
}

.btn.outline {
  background: transparent;
  color: var(--ink);
}

.btn.outline:hover {
  background: var(--paper);
}

.btn.accent {
  background: var(--accent-claude);
  border-color: var(--accent-claude);
  color: #fff;
  font-weight: 500;
}

.btn.accent:hover {
  background: #c56445;
}

.btn.emerald {
  background: var(--accent-webgpu);
  border-color: var(--accent-webgpu);
  color: #fff;
  font-weight: 500;
}

.feature-list {
  list-style: none;
  margin-top: 1rem;
  border-top: 1px solid var(--rule);
}

.feature-list li {
  padding: 0.52rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.94rem;
}

.login-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #302d28;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.login-field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9e9587;
}

.login-field input {
  background: #22201d;
  border: 1px solid #3c3832;
  color: var(--paper);
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
}

.login-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.landing-footer {
  display: flex;
  justify-content: space-between;
  padding: 1.2rem 6vw 2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ================= PWA WORKSPACE VIEW ================= */
.pwa-shell {
  display: grid;
  grid-template-columns: 17.5rem 1fr;
  height: 100dvh;
  width: 100vw;
  background: var(--pwa-bg);
  color: var(--pwa-text);
}

.pwa-drawer {
  background: var(--pwa-surface);
  border-right: 1px solid var(--pwa-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 0.85rem;
  overflow-y: auto;
}

.drawer-top {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.4rem 0.75rem;
  border-bottom: 1px solid var(--pwa-border);
}

.drawer-brand-title {
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.conn-pill {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(16, 163, 127, 0.16);
  color: #3fe0b5;
  border: 1px solid rgba(16, 163, 127, 0.35);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--pwa-muted);
  border: 1px solid transparent;
  padding: 0.6rem 0.7rem;
  border-radius: 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--pwa-text);
}

.nav-item.active {
  background: var(--pwa-elevated);
  color: var(--pwa-text);
  border-color: var(--pwa-border);
  font-weight: 500;
}

.nav-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #2f2c27;
  color: var(--pwa-text);
}

.nav-badge.warn {
  background: rgba(217, 119, 87, 0.22);
  color: #f59c7e;
}

.drawer-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--pwa-muted);
  padding: 0.5rem 0.6rem 0.2rem;
}

.status-box {
  background: #171614;
  border: 1px solid var(--pwa-border);
  border-radius: 0.5rem;
  padding: 0.7rem;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: #7a7266;
}

.dot.ok {
  background: #10a37f;
}

.dot.loading {
  background: #e5a93c;
}

/* Main Content Area */
.pwa-main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.pwa-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--pwa-border);
  background: var(--pwa-surface);
}

.bounce-strip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
}

.bounce-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.68rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--pwa-elevated);
  border: 1px solid var(--pwa-border);
  color: var(--pwa-text);
  cursor: pointer;
  white-space: nowrap;
}

.pane-view {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

/* Chat / Assistant Stream */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 56rem;
  margin: 0 auto;
  width: 100%;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.prompt-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.starter-chip {
  background: var(--pwa-elevated);
  border: 1px solid var(--pwa-border);
  color: var(--pwa-text);
  padding: 0.48rem 0.78rem;
  border-radius: 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}

.starter-chip:hover {
  border-color: var(--accent-webgpu);
}

.turn-card {
  border: 1px solid var(--pwa-border);
  background: var(--pwa-surface);
  border-radius: 0.6rem;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.turn-card.user-turn {
  background: #201f1c;
  border-left: 3px solid var(--accent-claude);
}

.turn-card.ai-turn {
  border-left: 3px solid var(--accent-webgpu);
}

.turn-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: var(--pwa-muted);
}

.steer-banner {
  background: rgba(16, 163, 127, 0.11);
  border: 1px solid rgba(16, 163, 127, 0.3);
  color: #9fe8d4;
  padding: 0.45rem 0.7rem;
  border-radius: 0.4rem;
  font-size: 0.79rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tool-fold {
  background: #161513;
  border: 1px solid var(--pwa-border);
  border-radius: 0.4rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
}

.tool-fold summary {
  cursor: pointer;
  color: var(--pwa-muted);
  font-weight: 500;
}

.tool-snippet-list {
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tool-snippet-item {
  padding: 0.45rem 0.6rem;
  background: var(--pwa-surface);
  border: 1px solid var(--pwa-border);
  border-radius: 0.35rem;
  font-size: 0.78rem;
}

.turn-answer {
  font-size: 0.98rem;
  line-height: 1.56;
  white-space: pre-wrap;
}

.cite-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.cite-chip {
  background: rgba(79, 143, 247, 0.14);
  border: 1px solid rgba(79, 143, 247, 0.35);
  color: #9ec5ff;
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
  font-size: 0.76rem;
  cursor: pointer;
}

.cite-chip.web {
  background: rgba(229, 169, 60, 0.14);
  border-color: rgba(229, 169, 60, 0.35);
  color: #f3ca7a;
}

/* Composer */
.composer-box {
  border: 1px solid var(--pwa-border);
  background: var(--pwa-surface);
  border-radius: 0.7rem;
  padding: 0.75rem;
  margin-bottom: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.composer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.composer-select {
  background: var(--pwa-elevated);
  color: var(--pwa-text);
  border: 1px solid var(--pwa-border);
  padding: 0.36rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.79rem;
}

.composer-input-row {
  display: flex;
  gap: 0.6rem;
}

.composer-input {
  flex: 1;
  background: #161513;
  color: var(--pwa-text);
  border: 1px solid var(--pwa-border);
  border-radius: 0.45rem;
  padding: 0.68rem 0.85rem;
  font-size: 0.94rem;
}

/* Cards in Agents / Library / Vault panes */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.item-card {
  background: var(--pwa-surface);
  border: 1px solid var(--pwa-border);
  border-radius: 0.55rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.item-card.excluded {
  border-color: rgba(217, 119, 87, 0.5);
  background: rgba(217, 119, 87, 0.06);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.73rem;
}

.pill {
  padding: 0.15rem 0.48rem;
  border-radius: 999px;
  background: var(--pwa-elevated);
  border: 1px solid var(--pwa-border);
  color: var(--pwa-muted);
}

.pill.excluded-pill {
  background: rgba(217, 119, 87, 0.2);
  color: #f59c7e;
  border-color: rgba(217, 119, 87, 0.4);
}

.diff-block {
  background: rgba(16, 163, 127, 0.1);
  border-left: 3px solid #10a37f;
  padding: 0.55rem 0.7rem;
  font-size: 0.82rem;
  color: #c7f5e8;
}

@media (max-width: 860px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .site-nav {
    gap: 1rem;
    font-size: 0.88rem;
  }
  .landing-grid {
    grid-template-columns: 1fr;
  }
  .pwa-shell {
    grid-template-columns: 1fr;
  }
  .pwa-drawer {
    display: none;
  }
  .pwa-drawer.mobile-open {
    display: flex;
    position: fixed;
    inset: 0 20% 0 0;
    z-index: 50;
  }
}
