:root {
  --bg: #edf0f4;
  --panel: rgba(252, 253, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --panel-muted: rgba(246, 248, 251, 0.92);
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.16);
  --text-0: #0f172a;
  --text-1: rgba(15, 23, 42, 0.72);
  --text-2: rgba(15, 23, 42, 0.48);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --success: #1f8f63;
  --success-soft: rgba(31, 143, 99, 0.1);
  --danger: #c25e48;
  --danger-soft: rgba(194, 94, 72, 0.1);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --mono: "IBM Plex Mono", monospace;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  font-family: "Manrope", sans-serif;
  color: var(--text-0);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56) 0%, rgba(255, 255, 255, 0) 26%),
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 24%),
    linear-gradient(180deg, #f6f8fb 0%, var(--bg) 100%);
}

button,
input,
select,
summary,
a {
  font: inherit;
}

button,
summary {
  cursor: pointer;
}

a {
  color: inherit;
}

.accounts-shell {
  height: 100dvh;
  padding: 16px;
  overflow: hidden;
}

.auth-gate {
  min-height: calc(100dvh - 32px);
  display: grid;
  place-items: center;
}

.gate-card,
.accounts-nav,
.account-stage,
.rail-shell {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.gate-card {
  width: min(720px, 100%);
  border-radius: 30px;
  padding: 28px;
  display: grid;
  gap: 18px;
}

.accounts-home {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: calc(100dvh - 32px);
  overflow: hidden;
}

.workspace-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 0 6px 0 2px;
}

.topbar-copy,
.topbar-session,
.gate-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-copy {
  gap: 16px;
}

.topbar-copy h1,
.gate-head h1,
.nav-head h2,
.rail-head h2,
.stage-title {
  margin: 0;
  letter-spacing: -0.05em;
}

.topbar-copy h1 {
  font-size: 24px;
  line-height: 1;
}

.gate-head {
  justify-content: space-between;
  align-items: flex-start;
}

.gate-head h1 {
  font-size: 34px;
}

.eyebrow,
.meta-label,
.status-pill,
.stage-kicker,
.metric-label {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow,
.gate-copy,
.gate-status,
.field span,
.field-note,
.rail-copy,
.nav-empty-state p,
.account-nav-server,
.stage-server,
.stage-timestamp,
.stage-note,
.console-log {
  color: var(--text-1);
}

.eyebrow,
.stage-kicker,
.metric-label {
  margin: 0;
  font-size: 11px;
  color: var(--text-2);
}

.home-link,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid transparent;
}

.home-link,
.secondary-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(15, 23, 42, 0.08);
}

.home-link {
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(180deg, #2f6df5 0%, #2558d8 100%);
  color: #fff;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(31, 143, 99, 0.18);
  background: var(--success-soft);
  color: var(--success);
}

.status-pill-muted {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.64);
  color: var(--text-2);
}

.status-pill-info {
  border-color: rgba(37, 99, 235, 0.16);
  background: var(--accent-soft);
  color: var(--accent);
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 12px;
}

.session-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
}

.workspace-layout {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 12px;
  overflow: hidden;
}

.accounts-nav,
.account-stage,
.rail-shell {
  min-height: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.accounts-nav,
.rail-shell {
  display: grid;
  align-content: start;
}

.accounts-nav {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.nav-head,
.rail-section,
.stage-section {
  padding: 18px;
}

.nav-head,
.rail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.nav-head,
.rail-section + .rail-section,
.stage-section + .stage-section {
  border-top: 1px solid var(--line);
}

.nav-head {
  border-top: none;
}

.nav-head h2,
.rail-head h2 {
  font-size: 18px;
}

.nav-empty-state {
  display: grid;
  gap: 8px;
  padding: 0 18px 18px;
}

.nav-empty-state strong {
  font-size: 14px;
}

.account-nav-list {
  min-height: 0;
  overflow: hidden;
  padding: 0 10px 10px 10px;
  display: grid;
  gap: 6px;
  scrollbar-width: none;
}

.account-nav-list.is-scrollable {
  overflow-y: auto;
}

.account-nav-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.account-nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 16px;
  padding: 12px 12px 12px 14px;
  display: grid;
  gap: 10px;
  background: transparent;
  color: inherit;
  transition: background 160ms ease, border-color 160ms ease;
}

.account-nav-item:hover {
  background: rgba(255, 255, 255, 0.52);
}

.account-nav-item.is-active {
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
}

.account-nav-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.account-nav-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.account-nav-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-0);
}

.account-nav-server {
  font-size: 12px;
  line-height: 1.45;
}

.account-stage {
  background: var(--panel-strong);
}

.stage-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.stage-section {
  display: grid;
  gap: 12px;
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stage-copy {
  display: grid;
  gap: 6px;
}

.stage-title {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 0.95;
}

.stage-server,
.stage-timestamp {
  font-size: 13px;
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stage-actions .primary-button,
.stage-actions .secondary-button {
  min-height: 40px;
  padding-inline: 16px;
}

.stage-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-block {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel-muted);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.metric-value.is-compact {
  font-size: 18px;
}

.stage-feedback {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-left: 3px solid rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.04);
}

.stage-feedback.is-error {
  background: var(--danger-soft);
  border-left-color: rgba(194, 94, 72, 0.4);
}

.stage-feedback.is-success {
  background: var(--success-soft);
  border-left-color: rgba(31, 143, 99, 0.36);
}

.stage-feedback-title {
  font-size: 14px;
  font-weight: 700;
}

.stage-feedback-detail,
.stage-feedback-raw {
  font-size: 13px;
  line-height: 1.6;
}

.stage-feedback-raw {
  font-family: var(--mono);
  color: var(--text-2);
}

.stage-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 18px;
}

.stage-runtime,
.stage-symbol-shell {
  display: grid;
  gap: 12px;
}

.stage-runtime-head {
  display: grid;
  gap: 6px;
}

.stage-runtime-caption {
  margin: 0;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.6;
}

.stage-runtime-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 18px;
  align-items: start;
}

.stage-runtime-timeline {
  display: grid;
}

.stage-runtime-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.stage-runtime-row:last-child {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.stage-runtime-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.14);
}

.stage-runtime-row.is-complete .stage-runtime-dot {
  background: var(--success);
}

.stage-runtime-row.is-active .stage-runtime-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.stage-runtime-row.is-error .stage-runtime-dot {
  background: var(--danger);
}

.stage-runtime-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.stage-runtime-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
}

.stage-runtime-label {
  font-size: 13px;
  letter-spacing: -0.01em;
}

.stage-runtime-value {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage-runtime-detail {
  margin: 0;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.6;
}

.stage-runtime-facts {
  display: grid;
  gap: 10px;
  align-content: start;
}

.stage-runtime-fact {
  display: grid;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.stage-runtime-fact-label {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage-runtime-fact-value {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

.stage-note {
  font-size: 13px;
  line-height: 1.6;
}

.stage-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-symbol-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 12px;
  color: var(--text-1);
}

.stage-empty {
  min-height: 100%;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 32px;
}

.stage-empty strong {
  font-size: 18px;
}

.stage-empty p {
  margin: 0;
  color: var(--text-1);
  line-height: 1.7;
}

.import-rail {
  min-height: 0;
}

.rail-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.rail-shell .rail-section:first-child {
  border-top: none;
}

.rail-head {
  display: grid;
  gap: 6px;
}

.rail-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.rail-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.rail-mode-button {
  min-height: 38px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.rail-mode-button.is-active {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--accent);
}

.rail-panels {
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
}

.rail-panel {
  display: none;
  height: 100%;
  padding: 18px;
}

.rail-panel.is-active {
  display: block;
}

.rail-form,
.field,
.gate-actions,
.local-auth-fields {
  display: grid;
  gap: 12px;
}

.local-auth-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-0);
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field-note {
  margin: -4px 2px 0;
  font-size: 12px;
  line-height: 1.5;
}

.field-note.is-success {
  color: var(--success);
}

.field-note.is-error {
  color: var(--danger);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  color: var(--text-1);
}

.fallback-form {
  align-content: start;
}

.console-log {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.workspace-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(10px);
}

.workspace-modal {
  width: min(880px, calc(100vw - 48px));
  max-height: min(86vh, 920px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
}

.workspace-modal-head,
.workspace-modal-toolbar,
.workspace-modal-footer,
.workspace-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-modal-head h2,
.workspace-modal-section-head h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.workspace-modal-note {
  margin: 0;
  color: var(--text-1);
  font-size: 14px;
}

.workspace-modal-body {
  min-height: 0;
  display: grid;
  gap: 16px;
  overflow: auto;
  padding-right: 2px;
}

.workspace-modal-section {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  display: grid;
  gap: 14px;
}

.workspace-modal-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-inline {
  max-width: 260px;
}

.publishing-account-grid {
  display: grid;
  gap: 10px;
}

.publishing-account-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
}

.publishing-account-card.is-focused {
  outline: 2px solid rgba(37, 99, 235, 0.22);
  border-color: rgba(37, 99, 235, 0.24);
}

.publishing-account-card input[type="checkbox"] {
  margin-top: 3px;
}

.publishing-account-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.publishing-account-head,
.publishing-account-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.publishing-account-name {
  margin: 0;
  font-size: 15px;
}

.publishing-account-meta {
  margin: 0;
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.6;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-1);
}

.mini-pill.is-public {
  background: var(--success-soft);
  color: var(--success);
}

.workspace-modal-actions .secondary-button.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .workspace-layout {
    grid-template-columns: 240px minmax(0, 1fr) 300px;
  }
}

@media (max-width: 1080px) {
  .workspace-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .accounts-nav {
    grid-template-rows: auto auto auto;
  }

  .account-nav-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .account-nav-list.is-scrollable {
    overflow-x: auto;
    overflow-y: hidden;
  }

  .stage-shell {
    grid-template-rows: auto auto auto auto;
  }

  .stage-runtime-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .accounts-shell {
    padding: 12px;
  }

  .workspace-topbar,
  .topbar-copy,
  .topbar-session,
  .stage-head,
  .gate-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .local-auth-fields,
  .stage-summary,
  .workspace-modal-form-grid {
    grid-template-columns: 1fr;
  }

  .workspace-modal {
    width: min(100vw - 24px, 880px);
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .workspace-modal-toolbar,
  .workspace-modal-footer,
  .workspace-modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .field-inline {
    max-width: none;
  }
}
