/* Estate shell: one header, footer, token set, controls and states shared by Estate public pages and workspaces
   (ascode/design/ESTATE-WEB-EXPERIENCE.md §§3, 16). Product identity, navigation and content stay with each site.
   The classes are the contract for native pages and for framework adapters alike; no class declares a literal colour
   outside the token blocks. */
:root {
  --estate-bg: #fbfaf7; --estate-surface: #ffffff; --estate-ink: #1d1b22; --estate-muted: #5b6475;
  --estate-line: #e4e1da; --estate-accent: #6b4de6; --estate-accent-ink: #ffffff; --estate-focus: #2b6cb0;
  --estate-warn: #b4541c;
  --estate-radius: 12px; --estate-header-h: 64px; --estate-gutter: clamp(16px, 4vw, 40px); --estate-measure: 1120px;
  --estate-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --estate-text-sm: 13px; --estate-text-base: 16px; --estate-text-lg: 20px; --estate-text-xl: clamp(28px, 4vw, 40px);
  --estate-space-1: 4px; --estate-space-2: 8px; --estate-space-3: 16px; --estate-space-4: 24px; --estate-space-5: 40px;
  --estate-motion: 160ms;
  --cs-ink: var(--estate-ink); --cs-muted: var(--estate-muted); --cs-line: var(--estate-line);
  --cs-panel: var(--estate-surface); --cs-accent: var(--estate-accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --estate-bg: #131218; --estate-surface: #1c1b22; --estate-ink: #eceaf2; --estate-muted: #a7a3b5;
    --estate-line: #2e2c37; --estate-accent: #a28bff; --estate-accent-ink: #131218; --estate-focus: #8cc4ff;
    --estate-warn: #f0a070;
  }
}
:root[data-theme="dark"] {
  --estate-bg: #131218; --estate-surface: #1c1b22; --estate-ink: #eceaf2; --estate-muted: #a7a3b5;
  --estate-line: #2e2c37; --estate-accent: #a28bff; --estate-accent-ink: #131218; --estate-focus: #8cc4ff;
  --estate-warn: #f0a070;
}
@media (prefers-reduced-motion: reduce) { :root { --estate-motion: 0ms; } }

.estate-page {
  margin: 0; background: var(--estate-bg); color: var(--estate-ink);
  font: var(--estate-text-base)/1.55 var(--estate-font);
}
.estate-page :focus-visible { outline: 3px solid var(--estate-focus); outline-offset: 2px; }
.estate-skip { position: absolute; left: -9999px; }
.estate-skip:focus {
  left: var(--estate-gutter); top: 8px; z-index: 30; background: var(--estate-surface); padding: 8px 12px;
}

/* Header (§16.3): one row of brand -> navigation or Menu -> one optional action -> Identity and Settings, rendered by
   renderEstateHeader() in estate-shell.mjs. The look is the accepted Intelligence reference and is owned here, so
   every site shows the same header; sites only map their palette onto the --estate-* tokens (Creator walkthrough
   2026-11-20: one look across sites, a larger product name, "Labs" in the brand's own type). */
.estate-header {
  position: relative; z-index: 20; display: flex; align-items: center; gap: 32px; min-height: var(--estate-header-h);
  padding: 22px max(var(--estate-gutter), (100% - var(--estate-measure)) / 2); background: transparent;
}
.estate-brand {
  display: inline-flex; align-items: center; gap: var(--estate-space-2); min-width: 0; font-weight: 700; color: inherit;
  text-decoration: none;
}
.estate-brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--estate-accent); color: var(--estate-accent-ink); font-size: 15px;
}
.estate-brand-labs { font-weight: 500; color: var(--estate-muted); }
.estate-brand-product { font-weight: 500; color: var(--estate-muted); }
:is(.estate-header, .estate-footer) .estate-brand { font-weight: 600; color: var(--estate-ink); }
:is(.estate-header, .estate-footer) .estate-brand-mark {
  flex: none; display: inline-block; width: 34px; height: 34px; border-radius: 50%; text-align: center;
  font: italic 30px/33px Georgia, "Times New Roman", serif;
}
:is(.estate-header, .estate-footer) .estate-brand-wordmark {
  display: inline-flex; align-items: baseline; gap: .3em; white-space: nowrap; font-size: 27px; line-height: 1;
  letter-spacing: -1.2px;
}
/* Labs shares the wordmark's font and weight, one step smaller and quieter; the product name reads as a name. */
:is(.estate-header, .estate-footer) .estate-brand-labs { font-size: .78em; font-weight: 600; letter-spacing: -.6px; }
:is(.estate-header, .estate-footer) .estate-brand-product {
  font-size: .78em; font-weight: 500; letter-spacing: -.4px; color: var(--estate-ink);
}
.estate-nav { display: flex; gap: 28px; margin-left: auto; }
.estate-nav a {
  padding: 6px 0; color: inherit; text-decoration: none; font-size: 14px; white-space: nowrap;
  text-underline-offset: 6px;
}
.estate-nav a:hover, .estate-nav a[aria-current="page"] { text-decoration: underline; }
.estate-nav:has(.estate-nav-group) { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.estate-nav:has(.estate-nav-group) a:focus-visible { outline-offset: -2px; }
.estate-nav .estate-nav-group:not([hidden]) { display: flex; gap: inherit; }
.estate-menu { display: none; }
.estate-header-action {
  display: inline-flex; align-items: center; gap: var(--estate-space-2); white-space: nowrap; min-height: 40px;
  padding: 0 16px; border-radius: 999px; border: 1px solid var(--estate-line); color: inherit;
  text-decoration: none; font-size: 13px; transition: border-color var(--estate-motion);
}
.estate-header-action:hover { border-color: var(--estate-accent); }
.estate-controls { display: flex; align-items: center; flex-shrink: 0; gap: var(--estate-space-2); }
.estate-nav ~ .estate-controls, .estate-header-action ~ .estate-controls { margin-left: 0; }
.estate-brand + .estate-controls { margin-left: auto; }
.estate-theme {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--estate-line);
  background: none; color: inherit; font: inherit; font-size: 13px; cursor: pointer;
}
/* Settings: one icon button at the far right of the header; the panel is a native modal dialog. */
.estate-settings-button {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; min-height: 36px; padding: 0;
  border-radius: 999px; border: 1px solid var(--estate-line); background: none; color: inherit; cursor: pointer;
}
.estate-settings-button:hover { border-color: var(--estate-accent); }
.estate-settings-button svg { width: 18px; height: 18px; }
/* Shared Estate Contribute entry (contribute.mjs): one renderer for every placement; unavailable is a quiet state. */
.estate-contribute { display: grid; gap: var(--estate-space-2); max-width: 520px; }
section.estate-contribute h2 { margin: 0; font-size: var(--estate-text-lg); }
.estate-contribute-lead, .estate-contribute-bounds, .estate-contribute-notice { margin: 0; }
.estate-contribute-bounds, .estate-contribute-notice { color: var(--estate-muted); font-size: 13px; }
.estate-contribute-form { display: grid; gap: var(--estate-space-2); }
.estate-contribute-form[hidden] { display: none; }
.estate-contribute-form input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--estate-line); border-radius: var(--estate-radius);
  background: var(--estate-surface); color: inherit; font: inherit; max-width: 220px;
}
.estate-contribute-go {
  justify-self: start; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--estate-accent);
  background: var(--estate-accent); color: var(--estate-accent-ink); font: inherit; cursor: pointer;
}
.estate-contribute-go:disabled { opacity: .55; cursor: not-allowed; }
.estate-contribute :focus-visible { outline: 3px solid var(--estate-focus); outline-offset: 2px; }
.estate-contribute-status { margin: 0; min-height: 1.4em; font-size: 14px; }
.estate-contribute[data-contribute-state="invalid"] .estate-contribute-status,
.estate-contribute[data-contribute-state="failed"] .estate-contribute-status { color: var(--estate-warn); }
.estate-settings {
  width: min(440px, calc(100vw - 32px)); max-height: min(80vh, 720px);
  margin: 72px max(16px, env(safe-area-inset-right)) auto auto;
  padding: 0; overflow: auto; color: var(--estate-ink); background: var(--estate-surface);
  border: 1px solid var(--estate-line); border-radius: var(--estate-radius); box-shadow: 0 18px 48px rgb(0 0 0 / .22);
  font: var(--estate-text-base)/1.5 var(--estate-font);
}
.estate-settings::backdrop { background: rgb(0 0 0 / .28); }
.estate-settings :focus-visible { outline: 3px solid var(--estate-focus); outline-offset: 2px; }
.estate-settings-head {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  gap: var(--estate-space-3); padding: var(--estate-space-3) var(--estate-space-4);
  background: var(--estate-surface); border-bottom: 1px solid var(--estate-line);
}
.estate-settings-head h2 { margin: 0; font-size: var(--estate-text-lg); }
.estate-settings-close {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--estate-line); background: none;
  color: inherit; font: inherit; font-size: 14px; cursor: pointer;
}
.estate-settings > .estate-settings-note { margin: var(--estate-space-3) var(--estate-space-4) 0; }
.estate-settings-section {
  padding: var(--estate-space-3) var(--estate-space-4); border-top: 1px solid var(--estate-line);
}
.estate-settings-section:first-of-type { border-top: 0; }
.estate-settings-section h3 { margin: 0 0 var(--estate-space-2); font-size: 15px; }
.estate-settings-note {
  margin: 0 0 var(--estate-space-2); color: var(--estate-muted); font-size: var(--estate-text-sm);
}
.estate-settings-fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: var(--estate-space-1); }
.estate-settings-fieldset legend {
  padding: 0; margin-bottom: var(--estate-space-1); font-size: var(--estate-text-sm); color: var(--estate-muted);
}
.estate-settings-choice {
  display: flex; align-items: center; gap: var(--estate-space-2); min-height: 36px; cursor: pointer;
}
.estate-settings-choice:has(input:disabled) { cursor: not-allowed; color: var(--estate-muted); }
.estate-settings-body { display: grid; gap: var(--estate-space-2); }
.estate-settings-body select {
  width: 100%; min-height: 40px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--estate-line);
  background: var(--estate-bg); color: inherit; font: inherit; font-size: 14px;
}
.estate-settings-body .estate-settings-action {
  justify-self: start; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--estate-accent);
  background: none; color: inherit; font: inherit; font-size: 14px; cursor: pointer;
}
.estate-settings-status { margin: 0; font-size: var(--estate-text-sm); }
.estate-settings-status[data-state="unsupported"],
.estate-settings-status[data-state="failed"] { color: var(--estate-warn); }

/* The common Surface mounts here (compact). Its panel opens below the header without moving the page. */
.estate-identity { position: relative; max-width: 360px; font-size: 13px; }
/* A page that opens identity on request (Estate) puts one plain button in the slot; it matches the Settings pill. */
.estate-identity > button {
  min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--estate-line); background: none;
  color: inherit; font: inherit; cursor: pointer; white-space: nowrap;
  /* A long account label ("CyOS · Signed in") shortens with an ellipsis instead of pushing Settings off-screen. */
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.estate-identity > button:hover { border-color: var(--estate-accent); }
.estate-identity > details > div {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, 92vw); max-height: 70vh; overflow: auto;
  padding: 12px; background: var(--estate-surface); border: 1px solid var(--estate-line);
  border-radius: var(--estate-radius); box-shadow: 0 12px 32px rgb(0 0 0 / .14);
}
.estate-identity summary {
  cursor: pointer; color: var(--estate-muted); list-style-position: inside; white-space: nowrap; min-height: 36px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--estate-line); border-radius: 999px;
}
/* Before the compact Surface mounts, a host may show plain loading text in the slot: keep it to one line. */
.estate-header .estate-identity:not(:has(details)) {
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.estate-identity .cs-storage { margin: 0 0 8px; color: var(--estate-muted); font-size: 12px; }
.estate-identity .cs-signin { display: inline-block; margin: 0 8px 0 0; }

/* Return: where a sub-page sits and how to go back; one link, site-owned text. */
.estate-return {
  max-width: var(--estate-measure); margin: 0 auto; padding: var(--estate-space-3) var(--estate-gutter) 0;
  font-size: var(--estate-text-sm); color: var(--estate-muted);
}
.estate-return a { color: inherit; }

.estate-main { max-width: var(--estate-measure); margin: 0 auto; padding: 32px var(--estate-gutter) 96px; }
.estate-card {
  background: var(--estate-surface); border: 1px solid var(--estate-line); border-radius: var(--estate-radius);
  padding: 20px;
}
.estate-note { color: var(--estate-muted); font-size: 14px; }

/* Controls and states. The text is the fact; data-state carries the same fact for machines. */
.estate-button {
  display: inline-flex; align-items: center; gap: var(--estate-space-2); min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--estate-line); background: var(--estate-surface); color: inherit;
  font: inherit; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: border-color var(--estate-motion), background-color var(--estate-motion);
}
.estate-button:hover { border-color: var(--estate-accent); }
.estate-button.primary {
  background: var(--estate-accent); border-color: var(--estate-accent); color: var(--estate-accent-ink);
}
.estate-button.quiet { border-color: transparent; background: none; }
.estate-button[disabled], .estate-button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.estate-field { display: grid; gap: 6px; }
.estate-field > label { font-weight: 600; font-size: var(--estate-text-sm); }
.estate-field input, .estate-field textarea, .estate-field select {
  box-sizing: border-box; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--estate-line); background: var(--estate-bg); color: inherit; font: inherit;
}
.estate-field .estate-hint { font-size: 12px; color: var(--estate-muted); }
.estate-disclosure {
  background: var(--estate-surface); border: 1px solid var(--estate-line); border-radius: var(--estate-radius);
}
.estate-disclosure > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--estate-space-2); min-height: 44px;
  padding: 10px 16px; cursor: pointer; font-weight: 600;
}
.estate-disclosure > :not(summary) { padding: 0 16px 16px; }
.estate-status {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--estate-line); color: var(--estate-muted);
}
.estate-status[data-state="loading"] { border-style: dashed; }
.estate-status[data-state="empty"] { font-style: italic; }
.estate-status[data-state="error"], .estate-status[data-state="unavailable"] {
  border-color: var(--estate-warn); color: var(--estate-ink);
}
.estate-status[data-state="confirmed"] { border-color: var(--estate-accent); color: var(--estate-ink); }

/* Footer: one structure from one configuration (estate-shell.mjs renderFooter): the Labs brand and programme purpose,
   grouped destinations (this site, the Estate, rights and contact), confirmed legal lines and the note that states
   which edition/processing applies to this page. Clearly separated from the page: its own tint, a strong rule and
   generous spacing (Creator review 2026-11-15). */
.estate-footer {
  margin-top: var(--estate-space-5); border-top: 3px solid var(--estate-accent);
  background: color-mix(in srgb, var(--estate-surface) 85%, var(--estate-accent) 15%);
  color: var(--estate-ink); font-size: var(--estate-text-sm); line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .estate-footer { background: color-mix(in srgb, var(--estate-surface) 92%, var(--estate-accent) 8%); }
}
:root[data-theme="dark"] .estate-footer { background: color-mix(in srgb, var(--estate-surface) 92%, var(--estate-accent) 8%); }
.estate-footer-inner {
  max-width: var(--estate-measure); margin: 0 auto; display: grid; gap: var(--estate-space-4);
  padding: var(--estate-space-5) var(--estate-gutter);
}
.estate-footer-main { display: grid; gap: 8px; max-width: 60ch; }
.estate-footer-main .estate-brand { color: var(--estate-ink); text-decoration: none; }
.estate-footer-main .estate-brand:hover { text-decoration: none; opacity: .85; }
.estate-footer-line { margin: 0; font-size: var(--estate-text-base); }
.estate-footer-availability { margin: 0; color: var(--estate-muted); }
.estate-footer-groups { display: grid; gap: var(--estate-space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.estate-footer-group { display: grid; gap: 8px; align-content: start; }
.estate-footer-heading {
  margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--estate-muted);
}
/* Compact lists (Creator walkthrough 2026-11-21): 28 px targets, above the WCAG 2.2 AA 24 px minimum. */
.estate-footer-links, .estate-footer-estate, .estate-footer-contact {
  display: grid; gap: 2px; margin: 0; padding: 0; list-style: none;
}
.estate-footer li { margin: 0; }
.estate-footer a, .estate-footer-links button {
  color: inherit; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; min-height: 28px; display: inline-flex; align-items: center; text-align: left;
}
.estate-footer a:hover, .estate-footer-links button:hover { color: var(--estate-accent); }
.estate-footer-rights { margin: 0; color: var(--estate-muted); }
.estate-footer-legal { display: grid; gap: 4px; padding-top: 14px; border-top: 1px solid var(--estate-line); }
.estate-footer-legal p { margin: 0; color: var(--estate-muted); }
.estate-footer-note {
  margin: 0; padding-top: 14px; border-top: 1px solid var(--estate-line); font-size: 12px; color: var(--estate-muted);
}

/* One optional Chat, bottom right, above page content and below dialogs. */
.estate-chat-dock {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 25;
}
.estate-chat-unavailable {
  max-width: 260px; padding: 10px 12px; border-radius: var(--estate-radius); background: var(--estate-surface);
  border: 1px solid var(--estate-line); font-size: 13px; color: var(--estate-muted);
}

@media (max-width: 1080px) {
  .estate-nav { display: none; }
  .estate-menu { display: block; position: relative; margin-left: auto; }
  .estate-menu summary {
    min-height: 44px; display: flex; align-items: center; padding: 0 8px; cursor: pointer; list-style: none;
  }
  .estate-menu nav {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; min-width: 220px;
    padding: 8px 16px;
    background: var(--estate-surface); border: 1px solid var(--estate-line); border-radius: var(--estate-radius);
    box-shadow: 0 12px 32px rgb(0 0 0 / .16);
  }
  .estate-menu nav a { min-height: 44px; display: flex; align-items: center; color: inherit; text-decoration: none; }
  .estate-menu nav:has(.estate-nav-group) {
    box-sizing: border-box; max-width: calc(100vw - 2 * var(--estate-gutter)); max-height: min(60vh, 28rem);
    overflow: auto; overflow-wrap: anywhere;
  }
}
@media (max-width: 760px) {
  .estate-brand-product, .estate-theme-label { display: none; }
  .estate-header { gap: var(--estate-space-2); padding-block: 16px; }
  .estate-header .estate-brand-mark { width: 30px; height: 30px; font-size: 27px; line-height: 29px; }
  .estate-header .estate-brand-wordmark { font-size: 24px; letter-spacing: -1px; }
  .estate-menu summary, .estate-identity summary { min-height: 44px; }
  .estate-header .estate-brand, .estate-menu, .estate-settings-button { flex: none; }
  /* Narrow headers: brand, Menu and Settings keep their size; only the identity label gives way (360 px audit). */
  .estate-controls { flex: 0 1 auto; min-width: 0; }
  .estate-identity { flex: 0 1 auto; min-width: 0; max-width: 34vw; }
  .estate-header-action { font-size: 13px; padding: 0 10px; }
  .estate-theme, .estate-identity .cs-signin, .estate-header-action { min-height: 44px; }
  .estate-settings-button { width: 44px; min-height: 44px; }
  .estate-settings { margin: 64px auto auto; }
  .estate-settings-choice, .estate-settings-close { min-height: 44px; }
  .estate-footer-groups { grid-template-columns: 1fr; }
  .estate-footer-inner { padding: var(--estate-space-4) var(--estate-gutter); }
}
/* 320 CSS px: the optional action moves into the page (its destination stays in Menu or the page). */
@media (max-width: 400px) {
  .estate-header-action { display: none; }
  .estate-header { padding-inline: var(--estate-space-3); }
  .estate-header .estate-brand-wordmark { font-size: 21px; }
  .estate-menu summary { min-width: 44px; justify-content: center; }
  .estate-menu-label { display: none; }
  .estate-identity { max-width: none; }
  .estate-identity > button { padding: 0 10px; }
}
