* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: var(--user-text-size, 100%);
}

html[data-color-mode="dark"] {
  color-scheme: dark;
  --color-background: var(--color-neutral-950);
  --color-surface: var(--color-neutral-900);
  --color-surface-subtle: var(--color-neutral-900);
  --color-text: var(--color-neutral-50);
  --color-text-muted: var(--color-neutral-300);
  --color-border: var(--color-neutral-700);
}

html[data-font="system"] body {
  font-family: var(--font-sans);
}

html[data-font="humanist"] body {
  font-family: "Segoe UI", "Noto Sans", var(--font-sans);
}

html[data-font="serif"] body {
  font-family: Georgia, "Noto Serif", serif;
}

html[data-spacing="compact"] {
  --shell-density: 0.8;
}

html[data-spacing="comfortable"] {
  --shell-density: 1;
}

html[data-spacing="spacious"] {
  --shell-density: 1.25;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--user-background, var(--color-background));
  color: var(--page-text, var(--color-text));
  line-height: var(--line-height-normal);
}

body:has(dialog[open]) {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  background: var(--color-brand-900);
  color: var(--color-neutral-0);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
}

.header-inner,
.main-content,
.footer-inner {
  width: min(calc(100% - 2rem), var(--content-wide));
  margin-inline: auto;
}

.header-inner {
  padding-block: var(--space-5) 0;
}

.identity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.brand-lockup {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 2.75rem;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 32%);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 7%);
  font-weight: var(--font-weight-bold);
}

.brand-copy,
.assistant-copy {
  min-width: 0;
  display: grid;
}

.project-label,
.eyebrow,
.card-label,
.dialog-eyebrow {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-label {
  color: rgb(255 255 255 / 72%);
}

.project-name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.assistant-button,
.header-control,
.language-button,
.menu-button,
.dialog-close,
.primary-button,
.secondary-button,
.info-list summary {
  min-height: var(--touch-target-min);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.assistant-button,
.header-control,
.language-button,
.menu-button {
  border: 1px solid rgb(255 255 255 / 26%);
  background: transparent;
  color: inherit;
}

.assistant-button:hover,
.header-control:hover,
.language-button:hover,
.menu-button:hover {
  background: rgb(255 255 255 / 10%);
}

.assistant-button {
  min-width: 11.5rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  text-align: left;
}

.assistant-avatar {
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--user-accent, var(--app-accent));
  color: var(--user-accent-contrast, var(--app-on-accent));
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
}

.assistant-name {
  overflow-wrap: anywhere;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-compact);
}

.assistant-presence,
.assistant-dialog-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: rgb(255 255 255 / 76%);
  font-size: var(--font-size-xs);
}

.assistant-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--color-success);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 20%);
}

.language-selector {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: var(--radius-md);
}

.language-button {
  min-width: var(--touch-target-min);
  padding-inline: var(--space-2);
  border-color: transparent;
}

.language-button[aria-pressed="true"] {
  background: var(--user-accent, var(--app-accent));
  color: var(--user-accent-contrast, var(--app-on-accent));
}

.header-control,
.menu-button {
  min-width: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  white-space: nowrap;
}

.ecosystem-link {
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  padding-inline: var(--space-3);
  border-radius: var(--radius-md);
  color: rgb(255 255 255 / 88%);
  font-size: var(--font-size-sm);
  text-decoration: none;
  white-space: nowrap;
}

.ecosystem-link:hover {
  background: rgb(255 255 255 / 10%);
  color: var(--color-neutral-0);
}

.navigation-row {
  display: flex;
  align-items: center;
  margin-top: var(--space-4);
}

.menu-button {
  display: none;
}

.primary-nav {
  min-width: 0;
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
}

.nav-link {
  position: relative;
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  padding-inline: var(--space-4);
  color: rgb(255 255 255 / 76%);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--color-neutral-0);
}

.nav-link.is-active::after {
  content: "";
  position: absolute;
  right: var(--space-4);
  bottom: 0;
  left: var(--space-4);
  height: 3px;
  border-radius: var(--radius-pill) var(--radius-pill) 0 0;
  background: var(--user-accent, var(--app-accent));
}

.main-content {
  flex: 1;
  padding-block: calc(var(--space-12) * var(--shell-density, 1));
}

.hero {
  max-width: var(--content-narrow);
  margin-bottom: calc(var(--space-12) * var(--shell-density, 1));
}

.eyebrow,
.card-label,
.dialog-eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--page-muted, var(--color-text-muted));
}

.hero h1,
.simple-section h2 {
  color: var(--page-text, var(--color-text));
}

.hero h1,
.status-panel h2,
.simple-section h2,
.dashboard-card h2,
.shell-dialog h2 {
  margin-top: 0;
}

.hero h1 {
  margin-bottom: var(--space-4);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.hero-copy {
  margin: 0;
  color: var(--page-muted, var(--color-text-muted));
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
}

.shell-notice {
  margin: var(--space-5) 0 0;
  padding: var(--space-3) var(--space-4);
  border-inline-start: 3px solid var(--user-accent, var(--app-accent));
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--space-5) * var(--shell-density, 1));
}

.dashboard-card {
  min-width: 0;
  min-height: 15rem;
  display: flex;
  flex-direction: column;
  padding: calc(var(--space-6) * var(--shell-density, 1));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
}

.dashboard-card h2 {
  margin-bottom: var(--space-3);
  font-size: var(--font-size-xl);
}

.dashboard-card p:not(.card-label) {
  margin-top: 0;
  margin-bottom: var(--space-5);
  color: var(--color-text-muted);
}

.card-link {
  width: fit-content;
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  margin-top: auto;
  color: var(--color-brand-700);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

html[data-color-mode="dark"] .card-link {
  color: var(--color-brand-300);
}

.card-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.status-panel {
  margin-top: calc(var(--space-12) * var(--shell-density, 1));
  padding: calc(var(--space-6) * var(--shell-density, 1));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.status-panel > div:first-child {
  margin-bottom: var(--space-5);
}

.status-panel h2,
.simple-section h2 {
  margin-bottom: 0;
  font-size: var(--font-size-2xl);
}

.status-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
}

.status-list > div {
  min-width: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.status-list dt {
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.status-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: var(--font-weight-semibold);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  display: inline-block;
  margin-right: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-success);
}

.simple-section {
  max-width: var(--content-narrow);
  margin-top: calc(var(--space-12) * var(--shell-density, 1));
}

.simple-section p:last-child {
  margin-bottom: 0;
  color: var(--page-muted, var(--color-text-muted));
}

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.footer-inner {
  display: grid;
  gap: var(--space-1);
  padding-block: var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.footer-line {
  margin: 0;
}

.build-id {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  overflow-wrap: anywhere;
}

.shell-dialog {
  width: min(calc(100% - 2rem), 36rem);
  max-height: min(44rem, calc(100dvh - 2rem));
  margin: auto;
  padding: var(--space-6);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

.shell-dialog:not([open]) {
  display: none;
}

.shell-dialog::backdrop {
  background: rgb(17 24 39 / 70%);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.dialog-header h2 {
  margin-bottom: 0;
  font-size: var(--font-size-2xl);
}

.dialog-eyebrow {
  color: var(--color-text-muted);
}

.dialog-close {
  width: var(--touch-target-min);
  flex: 0 0 var(--touch-target-min);
  border: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  color: var(--color-text);
  font-size: var(--font-size-xl);
}

.dialog-close:hover,
.secondary-button:hover,
.info-list summary:hover {
  background: var(--app-accent-soft);
}

.assistant-panel {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.assistant-avatar-large {
  width: 3rem;
  height: 3rem;
  flex-basis: 3rem;
  font-size: var(--font-size-sm);
}

.assistant-dialog-status {
  margin-top: 0;
  color: var(--color-text-muted);
}

.assistant-dialog-status .assistant-status-dot {
  box-shadow: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.setting-field {
  min-width: 0;
  display: grid;
  gap: var(--space-2);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.setting-field select,
.color-control {
  min-height: var(--touch-target-min);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.setting-field select {
  width: 100%;
  padding-inline: var(--space-3);
}

.color-control {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
}

.color-control input[type="color"] {
  width: var(--touch-target-min);
  height: calc(var(--touch-target-min) - var(--space-2));
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-control output {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  overflow-wrap: anywhere;
}

.dialog-status {
  min-height: 1.5em;
  margin: var(--space-4) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.primary-button,
.secondary-button {
  padding-inline: var(--space-4);
  border: 1px solid var(--color-border);
}

.primary-button {
  border-color: var(--user-accent, var(--app-accent));
  background: var(--user-accent, var(--app-accent));
  color: var(--user-accent-contrast, var(--app-on-accent));
}

.primary-button:hover {
  filter: brightness(0.94);
}

.secondary-button {
  background: var(--color-surface);
  color: var(--color-text);
}

.info-list {
  display: grid;
  gap: var(--space-1);
}

.info-list details {
  border-radius: var(--radius-md);
}

.info-list summary {
  display: flex;
  align-items: center;
  padding-inline: var(--space-3);
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.info-list details > p {
  padding: 0 var(--space-3) var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.info-list hr {
  width: 100%;
  height: 1px;
  margin: var(--space-3) 0;
  border: 0;
  background: var(--color-border);
}

.info-list p {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 80rem) {
  .identity-row {
    align-items: flex-start;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 64rem) {
  .identity-row {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .status-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 48rem) {
  .header-inner,
  .main-content,
  .footer-inner {
    width: min(calc(100% - 1.5rem), var(--content-wide));
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .assistant-button,
  .ecosystem-link {
    grid-column: 1 / -1;
  }

  .assistant-button,
  .ecosystem-link,
  .header-control,
  .language-selector {
    width: 100%;
  }

  .ecosystem-link {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .language-button {
    flex: 1;
  }

  .navigation-row {
    display: grid;
  }

  .menu-button {
    display: inline-flex;
    width: fit-content;
    margin-bottom: var(--space-3);
  }

  .primary-nav {
    display: none;
    flex-direction: column;
    padding-bottom: var(--space-4);
    overflow: visible;
  }

  .primary-nav.is-open {
    display: flex;
  }

  .nav-link.is-active::after {
    top: 0.5rem;
    right: auto;
    bottom: 0.5rem;
    left: 0;
    width: 3px;
    height: auto;
    border-radius: var(--radius-pill);
  }

  .card-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-card {
    min-height: 0;
  }
}

@media (max-width: 30rem) {
  .project-label {
    font-size: 0.68rem;
  }

  .project-name {
    font-size: var(--font-size-lg);
  }

  .brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    flex-basis: 2.5rem;
  }

  .status-list {
    grid-template-columns: 1fr;
  }

  .shell-dialog {
    width: min(calc(100% - 1rem), 36rem);
    padding: var(--space-4);
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
  }
}
