:root {
  color-scheme: dark;
  --bg: #0b0d0c;
  --bg-soft: #111613;
  --panel: rgba(20, 25, 22, 0.88);
  --panel-strong: #181e1a;
  --text: #f0eee6;
  --muted: #9daca2;
  --faint: #65736a;
  --line: rgba(197, 215, 203, 0.14);
  --line-strong: rgba(197, 215, 203, 0.27);
  --accent: #f2a65a;
  --accent-strong: #ffd08a;
  --accent-soft: rgba(242, 166, 90, 0.13);
  --healthy: #72d7a6;
  --warning: #f5bd61;
  --error: #f0796f;
  --local: #8ba6c7;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
  --radius: 24px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f1f0e9;
    --bg-soft: #e7e9df;
    --panel: rgba(252, 251, 246, 0.9);
    --panel-strong: #f8f7f2;
    --text: #1d2520;
    --muted: #5e6d64;
    --faint: #859188;
    --line: rgba(30, 55, 40, 0.13);
    --line-strong: rgba(30, 55, 40, 0.26);
    --accent: #bc6426;
    --accent-strong: #8f3f17;
    --accent-soft: rgba(188, 100, 38, 0.1);
    --healthy: #16865a;
    --warning: #a56a10;
    --error: #c44942;
    --local: #476d9d;
    --shadow: 0 24px 70px rgba(61, 72, 64, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% -10%, var(--accent-soft), transparent 38%),
    linear-gradient(160deg, var(--bg), var(--bg-soft));
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 58%, transparent);
  outline-offset: 3px;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 38rem;
  height: 38rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.08;
  pointer-events: none;
}

.ambient-a {
  top: 10rem;
  left: -19rem;
  background: var(--healthy);
}

.ambient-b {
  right: -20rem;
  bottom: 5rem;
  background: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 74px;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 13px 13px 13px 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.96rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand small,
.eyebrow {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding-right: 0.7rem;
  border-right: 1px solid var(--line);
}

.live-indicator i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--healthy);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--healthy) 13%, transparent);
}

.button {
  min-height: 38px;
  padding: 0.58rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.button:disabled {
  opacity: 0.52;
  cursor: wait;
}

.button-primary {
  border-color: transparent;
  background: var(--accent);
  color: #1f160f;
  font-weight: 700;
}

.button-ghost {
  background: transparent;
}

main {
  width: min(1540px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0 5rem;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.hero h1 {
  max-width: 900px;
  margin: 0.35rem 0 0.7rem;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(2.15rem, 5vw, 5.2rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.hero-copy {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.hero-seal {
  display: grid;
  flex: 0 0 auto;
  width: 132px;
  height: 132px;
  place-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--accent-soft);
  text-align: center;
}

.hero-seal span,
.hero-seal small {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
}

.hero-seal strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.metric,
.panel,
.project-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metric {
  min-height: 130px;
  padding: 1.2rem;
  border-radius: 20px;
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-value {
  display: block;
  margin-top: 0.5rem;
  font-family: Georgia, serif;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  font-weight: 500;
  line-height: 1;
}

.metric-note {
  display: block;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.skeleton {
  background: linear-gradient(100deg, var(--panel) 25%, var(--line) 40%, var(--panel) 55%);
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite linear;
}

.panel {
  border-radius: var(--radius);
  overflow: hidden;
}

.cockpit {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.75fr);
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.orbit-panel,
.inspector,
.attention-panel,
.pet-panel {
  padding: 1.25rem;
}

.panel-heading,
.section-heading,
.pet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h2,
.section-heading h2,
.pet-head h2 {
  margin: 0.18rem 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.legend span,
.project-meta span,
.status-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

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

.healthy {
  color: var(--healthy);
}

.warning {
  color: var(--warning);
}

.error {
  color: var(--error);
}

.local {
  color: var(--local);
}

.orbit {
  position: relative;
  height: 470px;
  margin-top: 1rem;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at center, var(--accent-soft), transparent 18%),
    repeating-radial-gradient(circle at center, transparent 0 76px, var(--line) 77px 78px, transparent 79px 112px);
}

.orbit-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.orbit-lines line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.orbit-core {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 116px;
  height: 116px;
  place-content: center;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--panel-strong) 91%, var(--accent));
  box-shadow: 0 0 55px var(--accent-soft);
  text-align: center;
}

.orbit-core span,
.orbit-core small {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
}

.orbit-core strong {
  font-family: Georgia, serif;
  font-size: 2.15rem;
  line-height: 1;
}

.orbit-node {
  position: absolute;
  z-index: 2;
  width: 104px;
  min-height: 58px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--panel-strong) 93%, transparent);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.orbit-node:hover,
.orbit-node.selected {
  z-index: 3;
  transform: translate(-50%, -50%) scale(1.05);
  border-color: currentColor;
  background: var(--panel-strong);
}

.orbit-node span,
.orbit-node small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orbit-node span {
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 700;
}

.orbit-node small {
  margin-top: 0.18rem;
  color: currentColor;
  font-size: 0.62rem;
}

.status-pill,
.pet-mode,
.queue-count,
.project-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.25rem 0.55rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.68rem;
  white-space: nowrap;
}

.inspector {
  min-height: 560px;
}

.inspector-empty {
  display: grid;
  min-height: 430px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.selected-title {
  margin: 1.5rem 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.1;
}

.selected-description {
  margin: 0.55rem 0 1.2rem;
  color: var(--muted);
}

.facts {
  display: grid;
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.fact {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.fact dt {
  color: var(--muted);
  font-size: 0.74rem;
}

.fact dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.fact code {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.inspector-actions .button {
  flex: 1 1 120px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(390px, 0.9fr);
  gap: 0.9rem;
  margin-bottom: 3rem;
}

.queue-count {
  color: var(--warning);
}

.risk-list {
  display: grid;
  gap: 0;
  margin-top: 0.8rem;
}

.risk-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 0.8rem;
  align-items: start;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.risk-item:first-child {
  border-top: 0;
}

.risk-bar {
  width: 4px;
  min-height: 42px;
  border-radius: 4px;
  background: currentColor;
}

.risk-copy strong,
.risk-copy span {
  display: block;
}

.risk-copy strong {
  font-size: 0.82rem;
}

.risk-copy span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.73rem;
}

.risk-open {
  padding: 0.28rem 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.72rem;
}

.pet-panel {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 75%, transparent), transparent 42%),
    var(--panel);
}

.pet-head {
  justify-content: flex-start;
}

.pet-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 82px;
  height: 74px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 30px 30px 24px 24px;
  background: linear-gradient(145deg, var(--accent-strong), var(--accent));
  box-shadow: 0 12px 40px var(--accent-soft);
  animation: breathe 3.2s ease-in-out infinite;
}

.pet-ear {
  position: absolute;
  top: -10px;
  width: 26px;
  height: 30px;
  border-radius: 9px 16px 2px 16px;
  background: var(--accent);
}

.pet-ear-left {
  left: 7px;
  transform: rotate(-22deg);
}

.pet-ear-right {
  right: 7px;
  transform: scaleX(-1) rotate(-22deg);
}

.pet-face {
  position: absolute;
  inset: 0;
}

.pet-face i {
  position: absolute;
  top: 30px;
  width: 7px;
  height: 10px;
  border-radius: 50%;
  background: #25180f;
}

.pet-face i:first-child {
  left: 25px;
}

.pet-face i:nth-child(2) {
  right: 25px;
}

.pet-face b {
  position: absolute;
  top: 49px;
  left: 50%;
  width: 15px;
  height: 7px;
  border-bottom: 2px solid #25180f;
  border-radius: 50%;
  transform: translateX(-50%);
}

.pet-avatar.alert {
  filter: saturate(0.8);
}

.pet-avatar.alert .pet-face b {
  top: 53px;
  border-top: 2px solid #25180f;
  border-bottom: 0;
}

.pet-mode {
  margin-top: 0.35rem;
  color: var(--accent-strong);
}

.chat-log {
  display: flex;
  min-height: 180px;
  max-height: 310px;
  margin-top: 1rem;
  padding: 0.8rem;
  overflow: auto;
  flex-direction: column;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
}

.chat-bubble {
  max-width: 88%;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.chat-bubble.pet {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  background: var(--panel-strong);
}

.chat-bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: #25180f;
}

.chat-bubble.thinking {
  color: var(--muted);
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.quick-prompts button,
.filter {
  padding: 0.38rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
}

.quick-prompts button:hover,
.filter:hover,
.filter.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.pet-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.pet-form input {
  min-width: 0;
  min-height: 42px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}

.projects-section {
  scroll-margin-top: 90px;
}

.section-heading {
  margin-bottom: 1rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.project-card {
  display: flex;
  min-height: 245px;
  padding: 1.1rem;
  border-radius: 20px;
  flex-direction: column;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease;
}

.project-card:hover,
.project-card.selected {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, currentColor 70%, var(--line));
}

.project-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.project-number {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.project-card h3 {
  margin: 1rem 0 0.25rem;
  color: var(--text);
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 1.3rem;
  font-weight: 500;
}

.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 1rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.project-domain {
  margin-top: 0.65rem;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  overflow-wrap: anywhere;
}

.project-tag {
  color: currentColor;
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 40;
  max-width: min(440px, calc(100% - 2rem));
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes shimmer {
  to {
    background-position-x: -300%;
  }
}

@keyframes breathe {
  50% {
    transform: translateY(-3px) rotate(1deg);
  }
}

@media (max-width: 1150px) {
  .cockpit,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .inspector {
    min-height: 0;
  }

  .inspector-empty {
    min-height: 180px;
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-seal {
    width: 96px;
    height: 96px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legend {
    display: none;
  }

  .orbit {
    height: 540px;
  }

  .orbit-node {
    width: 92px;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    justify-content: flex-start;
  }
}

@media (max-width: 500px) {
  main {
    width: min(100% - 1rem, 1540px);
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 105px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .pet-head {
    align-items: flex-start;
  }

  .pet-avatar {
    transform: scale(0.85);
    transform-origin: top left;
  }

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

  .risk-item {
    grid-template-columns: 8px 1fr;
  }

  .risk-open {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
