/* Studio Control: the production root is an operational surface, not a simulation. */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e11;
  --paper: #111419;
  --panel: #14181e;
  --panel-2: #1a1f27;
  --input: #101318;
  --line: #272d36;
  --line-strong: #3a424e;
  --muted: #8e98a7;
  --text: #f1f3f5;
  --ink: #f1f3f5;
  --accent: #a98bdd;
  --accent-strong: #c6aeed;
  --accent-soft: #241d31;
  --ready: #193a52;
  --ready-ink: #99d4ff;
  --active: #3b3218;
  --active-ink: #e8c96f;
  --blocked: #45251f;
  --blocked-ink: #ffab96;
  --done: #17362b;
  --done-ink: #87d5ad;
  --danger: #ff9f91;
  --danger-soft: #3a211f;
  --focus: #bea3eb;
  --shadow: 0 0 0;
  --accent-solid: #b99ae8;
  --on-accent: #160f20;
  --surface-hover: #1c222a;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f3f5;
  --paper: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --input: #ffffff;
  --line: #dfe2e7;
  --line-strong: #c4c9d1;
  --muted: #697281;
  --text: #15181d;
  --ink: #15181d;
  --accent: #7257a8;
  --accent-strong: #604590;
  --accent-soft: #eee8f8;
  --ready: #e2f2fc;
  --ready-ink: #235e84;
  --active: #f8edc8;
  --active-ink: #745a0e;
  --blocked: #fbe4df;
  --blocked-ink: #9a4535;
  --done: #dff2e8;
  --done-ink: #326c4d;
  --danger: #a83e35;
  --danger-soft: #fbe5e1;
  --focus: #7257a8;
  --shadow: 0 0 0;
  --accent-solid: #654896;
  --on-accent: #ffffff;
  --surface-hover: #f7f8f9;
}

html {
  min-height: 100%;
  background: var(--bg);
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  border-radius: .55rem;
}

button {
  box-shadow: none;
}

.shell {
  width: min(1360px, calc(100% - 3rem));
  padding: 0 0 3rem;
}

.topbar {
  min-height: 4.6rem;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  gap: .7rem;
}

.mark {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line-strong);
  border-radius: .52rem;
  color: var(--text);
  background: var(--panel-2);
  box-shadow: none;
  font-size: .78rem;
  transform: none;
}

.brand-copy {
  display: grid;
  gap: .02rem;
}

.brand strong {
  font-size: .92rem;
  letter-spacing: -.015em;
}

.brand small {
  color: var(--muted);
  font-size: .67rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.github,
.icon-button {
  min-height: 2.2rem;
  padding: .45rem .62rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: var(--muted);
  background: transparent;
  font-size: .72rem;
}

.github:hover,
.icon-button:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
}

.icon-button {
  display: grid;
  width: 2.2rem;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

html[data-theme="dark"] .theme-sun,
html[data-theme="light"] .theme-moon {
  display: none;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  min-height: 2.2rem;
  padding: 0 .65rem;
  color: var(--muted);
  font-size: .68rem;
  white-space: nowrap;
}

.sync-state i {
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--muted);
}

.sync-state[data-state="live"] i { background: var(--done-ink); }
.sync-state[data-state="cached"] i { background: var(--active-ink); }
.sync-state[data-state="syncing"] i { background: var(--ready-ink); }
.sync-state[data-state="degraded"] { color: var(--blocked-ink); }
.sync-state[data-state="degraded"] i { background: var(--blocked-ink); }

.root-connecting-status {
  display: none !important;
}

.hero {
  min-height: calc(100vh - 4.6rem);
  grid-template-columns: minmax(0, 1.15fr) minmax(20rem, .58fr);
  gap: clamp(2rem, 7vw, 7.5rem);
  margin: 0;
  padding: clamp(4rem, 11vh, 8rem) clamp(0rem, 2vw, 2rem);
  align-items: center;
}

.hero-copy {
  max-width: 49rem;
}

.connection-slot,
.connection-system-slot {
  min-width: 0;
}

.connection-system-slot .connection {
  max-width: 36rem;
}

.eyebrow {
  margin-bottom: .55rem;
  color: var(--accent-strong);
  font-size: .66rem;
  font-weight: 720;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 10ch;
  font-size: clamp(3.4rem, 7vw, 7rem);
  font-weight: 650;
  line-height: .94;
  letter-spacing: -.072em;
}

.hero-lede {
  max-width: 38rem;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.55;
}

.hero-proof {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: clamp(2.4rem, 7vh, 5rem);
}

.hero-proof p {
  display: grid;
  gap: .3rem;
  margin: 0;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}

.hero-proof span {
  color: var(--accent-strong);
  font: 650 .62rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hero-proof strong {
  font-size: .8rem;
}

.hero-proof small {
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.45;
}

.connection,
.session-context,
.metrics article,
.agents-panel,
.column,
.board-filter-panel {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: none;
}

.connection {
  padding: 1.15rem;
  border-radius: .8rem;
}

.connection::before {
  display: none;
}

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

.connection-head > div {
  display: grid;
  gap: .2rem;
}

.connection-kicker {
  color: var(--muted);
  font-size: .64rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.connection-head strong {
  font-size: .9rem;
}

.connection-head > span {
  padding: .22rem .4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .61rem;
}

.hosted-sign-in {
  padding: .75rem 0 0;
  border: 0;
  background: transparent;
}

.hosted-sign-in button {
  min-height: 3rem;
  border-radius: .55rem;
}

.advanced-connection {
  margin-top: .7rem;
  border-top: 1px solid var(--line);
}

.advanced-connection summary {
  padding: .8rem 0 .15rem;
  color: var(--muted);
  font-size: .7rem;
  cursor: pointer;
}

.advanced-connection-body {
  display: grid;
  gap: .65rem;
  margin-top: .6rem;
}

.connection-note {
  margin-top: .8rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}

html[data-app-mode="connecting"] .hero-login,
html[data-app-mode="connected"] .hero-login,
html[data-app-mode="degraded"] .hero-login {
  display: none;
}

html[data-app-mode="editing"] .hero-login {
  display: block;
  min-height: 0;
  padding: 1rem 0 0;
}

html[data-app-mode="editing"] .hero-copy {
  display: none;
}

html[data-app-mode="editing"] .login-card {
  max-width: 32rem;
  padding: 1rem;
}

.dashboard {
  gap: 1rem;
  padding: clamp(2.4rem, 6vh, 4.5rem) 0 0;
}

.dashboard-head {
  margin: 0;
  align-items: end;
}

.dashboard-title h1 {
  max-width: none;
  font-size: clamp(2.4rem, 4.5vw, 4.7rem);
  font-weight: 630;
  line-height: .96;
  letter-spacing: -.065em;
}

.dashboard-lede {
  margin: .8rem 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.dashboard-actions {
  align-items: end;
  flex-wrap: nowrap;
}

.dashboard-actions button,
.dashboard-actions select {
  min-height: 2.45rem;
  border-radius: .5rem;
  color: var(--text);
  background: var(--panel);
}

.project-select {
  gap: .28rem;
}

.project-select span {
  color: var(--muted);
  font-size: .61rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.view-tabs {
  display: flex;
  gap: .15rem;
  margin-top: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.view-tabs button {
  min-height: 2.7rem;
  margin-bottom: -1px;
  padding: .65rem .85rem;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: .76rem;
  font-weight: 620;
}

.view-tabs button:hover {
  color: var(--text);
  background: transparent;
}

.view-tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent-strong);
}

.view-panel {
  display: grid;
  gap: .8rem;
  padding-top: .3rem;
}

.metrics {
  gap: .6rem;
}

.metrics article {
  min-height: 8.2rem;
  padding: 1rem;
  border-radius: .68rem;
}

.metrics article::before {
  content: "";
  display: block;
  width: 1.25rem;
  height: .16rem;
  margin-bottom: 1.2rem;
  border-radius: 999px;
  background: var(--status, var(--line-strong));
}

.metric-attention { --status: var(--blocked-ink); }
.metric-active { --status: var(--active-ink); }
.metric-ready { --status: var(--ready-ink); }
.metric-done { --status: var(--done-ink); }

.metrics span {
  color: var(--text);
  font-size: .71rem;
}

.metrics strong {
  margin-top: .15rem;
  font-size: 1.65rem;
  font-weight: 600;
}

.metrics small {
  display: block;
  margin-top: .22rem;
  color: var(--muted);
  font-size: .65rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(20rem, .8fr);
  gap: .8rem;
}

.overview-panel,
.agents-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .68rem;
  background: var(--panel);
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-head .eyebrow,
.section-head .eyebrow {
  margin-bottom: .25rem;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
  font-size: .9rem;
  letter-spacing: -.015em;
}

.panel-head > span,
.section-head > span {
  color: var(--muted);
  font: .62rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.overview-list {
  display: grid;
}

.overview-list > .empty {
  padding: 2.3rem 1rem;
  text-align: center;
}

.overview-item {
  display: grid;
  grid-template-columns: .55rem minmax(0, 1fr) auto;
  gap: .75rem;
  width: 100%;
  min-height: 4.75rem;
  padding: .85rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: transparent;
}

.overview-item:last-child {
  border-bottom: 0;
}

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

.overview-status {
  width: .45rem;
  height: .45rem;
  margin-top: .32rem;
  border-radius: 50%;
  background: var(--status);
}

.overview-copy {
  display: grid;
  gap: .28rem;
  min-width: 0;
}

.overview-copy strong {
  overflow: hidden;
  font-size: .78rem;
  font-weight: 620;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 450;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-meta {
  display: grid;
  gap: .25rem;
  justify-items: end;
  color: var(--muted);
  font: .59rem ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}

.overview-meta strong {
  color: var(--status-ink);
  font: inherit;
}

.agents-panel {
  padding: 0;
}

.agents {
  margin: 0;
  padding: .9rem 1rem 1rem;
}

.agent {
  padding: .45rem .6rem;
  border-radius: .5rem;
  background: var(--panel-2);
}

.view-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: .8rem 0 .4rem;
}

.view-intro h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -.025em;
}

.view-intro > p {
  max-width: 31rem;
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.5;
  text-align: right;
}

.board {
  gap: .6rem;
  padding-bottom: 1rem;
}

.column {
  padding: .65rem;
  border-radius: .68rem;
}

.card {
  border-radius: .58rem;
  background: var(--input);
  box-shadow: none;
}

.card:hover {
  box-shadow: none;
  transform: none;
  background: var(--surface-hover);
}

.system-view {
  max-width: 62rem;
}

.dashboard-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.dashboard-secondary-actions button {
  min-height: 2.35rem;
  padding: .5rem .7rem;
  color: var(--text);
  border-color: var(--line);
  background: var(--panel);
  font-size: .72rem;
  text-transform: capitalize;
}

.session-context,
.provider-capacity {
  border-radius: .68rem !important;
  background: var(--panel) !important;
  box-shadow: none !important;
}

.disconnected {
  display: none;
}

html[data-app-mode="signed-out"] .disconnected,
html[data-app-mode="connecting"] .disconnected {
  display: none;
}

.connection-error {
  border-radius: .5rem;
}

.create-item-dialog,
.item-detail-dialog,
.actor-activity-dialog,
.project-brief-dialog {
  border-color: var(--line);
  border-radius: .7rem;
  background: var(--paper);
  box-shadow: 0 2rem 5rem rgb(0 0 0 / .45);
}

.create-item-head,
.item-detail-head {
  background: var(--paper);
}

@media (max-width: 900px) {
  .shell { width: min(100% - 2rem, 1360px); }
  .hero { grid-template-columns: 1fr; min-height: auto; padding: 4.5rem 0; }
  .login-card { max-width: 34rem; }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 1.2rem, 1360px); }
  .topbar { min-height: 4rem; }
  .brand small, .github { display: none; }
  .sync-state { max-width: 8.5rem; overflow: hidden; }
  .sync-state > span { overflow: hidden; text-overflow: ellipsis; }
  .hero { padding: 3.5rem 0; }
  .hero h1 { font-size: clamp(3rem, 16vw, 4.8rem); }
  .hero-proof { grid-template-columns: 1fr; gap: .75rem; }
  .hero-proof p { grid-template-columns: 1.5rem minmax(0, 1fr); }
  .hero-proof small { grid-column: 2; }
  .dashboard { padding-top: 2.4rem; }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .dashboard-title h1 { font-size: clamp(2.5rem, 13vw, 4rem); }
  .dashboard-actions { width: 100%; flex-wrap: wrap; }
  .project-select { flex: 1 1 100%; }
  .dashboard-actions select { width: 100%; }
  .dashboard-actions button { flex: 1; }
  .view-tabs { position: sticky; top: 0; z-index: 5; background: var(--bg); }
  .view-tabs button { flex: 1; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { min-height: 7.2rem; }
  .view-intro { align-items: flex-start; flex-direction: column; gap: .45rem; }
  .view-intro > p { text-align: left; }
  .overview-item { grid-template-columns: .45rem minmax(0, 1fr); }
  .overview-meta { grid-column: 2; grid-template-columns: auto auto; justify-content: start; justify-items: start; }
  .board { grid-template-columns: repeat(4, 17rem); }
}

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