/* ==========================================================================
   AgentMiniOffice design system
   Tokens -> reset -> primitives -> layouts -> views.
   Rules that keep this honest:
   - every colour, space, radius, and duration comes from a token
   - every interactive element has hover, focus-visible, active, disabled states
   - no gradients used as decoration, no glow, no drop shadow beyond the token scale
   - motion is opt-out aware via prefers-reduced-motion
   ========================================================================== */

/* ---------- 1. tokens ---------- */

:root {
  color-scheme: light;

  --bg: #f5f2ea;
  --surface: #fffdf8;
  --surface-2: #efe9dc;
  --surface-3: #e6dfcf;
  --border: #ddd4c3;
  --border-strong: #c8bda8;

  --text: #241f1a;
  --text-2: #4a4238;
  --muted: #7c7264;

  --accent: #4f6b45;
  --accent-hover: #3f5637;
  --accent-soft: #e4eade;
  --on-accent: #fdfbf6;

  --ok: #4f6b45;
  --warn: #9c5236;
  --warn-soft: #f6e6dd;
  --info: #47647f;
  --info-soft: #e3eaf1;
  --caution: #96681f;
  --caution-soft: #f7ecd8;
  --ocean: #3f6585;
  --ocean-soft: #e2ebf3;
  --plum: #77516f;
  --plum-soft: #efe4ec;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;
  --s8: 44px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;

  --shadow-1: 0 1px 2px rgb(36 31 26 / 6%);
  --shadow-2: 0 6px 20px rgb(36 31 26 / 8%);

  --fs-xs: 0.72rem;
  --fs-sm: 0.8rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.3rem;
  --fs-2xl: 1.85rem;

  --t-fast: 120ms;
  --t-med: 200ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #16140f;
  --surface: #1f1c17;
  --surface-2: #272320;
  --surface-3: #322d28;
  --border: #38322b;
  --border-strong: #4a4238;

  --text: #ece5d8;
  --text-2: #cabfae;
  --muted: #9d9184;

  --accent: #93b184;
  --accent-hover: #a8c69a;
  --accent-soft: #26311f;
  --on-accent: #14120e;

  --ok: #93b184;
  --warn: #d99177;
  --warn-soft: #33241d;
  --info: #93b3d0;
  --info-soft: #212a33;
  --caution: #d7a55c;
  --caution-soft: #332a1a;
  --ocean: #8db2d4;
  --ocean-soft: #1d2733;
  --plum: #c095b8;
  --plum-soft: #2a1f2a;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 8px 24px rgb(0 0 0 / 45%);
}

/* ---------- 2. reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Author display rules beat the UA rule for [hidden], so state it once, properly. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    var(--fs-md) / 1.55 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
figure {
  margin: 0;
}

h1 {
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: -0.015em;
}

h2 {
  font-size: var(--fs-lg);
  font-weight: 620;
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--fs-xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

pre {
  margin: 0;
  overflow-x: auto;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* Tone classes give a component one meaningful colour without inventing a new one. */
.tone-sage {
  --tone: var(--accent);
  --tone-soft: var(--accent-soft);
}

.tone-ocean {
  --tone: var(--ocean);
  --tone-soft: var(--ocean-soft);
}

.tone-plum {
  --tone: var(--plum);
  --tone-soft: var(--plum-soft);
}

.tone-clay {
  --tone: var(--warn);
  --tone-soft: var(--warn-soft);
}

.tone-caution {
  --tone: var(--caution);
  --tone-soft: var(--caution-soft);
}

/* ---------- 3. primitives ---------- */

.btn {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  --btn-border: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px 16px;
  border: 1px solid var(--btn-border);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

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

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-quiet {
  --btn-bg: transparent;
  --btn-fg: var(--text-2);
  --btn-border: var(--border);
}

.btn-quiet:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--muted);
  --btn-border: transparent;
  padding-inline: var(--s2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  --btn-bg: transparent;
  --btn-fg: var(--warn);
  --btn-border: color-mix(in srgb, var(--warn) 45%, transparent);
}

.btn-danger:hover {
  background: var(--warn-soft);
}

.btn-sm {
  padding: 6px 11px;
  font-size: var(--fs-xs);
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  pointer-events: none;
  opacity: 0.7;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.card-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--tone-soft, var(--surface-2));
  color: var(--tone, var(--muted));
  flex: 0 0 auto;
}

.card-accent {
  border-left: 3px solid var(--tone, var(--accent));
}

.card-head p {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: var(--s1);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-2);
}

.required-mark { color: var(--danger, var(--text)); }
.password-control { position: relative; }
.password-control .input { padding-inline-end: 3rem; }
.password-eye {
  position: absolute;
  inset-block: 1px;
  inset-inline-end: 1px;
  inline-size: 2.6rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.password-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.password-eye:active { background: var(--surface-2); }

.field small {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: var(--accent-soft);
  color: var(--ok);
}

.badge-info {
  border-color: color-mix(in srgb, var(--info) 40%, transparent);
  background: var(--info-soft);
  color: var(--info);
}

.badge-accent {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-demo {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: transparent;
  color: var(--warn);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted);
}

.dot-online {
  background: var(--ok);
}

.dot-stale {
  background: color-mix(in srgb, var(--warn) 70%, var(--muted));
}

.dot-offline {
  background: var(--border-strong);
}

.dot-lobby {
  background: var(--border-strong);
  opacity: 0.6;
}

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

.small {
  font-size: var(--fs-sm);
}

.tiny {
  font-size: var(--fs-xs);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-sm);
}

.code-block {
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  padding: var(--s6);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: var(--s4) 0;
}

.skeleton {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  animation: pulse 1.4s var(--ease) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* ---------- 4. toasts ---------- */

.toasts {
  position: fixed;
  top: calc(56px + var(--s3));
  right: var(--s4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(380px, calc(100vw - var(--s6)));
  pointer-events: none;
}

.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s3) var(--s3) calc(var(--s3) + 2px) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in var(--t-med) var(--ease);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.toast p {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.toast button:hover {
  color: var(--text);
}

/* Life strip: shows how long the message will stay. */
.toast::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: currentColor;
  opacity: 0.35;
  transform-origin: left;
  animation: toast-life linear forwards;
  animation-duration: var(--toast-life, 4200ms);
}

.toast-ok {
  border-left-color: var(--ok);
  color: var(--ok);
}

.toast-ok .toast-icon {
  background: var(--accent-soft);
  color: var(--ok);
}

.toast-error {
  border-left-color: var(--warn);
  color: var(--warn);
}

.toast-error .toast-icon {
  background: var(--warn-soft);
  color: var(--warn);
}

.toast-warn {
  border-left-color: var(--caution);
  color: var(--caution);
}

.toast-warn .toast-icon {
  background: var(--caution-soft);
  color: var(--caution);
}

.toast-info {
  border-left-color: var(--info);
  color: var(--info);
}

.toast-info .toast-icon {
  background: var(--info-soft);
  color: var(--info);
}

.toast p {
  color: var(--text);
}

.toast.is-leaving {
  animation: toast-out var(--t-fast) var(--ease) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes toast-life {
  to {
    transform: scaleX(0);
  }
}

@media (max-width: 760px) {
  .toasts {
    top: calc(96px + var(--s2));
    right: var(--s3);
    left: var(--s3);
    width: auto;
  }
}

/* ---------- 5. chrome ---------- */

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.appbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--s5);
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: var(--s5);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.icon {
  flex: 0 0 auto;
  color: currentColor;
}

.icon-accent {
  color: var(--accent);
}

.icon-info {
  color: var(--info);
}

.icon-warn {
  color: var(--warn);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.brand small {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: var(--s4);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 18px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab .count {
  margin-left: 6px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.appbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex: 0 0 auto;
}

#statusLine {
  display: inline-flex;
  align-items: center;
  gap: .45em;
}
#statusLine::before {
  content: "";
  inline-size: .65em;
  block-size: .65em;
  flex: none;
  border-radius: 50%;
  background: var(--connection-dot, var(--muted));
}
#statusLine[data-state="live"] { --connection-dot: oklch(64% .17 147); }
#statusLine:is([data-state="connecting"], [data-state="retry"]) { --connection-dot: oklch(71% .16 78); }
#statusLine[data-state="down"] { --connection-dot: oklch(59% .2 28); }

.appbar-end .who {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
}

.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s6) var(--s5) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  flex: 1 1 auto;
}

.page-foot {
  margin-top: auto;
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}

.page-head p {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: var(--s1);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
}

.stat {
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.stat-icon-info {
  background: var(--info-soft);
  color: var(--info);
}

.stat-icon-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.stat dt {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat dd {
  margin: 2px 0 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Control Room: scoped so office scene layout and counters stay independent. */
#dashboardRoot :is(.card, .page-head > div, .stack, .split > *) {
  min-inline-size: 0;
}

#dashboardRoot .page-head {
  align-items: center;
}

#dashboardRoot .page-head h1 {
  overflow-wrap: anywhere;
}

#dashboardRoot .tabs {
  flex-wrap: wrap;
  overflow: visible;
}

#dashboardRoot .stats {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
}

#dashboardRoot .stat dt {
  text-transform: none;
  letter-spacing: normal;
}

.role-badge {
  margin-inline-start: var(--s2);
}

.access-card .role-badge {
  margin-inline-start: 0;
}

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.card > .dashboard-actions {
  margin-block-start: var(--s4);
}

.overview-grid,
.overview-utilities {
  display: grid;
  gap: var(--s4);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 48rem) {
  .overview-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
  .overview-utilities {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.workspace-entry {
  margin-block-start: var(--s4);
}
.workspace-entry .btn {
  inline-size: 100%;
}
.workspace-status:not(:empty) {
  border-inline-start: 3px solid var(--info);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
  background: var(--info-soft);
  color: var(--text);
}
.workspace-status:empty {
  margin: 0;
  block-size: 0;
}
.workspace-dialog {
  margin: auto;
  inline-size: min(28rem, calc(100% - 2rem));
  color: var(--text);
  overflow-wrap: anywhere;
}
.workspace-dialog::backdrop {
  background: rgb(0 0 0 / 48%);
}
.workspace-dialog .dashboard-actions {
  justify-content: end;
}
.workspace-page .overview-utilities {
  align-items: start;
}
.workspace-page .card > .mode-actions {
  margin: 0;
  justify-self: stretch;
}
.admission-buttons {
  margin-inline-start: auto;
  justify-content: end;
}
.doc-layout {
  inline-size: min(100%, 72rem);
  margin-inline: auto;
  padding: var(--s6) clamp(var(--s3), 3vw, var(--s7)) var(--s8);
  display: grid;
  align-items: start;
  gap: var(--s6);
}
.doc-reader, .doc-index { display: grid; gap: var(--s4); min-inline-size: 0; }
.doc-reader { max-inline-size: 78ch; }
.doc-reader header > p:last-child { color: var(--text-2); }
.doc-reader :is(section, main), .doc-reader { scroll-margin-block-start: 4.5rem; }
.doc-reader .card { padding: clamp(var(--s4), 3vw, var(--s7)); }
.doc-reader h2 { margin-block-end: var(--s3); }
.doc-reader :is(pre, dl) + a { display: inline-block; margin-block: var(--s2); }
.doc-reader #copy-brief { margin-block-start: var(--s3); }
.doc-reader .btn[hidden] { display: none; }
.doc-paths { margin: var(--s3) 0; }
.doc-paths dt { font-weight: 650; margin-block-start: var(--s3); }
.doc-paths dd { margin: 0; color: var(--text-2); }
.doc-index { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); border-block-end: 1px solid var(--border); padding-block-end: var(--s3); }
.doc-index p { inline-size: 100%; }
.doc-index a { padding-block: var(--s1); }
@media (min-width: 52rem) {
  .doc-layout { grid-template-columns: 12rem minmax(0, 1fr); gap: var(--s8); }
  .doc-index { position: sticky; inset-block-start: 4.5rem; display: grid; border: 0; max-block-size: calc(100dvh - 5rem); overflow: auto; }
}
.guide-public pre {
  max-inline-size: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: var(--s3);
}
.guide-public .card {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.guide-public :is(p, pre, ul, ol) + :is(p, h3, pre, ul, ol, a) {
  margin-block-start: var(--s3);
}
.workspace-controls {
  display: grid;
  gap: var(--s4);
  min-inline-size: 0;
  border: 0;
  margin: 0;
  padding: 0;
}
.workspace-secret:empty {
  display: none;
}
.workspace-secret:not(:empty),
.workspace-list {
  display: grid;
  gap: var(--s2);
}
.workspace-secret > button {
  justify-self: start;
}
.workspace-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.workspace-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  border-block-start: 1px solid var(--border);
  padding-block: var(--s2);
}
.workspace-list li > div {
  display: grid;
  min-inline-size: 0;
}
.workspace-list code {
  overflow-wrap: anywhere;
}
.workspace-page .overview-utilities > .card {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: var(--s3);
  min-inline-size: 0;
}

.rename-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s2);
}
.rename-form small {
  grid-column: 1 / -1;
}
.rename-form .field,
.rename-form input {
  min-inline-size: 0;
}
.rename-form .btn {
  inline-size: auto;
}
.roster {
  table-layout: fixed;
}
.roster th:nth-child(2) {
  inline-size: 21%;
}
.roster th:last-child {
  inline-size: 7.75rem;
}
.roster button {
  white-space: nowrap;
}
.roster :is(td, th):nth-child(2) {
  padding-inline: var(--s1);
}
.roster th {
  text-transform: none;
  letter-spacing: normal;
}
.overview-utilities {
  align-items: stretch;
}
@media (max-width: 30rem) {
  .roster :is(td, th) {
    padding-inline: var(--s2);
  }
  .roster th:last-child {
    inline-size: 6.75rem;
  }
}
.roster :is(th, td):last-child:not([colspan]) {
  text-align: end;
}
.roster td {
  overflow-wrap: anywhere;
}
.roster .badge {
  max-inline-size: 100%;
  white-space: normal;
}
.table .inspector-row > td {
  padding: 0;
  text-align: start;
  background: var(--surface-2);
}
.demo-description {
  display: block;
  font-weight: 400;
  color: var(--muted);
  margin-block-start: var(--s2);
}
.rename-office {
  margin-block-start: var(--s3);
}

.worker-details {
  display: grid;
  gap: var(--s3);
  padding: var(--s3);
  border-inline-start: 2px solid var(--accent);
  overflow-wrap: anywhere;
}

.agent-row-actions {
  display: inline-flex;
  gap: var(--s2);
  align-items: center;
  white-space: nowrap;
}
.agent-row-actions > .btn { flex: none; }
.worker-details {
  max-inline-size: 100cqi;
  position: sticky;
  inset-inline-start: 0;
  padding: var(--s4);
  background: var(--surface);
}
.table-wrap:has(.worker-details), .table-wrap:has(.agent-row-actions) { container-type: inline-size; }
.inspector-head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
}
.worker-details .inspector-head h3 { text-transform: none; letter-spacing: normal; font-size: var(--fs-md); }
.inspector-head p { margin-block: var(--s1) 0; }
.inspector-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,16rem),1fr));
  gap: var(--s4);
  margin-block: var(--s2) var(--s3);
}
.inspector-groups section { min-inline-size: 0; }
.inspector-groups h4 { margin: 0 0 var(--s2); border-block-end: 1px solid var(--border); padding-block-end: var(--s2); }
.inspector-groups .facts { grid-template-columns: max-content minmax(0,1fr); margin: 0; }
.inspector-workload { margin: 0; padding-block-start: var(--s2); border-block-start: 1px solid var(--border); }
.worker-details:focus-visible {
  outline: 2px solid var(--accent);
}

.integration-doc-card { display: grid; gap: var(--s4); }
.integration-doc-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: var(--s2);
}
.integration-doc-links > a { text-align: center; }

.integration-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: var(--s4);
  align-items: start;
}

.access-card > p {
  margin-block: var(--s3);
}

.onboarding-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
}

.onboarding-card > div {
  flex: 1 1 28rem;
  min-inline-size: 0;
}

.onboarding-card p {
  margin-block-start: var(--s2);
  max-inline-size: 72ch;
}

.guide-topic {
  border-block-start: 1px solid var(--border);
}

.guide-topic > summary,
.demo-tools > summary {
  padding-block: var(--s3);
  cursor: pointer;
  font-weight: 550;
  border-radius: var(--r-sm);
}

.guide-topic > summary::marker,
.demo-tools > summary::marker {
  color: var(--accent);
}

.guide-topic > summary:focus-visible,
.demo-tools > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.guide-topic > summary:active,
.demo-tools > summary:active {
  background: var(--surface-2);
}

@media (hover: hover) and (pointer: fine) {
  .guide-topic > summary:hover,
  .demo-tools > summary:hover {
    background: var(--surface-2);
  }
}

.demo-tools > summary .badge {
  margin-inline-start: var(--s3);
}

.demo-panel,
.guide-topic-body {
  padding-block: var(--s3);
}

.demo-panel .input {
  inline-size: auto;
  max-inline-size: 100%;
}

.demo-panel .row {
  flex-wrap: wrap;
}

.guide-topic-body,
.credential-guide {
  display: grid;
  gap: var(--s3);
}

.credential-guide .card-head {
  margin-block-end: 0;
}

.credential-guide > .badge {
  justify-self: start;
}

.guide-topic-body > p,
.credential-guide > p,
.guide-list {
  max-inline-size: 85ch;
}

.guide-warning {
  padding: var(--s3);
  border-inline-start: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: var(--r-sm);
  color: var(--text);
}

.credential-guide > .guide-warning {
  display: grid;
  gap: var(--s2);
  justify-self: stretch;
}

.credential-guide > .guide-warning > p {
  margin: 0;
}

.consent {
  display: flex;
  align-items: start;
  gap: var(--s2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.consent input {
  flex: none;
  margin-block-start: 0.25em;
  accent-color: var(--accent);
}

.credential-value {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
  font-size: var(--fs-sm);
}

.share-status:empty {
  display: none;
}

.integration-options {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  align-items: stretch;
}

.integration-option {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.integration-option h3 {
  font-size: var(--fs-md);
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.integration-option .badge {
  justify-self: start;
  white-space: normal;
}

.guide-chapters > h2 {
  margin-block-end: var(--s3);
}

.guide-facts > div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  padding-block: var(--s3);
  border-block-end: 1px solid var(--border);
}

.guide-facts dt {
  flex: 1 0 11rem;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.guide-facts dd {
  flex: 4 1 24rem;
  min-inline-size: 0;
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.guide-list {
  padding-inline-start: var(--s5);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.guide-list li + li {
  margin-block-start: var(--s2);
}

.agent-id {
  display: block;
  margin-block-start: var(--s1);
  font-size: var(--fs-xs);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Two column content for wide screens. Collapses to one column below 1100px. */
.dash-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: var(--s4);
  align-items: start;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
  gap: var(--s4);
  align-items: start;
}

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

@media (max-width: 760px) {
  .appbar-inner {
    padding: 0 var(--s4);
    gap: var(--s3);
    flex-wrap: wrap;
    row-gap: 0;
  }

  .tabs {
    order: 3;
    width: 100%;
    gap: var(--s4);
  }

  .tab {
    padding: 0 0 10px;
  }

  .appbar-end {
    gap: var(--s2);
  }

  .appbar-end .who,
  .appbar-end .hide-sm {
    display: none;
  }

  .page {
    padding: var(--s4) var(--s4) var(--s5);
    gap: var(--s4);
  }
}

/* ---------- 6. tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th {
  text-align: left;
  padding: var(--s2) var(--s3);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--s3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

/* ---------- 7. auth screens ---------- */

.auth {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s6) var(--s4);
  overflow: hidden;
}

.auth canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.auth-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--s8);
  align-items: center;
  width: min(1000px, 100%);
}

.auth-copy h1 {
  font-size: var(--fs-2xl);
  line-height: 1.15;
  max-width: 15ch;
}

.auth-copy p {
  margin-top: var(--s3);
  max-width: 42ch;
  color: var(--text-2);
}

.checklist {
  list-style: none;
  margin: var(--s5) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.checklist li {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.check {
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 10px;
  flex: 0 0 auto;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s6);
  box-shadow: var(--shadow-2);
}

.auth-card h2 {
  font-size: var(--fs-xl);
}

.auth-card .lead {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin: var(--s1) 0 var(--s5);
}

.auth-foot {
  margin-top: var(--s4);
  font-size: var(--fs-xs);
  color: var(--muted);
}

@media (max-width: 880px) {
  .auth-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s5);
    width: min(420px, 100%);
  }

  .auth-copy h1 {
    font-size: var(--fs-xl);
    max-width: none;
  }

  .checklist {
    margin-top: var(--s3);
  }
}

/* ---------- 8. office view ---------- */

.project-feed {
  display: grid;
  gap: var(--s2);
}
.project-feed > .row {
  flex-wrap: wrap;
}
.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: var(--s3);
  list-style: none;
  padding: 0;
  margin: 0;
}
.project-list > li {
  min-inline-size: 0;
}
.project-card {
  display: grid;
  gap: var(--s2);
  inline-size: 100%;
  block-size: 100%;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.project-name,
.project-summary {
  min-inline-size: 0;
  overflow: clip;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-card .row {
  min-inline-size: 0;
}
.project-card .badge {
  flex-shrink: 0;
}
.project-summary {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.project-reporters {
  display: grid;
  gap: var(--s1);
  font-size: var(--fs-xs);
}

.project-reporters,
.project-event {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.project-card:active {
  background: var(--surface-2);
}
@media (hover: hover) and (pointer: fine) {
  .project-card:hover {
    border-color: var(--accent);
    background: var(--surface-2);
  }
}

.office-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 23vw, 320px);
  gap: var(--s4);
  align-items: start;
  /* Each column owns its height; a long agent list never stretches the canvas. */
  flex: 1 1 auto;
}

.office-main {
  display: grid;
  gap: var(--s4);
  min-inline-size: 0;
  align-content: start;
}

@media (min-width: 981px) {
  /* Fill the screen instead of leaving a long tail of empty space. */
  .office-layout {
    align-items: start;
  }

  .panel {
    align-self: start;
  }

  .rooms {
    grid-auto-rows: minmax(104px, auto);
    align-content: start;
  }

  .panel {
    position: sticky;
    top: calc(var(--s6) + 64px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
  }
}

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

.rooms {
  display: grid;
  grid-template-columns: repeat(
      auto-fit,
      minmax(min(100%, max(11rem, calc((100% - 3 * var(--s3)) / 4))), 1fr)
    );
  gap: var(--s3);
}

.room {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3);
  min-height: 104px;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.room-empty {
  background: transparent;
  border-style: dashed;
}

.room-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-head .room-count {
  margin-left: auto;
}

.room-icon {
  color: var(--muted);
  opacity: 0.7;
  flex: 0 0 auto;
}

.room-occupied {
  border-left: 3px solid var(--tone, var(--accent));
}

.room-occupied .room-icon {
  color: var(--tone, var(--accent));
  opacity: 1;
}

.room-count {
  color: var(--tone, var(--muted));
}

.room-head h2 {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.room-count {
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.occupants {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "dot name badge"
    ". action action"
    ". task task";
  align-items: center;
  gap: 2px var(--s2);
  width: 100%;
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.chip[aria-current="true"] {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chip .dot {
  grid-area: dot;
}

.chip-name {
  grid-area: name;
  font-weight: 600;
  font-size: var(--fs-sm);
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.chip-action {
  grid-area: action;
  font-size: var(--fs-xs);
  min-inline-size: 0;
  overflow-wrap: break-word;
}

.chip-task {
  grid-area: task;
  font-size: var(--fs-xs);
  color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip .badge {
  grid-area: badge;
  justify-self: end;
  font-size: 10px;
  padding: 1px 6px;
}

.panel {
  position: sticky;
  top: calc(var(--s7) + var(--s4));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

@media (max-width: 980px) {
  .panel {
    position: static;
  }
}

.panel-empty {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: var(--s2);
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px var(--s3);
  font-size: var(--fs-sm);
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
}

.list .title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.status-pending {
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  color: var(--warn);
}

.status-claimed {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}

.status-acked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.status-failed {
  border-color: color-mix(in srgb, var(--warn) 60%, transparent);
  background: var(--warn-soft);
  color: var(--warn);
}

.accordion {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.acc-item {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
}

.acc-item:hover {
  background: var(--surface-2);
}

.acc-open {
  background: var(--surface-2);
  border-color: var(--border);
}

.acc-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px var(--s2);
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.identity {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
  background: hsl(var(--id-hue, 210) 30% 90%);
  color: hsl(var(--id-hue, 210) 45% 28%);
}

:root[data-theme="dark"] .identity {
  background: hsl(var(--id-hue, 210) 24% 22%);
  color: hsl(var(--id-hue, 210) 45% 76%);
}

.acc-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.acc-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--muted);
  min-width: 0;
}

.acc-meta span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-name {
  font-weight: 600;
  font-size: var(--fs-sm);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-room {
  grid-column: 2 / -1;
  font-size: var(--fs-xs);
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-body {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: 0 10px 10px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
}

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

.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-height: 140px;
}

.kanban-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kanban-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tone, var(--border-strong));
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.kanban-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.kanban-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.kanban-actions {
  display: flex;
  gap: 6px;
}

select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% + 2px),
    calc(100% - 13px) calc(50% + 2px);
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.segmented {
  display: inline-flex;
  margin: 0;
  border: 1px solid var(--border);
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 550;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

#officeRoot :is(.page, .appbar-inner) {
  max-inline-size: none;
  padding-inline: clamp(var(--s3), 2vw, var(--s7));
}

#officeRoot .office-head {
  align-items: center;
  gap: var(--s3);
}

.office-heading {
  flex: 1 1 20rem;
  min-inline-size: 0;
  overflow-wrap: break-word;
}

#officeRoot .stats {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: 0;
}

#officeRoot .stat {
  padding: var(--s1) var(--s2);
  gap: var(--s1);
  border-radius: var(--r-sm);
}

#officeRoot .stat-icon {
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

#officeRoot .stat > div {
  display: flex;
  align-items: baseline;
  gap: var(--s1);
  white-space: nowrap;
}

#officeRoot .stat dt {
  text-transform: none;
  letter-spacing: normal;
}

#officeRoot .stat dd {
  order: -1;
  font-size: var(--fs-sm);
  margin: 0;
}

.stage {
  --scene-sky: #779fba;
  --scene-horizon: #cedcda;
  position: relative;
  isolation: isolate;
  /* The gradient is the time-driven sky, not decoration on a UI surface. */
  background: linear-gradient(var(--scene-sky), var(--scene-horizon));
  min-block-size: 400px;
  block-size: clamp(400px, 68svh, 780px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  touch-action: none;
}

.stage canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

.scene-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: clip;
  pointer-events: none;
}

.scene-sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at var(--scene-sun-x, 12%) 40%,
    oklch(85% 0.13 60 / 65%),
    transparent 65%
  );
  opacity: var(--scene-twilight, 0);
}

.scene-stars {
  position: absolute;
  inset: 0;
  opacity: var(--scene-stars, 0);
}

.scene-stars i {
  position: absolute;
  inset-inline-start: var(--star-x);
  inset-block-start: var(--star-y);
  inline-size: var(--star-size);
  block-size: var(--star-size);
  border-radius: 50%;
  background: oklch(95% 0.025 245);
}

.scene-sun,
.scene-moon {
  position: absolute;
  inline-size: clamp(30px, 4vw, 54px);
  aspect-ratio: 1;
  border-radius: 50%;
}

.scene-sun {
  inset-inline-start: var(--scene-sun-x, 12%);
  inset-block-start: var(--scene-sun-y, 29%);
  background: oklch(96% 0.12 90);
  box-shadow: 0 0 34px 12px oklch(88% 0.13 75 / 35%);
  opacity: calc(var(--scene-daylight, 0) * (1 - var(--scene-cloud-cover, 0) * 0.8));
}

.scene-moon {
  inset-inline-end: 13%;
  inset-block-start: 13%;
  background:
    radial-gradient(circle at 28% 42%, oklch(77% 0.03 250) 0 10%, transparent 11%),
    radial-gradient(circle at 63% 68%, oklch(80% 0.025 250) 0 14%, transparent 15%),
    radial-gradient(circle at 60% 24%, oklch(83% 0.025 250) 0 7%, transparent 8%),
    oklch(94% 0.025 245);
  box-shadow: 0 0 24px 5px oklch(86% 0.03 245 / 15%);
  opacity: var(--scene-stars, 0);
}

.scene-clouds {
  position: absolute;
  inset: 6% 0 auto;
  block-size: 25%;
  background:
    radial-gradient(ellipse 12% 9% at 27% 62%, oklch(98% 0.01 230 / 40%), transparent),
    radial-gradient(ellipse 9% 12% at 33% 59%, oklch(98% 0.01 230 / 30%), transparent),
    radial-gradient(ellipse 15% 8% at 71% 27%, oklch(98% 0.01 230 / 35%), transparent);
  opacity: max(var(--scene-daylight, 0), var(--scene-cloud-cover, 0));
}

.scene-footer {
  position: absolute;
  z-index: 2;
  inset-inline: var(--s3);
  inset-block-end: var(--s3);
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--s1) var(--s3);
  pointer-events: none;
}
.stage-hint {
  margin-inline-start: auto;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
  pointer-events: none;
}

.scene-hud {
  position: absolute;
  z-index: 2;
  inset: var(--s3) var(--s3) auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  pointer-events: none;
}

.scene-hud button {
  pointer-events: auto;
  flex-shrink: 0;
}

.scene-weather-stack {
  display: grid;
  justify-items: start;
  gap: var(--s1);
  min-inline-size: 0;
}

.scene-forecast {
  display: grid;
  gap: 0.125rem;
}

.scene-hud button {
  align-self: start;
}

.scene-weather {
  min-inline-size: 0;
  text-wrap: balance;
}

.scene-weather,
.scene-forecast,
.scene-caption {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text-2);
  font-size: var(--fs-xs);
}

.scene-caption {
  max-inline-size: 100%;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* ---------- 9. misc ---------- */

.notice {
  display: flex;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
}

.notice-warn {
  border-left-color: var(--warn);
}

.reveal {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  border-radius: var(--r-md);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.spread {
  justify-content: space-between;
}

.row-end {
  align-items: flex-end;
}

.field-grow {
  flex: 1 1 140px;
}

.mt-1 {
  margin-top: var(--s1);
}

.mt-3 {
  margin-top: var(--s3);
}

.mt-4 {
  margin-top: var(--s4);
}

.on-top {
  position: relative;
  z-index: 1;
}

.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;
}

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