:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f7f5;
  --surface-raised: #fbfbfa;
  --ink: #101110;
  --muted: #686f68;
  --faint: #8b928b;
  --line: #e7e7e2;
  --line-strong: #d7d8d2;
  --accent: #10a37f;
  --accent-soft: #e8f7f2;
  --blue: #2f80ed;
  --pink: #ef6aa8;
  --code: #f4f5f0;
  --shadow: 0 24px 80px rgba(17, 18, 16, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(16, 163, 127, 0.055), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  border-color: #b9bbb4;
  background: #fdfdfb;
}

select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 34px 0 10px;
  font-size: 13px;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code);
  padding: 1px 5px;
  font-size: 0.92em;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 0 28px;
  backdrop-filter: blur(18px);
}

.brand,
.topnav,
.top-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  justify-self: start;
  font-size: 15px;
  font-weight: 700;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border: 1px solid #111;
  border-radius: 50%;
}

.topnav {
  justify-content: center;
  gap: 3px;
}

.topnav a {
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 14px;
}

.topnav a:hover,
.topnav .is-active {
  background: var(--surface-soft);
  color: var(--ink);
}

.top-actions {
  justify-self: end;
  gap: 10px;
}

.search {
  min-width: 132px;
  justify-content: flex-start;
  color: var(--muted);
  text-align: left;
  font-weight: 500;
}

.dashboard {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
}

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 880px) 180px;
  gap: 44px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 34px 28px 70px;
}

.sidebar,
.right-rail {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding-right: 18px;
}

.sidebar-title,
.rail-title,
.nav-group {
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.sidebar-title {
  margin-bottom: 12px;
  font-size: 14px;
}

.nav-group {
  margin: 18px 0 7px;
  color: var(--faint);
  text-transform: uppercase;
}

.sidebar a,
.right-rail a {
  display: block;
  border-radius: 7px;
  padding: 6px 8px;
}

.sidebar a:hover,
.sidebar a.active,
.right-rail a:hover,
.right-rail a.active {
  background: var(--surface-soft);
  color: var(--ink);
}

.right-rail {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.rail-title {
  margin-bottom: 8px;
}

.content {
  min-width: 0;
}

.article {
  min-width: 0;
}

.eyebrow,
.panel-label,
.field-label {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(40px, 6vw, 70px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.58;
}

section {
  margin-top: 44px;
}

.article p {
  max-width: 720px;
  color: #333631;
  font-size: 16px;
  line-height: 1.7;
}

.article p + p {
  margin-top: 14px;
}

.pets-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 26px;
  align-items: start;
}

.pet-settings,
.thread-demo {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.pet-settings {
  padding: 14px;
}

.settings-head,
.thread-head,
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-head {
  margin-bottom: 18px;
}

.field + .field {
  margin-top: 16px;
}

.field-label {
  margin-bottom: 7px;
}

.pet-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pet-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 6px;
  text-align: left;
}

.pet-option:hover,
.pet-option[aria-selected="true"] {
  border-color: rgba(16, 163, 127, 0.65);
  background: var(--accent-soft);
}

.pet-option-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-thumb,
.avatar {
  background-repeat: no-repeat;
  background-size: 800% 900%;
  image-rendering: pixelated;
}

.pet-thumb {
  width: 38px;
  height: 42px;
}

.pet-overlay-card {
  margin-top: 18px;
}

.pet-button {
  position: relative;
  display: grid;
  width: 100%;
  place-items: center;
  min-height: 104px;
  border: 0;
  background: transparent;
  padding: 0;
}

.avatar {
  width: 92px;
  aspect-ratio: 192 / 208;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.12));
}

.avatar[data-flipped="true"] {
  transform: scaleX(-1);
}

.pet-badge {
  position: absolute;
  top: 8px;
  right: calc(50% - 64px);
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.prompt-card {
  position: relative;
  min-height: 76px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.65),
    inset 0 -1px rgba(0, 0, 0, 0.05),
    0 16px 38px rgba(0, 0, 0, 0.08);
  padding: 12px 36px 12px 13px;
}

.prompt-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.prompt-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
}

.prompt-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.spinner {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.16);
  border-top-color: rgba(0, 0, 0, 0.75);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

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

.thread-demo {
  overflow: hidden;
}

.thread-head {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#threadStage {
  display: block;
  width: 100%;
  height: clamp(420px, 58vh, 680px);
  background:
    linear-gradient(120deg, rgba(16, 163, 127, 0.09), transparent 38%),
    linear-gradient(300deg, rgba(239, 106, 168, 0.11), transparent 46%),
    #f8f8f4;
  cursor: crosshair;
}

.metric-row {
  border-top: 1px solid var(--line);
  padding: 11px 18px;
  color: var(--muted);
  font-size: 12px;
}

.metric-row strong {
  color: var(--ink);
  font-size: 13px;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 0 16px;
  }

  .topnav {
    display: none;
  }

  .search {
    display: none;
  }

  .layout {
    display: block;
    padding: 24px 18px 56px;
  }

  .sidebar {
    position: static;
    display: flex;
    max-height: none;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
    padding: 0 0 14px;
  }

  .sidebar-title,
  .nav-group,
  .sidebar a:nth-of-type(n + 8) {
    display: none;
  }

  .sidebar a {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--surface);
  }

  .pets-section {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 44px;
  }
}

@media (max-width: 560px) {
  .brand span:last-child {
    display: none;
  }

  .dashboard {
    display: none;
  }

  .pet-selector {
    grid-template-columns: 1fr;
  }

  .thread-head,
  .metric-row {
    align-items: flex-start;
    flex-direction: column;
  }

  #threadStage {
    height: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .spinner {
    animation: none;
  }
}
