:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #66736b;
  --paper: #f5f4ee;
  --surface: #fffefa;
  --line: #d9ddd6;
  --green: #245b45;
  --green-soft: #dfece5;
  --lime: #bddb69;
  --amber: #bd7025;
  --red: #a83a32;
  --shadow: 0 10px 30px rgba(31, 49, 39, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 94% 4%, rgba(189, 219, 105, 0.24), transparent 20rem),
    var(--paper);
  color: var(--ink);
}

button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.58; }

:focus-visible {
  outline: 3px solid #7aa927;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  transform: translateY(-150%);
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: white;
  border-radius: 0.4rem;
}
.skip-link:focus { transform: translateY(0); }

.topbar, main, footer { width: min(1500px, calc(100% - 2rem)); margin-inline: auto; }

.topbar {
  min-height: 5.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.55rem; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(1.8rem, 3vw, 2.55rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 1rem; letter-spacing: -0.01em; }

.eyebrow, .section-kicker {
  margin-bottom: 0.18rem;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.health-pill, .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.health-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #a9afa9; }
.health-pill.ok .health-dot { background: #4b9a65; box-shadow: 0 0 0 4px rgba(75, 154, 101, 0.14); }
.health-pill.error .health-dot { background: var(--red); }

main { padding-block: 1rem 2rem; }

.control-bar {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(17rem, 2fr) auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.select-field, .representation-form label { display: grid; gap: 0.3rem; }
.select-field > span, .representation-form label > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; }

select, input, textarea {
  min-height: 2.55rem;
  width: 100%;
  border: 1px solid #cbd1ca;
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
}

textarea { resize: vertical; }

.identity-label {
  max-width: 17rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  width: min(1500px, calc(100% - 2rem));
  margin: 0.7rem auto 0;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}
.app-nav button {
  flex: 0 0 auto;
  min-height: 2.25rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}
.app-nav button[aria-current="page"] {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.control-view { padding-block: 0.5rem 2rem; }
.control-page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1rem;
}
.control-page-heading h2 { font-family: Georgia, serif; font-size: clamp(1.55rem, 3vw, 2.15rem); }
.control-page-heading > p { max-width: 42rem; margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.control-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  padding: 1rem;
}
.control-form label, .secret-result label { display: grid; gap: 0.3rem; }
.control-form label > span, .secret-result label > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.control-form button { align-self: end; }
.compact-control-form { grid-template-columns: minmax(0, 2fr) minmax(10rem, 1fr); }
.control-card-list { display: grid; gap: 0.65rem; }
.control-card { padding: 0.9rem; }
.control-card-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.control-card-heading h2 { margin: 0; }
.control-card-heading .quiet-copy { margin: 0.25rem 0 0; }
.control-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.75rem; }
.monospace-copy { margin: 0.55rem 0 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; overflow-wrap: anywhere; }
.secret-result { margin-block: 0.9rem; padding: 1rem; border-color: var(--amber); }
.secret-result > p, .guidance-copy { color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.secret-result label { margin-top: 0.8rem; }
.secret-result textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.76rem; }

button { min-height: 2.55rem; border-radius: 0.5rem; padding: 0.55rem 0.9rem; font-weight: 750; }
.secondary-button { border: 1px solid #bcc5bd; background: transparent; color: var(--green); }
.primary-button { border: 1px solid var(--green); background: var(--green); color: white; }
.compact-button { min-height: 2.25rem; padding-block: 0.4rem; }
.text-button { min-height: 2.25rem; border: 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--green); }

.access-gate {
  width: min(100% - 2rem, 1500px);
  min-height: calc(100vh - 5.5rem);
  margin-inline: auto;
  display: grid;
  place-items: center;
  padding: 2rem 0;
}
.access-card {
  width: min(100%, 36rem);
  padding: clamp(1.4rem, 4vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 24px 70px rgba(31, 49, 39, 0.13);
}
.access-card h2 { margin-bottom: 0.8rem; font-family: Georgia, serif; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.access-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.access-form { display: grid; gap: 0.8rem; }
.access-form label, .share-result label { display: grid; gap: 0.3rem; }
.access-form label > span, .share-result label > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.quiet-copy { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.owner-bootstrap { margin-top: 1.1rem; }
.owner-divider { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.8rem; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.owner-divider::before, .owner-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.owner-bootstrap > button { width: 100%; }
.owner-bootstrap .access-form { margin-top: 0.75rem; }
.owner-bootstrap .notice { margin: 0.75rem 0 0; }

.share-dialog {
  width: min(calc(100% - 2rem), 35rem);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  padding: 1.2rem;
  box-shadow: 0 28px 90px rgba(16, 28, 21, 0.25);
}
.share-dialog::backdrop { background: rgba(23, 33, 28, 0.52); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { font-family: Georgia, serif; font-size: 1.55rem; }
.dialog-copy { color: var(--muted); font-size: 0.84rem; }
.icon-button { min-width: 2.4rem; border: 0; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; }
.share-dialog .access-form { grid-template-columns: 1fr 0.55fr; align-items: end; }
.share-dialog .access-form button { grid-column: 1 / -1; }
.share-result { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.55rem; }
.invite-warning { margin: 0.7rem 0 0; color: #844a13; font-size: 0.76rem; font-weight: 700; }

.notice { margin-bottom: 0.85rem; padding: 0.75rem 0.9rem; border-radius: 0.5rem; }
.notice.error { border: 1px solid #e3b6b0; background: #fff0ed; color: #7e2722; }

.summary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 0.75rem; }
.metric-card, .panel {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 254, 250, 0.9);
  box-shadow: var(--shadow);
}

.metric-card { padding: 0.7rem 0.85rem; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.metric-card span { color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.metric-card strong { font-family: Georgia, serif; color: var(--green); font-size: 1.65rem; }

.overview-grid { display: grid; grid-template-columns: 1.2fr 0.9fr 1fr 1fr; gap: 0.75rem; }
.panel { min-width: 0; padding: 0.85rem; }
.panel-heading { min-height: 2.25rem; display: flex; justify-content: space-between; align-items: start; gap: 0.8rem; margin-bottom: 0.65rem; }
.placeholder { margin: auto; color: var(--muted); font-size: 0.82rem; text-align: center; }

.workspace-map { min-height: 8.5rem; display: grid; grid-template-columns: 1.2fr 0.9fr; align-items: center; gap: 1.2rem; }
.map-root, .map-node { position: relative; border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.65rem; background: white; }
.map-root { border-color: var(--green); background: var(--green); color: white; }
.map-root strong, .map-node strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; }
.map-root span, .map-node span { display: block; margin-top: 0.15rem; font-size: 0.68rem; opacity: 0.76; }
.map-branches { display: grid; gap: 0.35rem; }
.map-node::before { content: ""; position: absolute; width: 1.2rem; height: 1px; right: 100%; top: 50%; background: var(--line); }

.queue-track { height: 0.42rem; overflow: hidden; border-radius: 999px; background: #e8ebe5; }
.queue-track span { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, var(--green), var(--lime)); transition: width 240ms ease; }
.queue-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin: 0.85rem 0 0; }
.queue-stats div { border-top: 1px solid var(--line); padding-top: 0.42rem; }
.queue-stats dt { color: var(--muted); font-size: 0.67rem; }
.queue-stats dd { margin: 0.1rem 0 0; font-size: 0.95rem; font-weight: 800; }
.status-badge { padding: 0.3rem 0.5rem; font-size: 0.67rem; }
.status-badge.ok { border-color: #aacbb5; color: var(--green); background: var(--green-soft); }
.status-badge.busy { border-color: #dfbd94; color: #844a13; background: #fff0db; }
.status-badge.error { border-color: #e3b6b0; color: var(--red); background: #fff0ed; }

.entity-list { min-height: 8.5rem; max-height: 8.5rem; overflow: auto; display: grid; align-content: start; gap: 0.35rem; }
.entity-button { width: 100%; min-height: 2.25rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.6rem; padding: 0.45rem 0.55rem; border: 1px solid transparent; background: #f4f6f2; color: var(--ink); text-align: left; }
.entity-button:hover, .entity-button[aria-current="true"] { border-color: #a9baae; background: var(--green-soft); }
.entity-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; }
.entity-button span { color: var(--muted); font-size: 0.63rem; }

.inspection-grid { display: grid; grid-template-columns: 1.05fr 1.05fr 0.9fr; gap: 0.75rem; margin-top: 0.75rem; align-items: start; }
.inspector-panel { min-height: 28rem; }
.quiet-count { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.inspector-context { min-height: 1.6rem; margin: -0.2rem 0 0.5rem; color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }
.message-list, .conclusion-list, .representation-output { height: 22rem; overflow: auto; padding-right: 0.2rem; }
.message-list, .conclusion-list { display: grid; align-content: start; gap: 0.5rem; }
.message, .conclusion { border: 1px solid var(--line); border-radius: 0.6rem; padding: 0.65rem; background: white; }
.message header, .conclusion header { display: flex; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.65rem; }
.message header strong { color: var(--green); }
.message p, .conclusion p { margin: 0; font-size: 0.78rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.conclusion-level { color: var(--green); font-weight: 800; text-transform: capitalize; }

.representation-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.7rem; }
.representation-form .search-field, .representation-form button { grid-column: 1 / -1; }
.representation-output { height: 16rem; border: 1px solid var(--line); border-radius: 0.6rem; background: white; padding: 0.75rem; }
.representation-output p:not(.placeholder) { margin: 0; font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

.loading-block { min-height: 5rem; display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; }
.inline-error { margin: 0; color: var(--red); font-size: 0.8rem; }

footer { display: flex; justify-content: center; gap: 0.5rem; padding: 1rem 0 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; }

@media (max-width: 1100px) {
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .inspection-grid { grid-template-columns: 1fr 1fr; }
  .representation-panel { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .topbar, main, footer { width: min(100% - 1rem, 1500px); }
  .topbar { align-items: flex-start; padding-block: 0.8rem; }
  .topbar-actions { max-width: 55%; flex-wrap: wrap; }
  .health-pill { max-width: 100%; }
  .control-bar { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 1fr 1fr; }
  .overview-grid, .inspection-grid { grid-template-columns: 1fr; }
  .representation-panel { grid-column: auto; }
  .inspector-panel { min-height: auto; }
  .message-list, .conclusion-list { height: 20rem; }
  footer { flex-wrap: wrap; }
  .share-dialog .access-form, .copy-row { grid-template-columns: 1fr; }
  .app-nav { width: min(100% - 1rem, 1500px); }
  .control-page-heading { align-items: start; flex-direction: column; gap: 0.5rem; }
  .control-form, .compact-control-form { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
