:root {
  color-scheme: light;
  --md-sys-color-primary: #2f5bda;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #dfe7ff;
  --md-sys-color-on-primary-container: #102a72;
  --md-sys-color-secondary: #53627a;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #dde5f4;
  --md-sys-color-on-secondary-container: #1d293c;
  --md-sys-color-tertiary: #8c4f7d;
  --md-sys-color-surface: #f4f7fb;
  --md-sys-color-surface-dim: #edf1f7;
  --md-sys-color-surface-bright: #ffffff;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #fbfcff;
  --md-sys-color-surface-container: #f3f6fb;
  --md-sys-color-surface-container-high: #ebf0f7;
  --md-sys-color-surface-container-highest: #e1e8f1;
  --md-sys-color-surface-variant: #d6deea;
  --md-sys-color-on-surface: #17212f;
  --md-sys-color-on-surface-variant: #586579;
  --md-sys-color-outline: #7b8798;
  --md-sys-color-outline-variant: #d6deea;
  --md-sys-color-error: #b42318;
  --md-sys-color-error-container: #fde7e4;
  --md-sys-color-success: #147d48;
  --md-sys-color-success-container: #ddf7e7;
  --md-sys-color-warning: #b4690e;
  --md-sys-color-warning-container: #fff1db;
  --md-sys-color-backdrop: rgba(16, 24, 40, 0.18);
  --md-elevation-1: 0 1px 2px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.06);
  --md-elevation-2: 0 4px 10px rgba(16, 24, 40, 0.10), 0 2px 4px rgba(16, 24, 40, 0.05);
  --md-elevation-3: 0 12px 24px rgba(16, 24, 40, 0.12), 0 6px 10px rgba(16, 24, 40, 0.06);
  --md-radius-xl: 22px;
  --md-radius-lg: 18px;
  --md-radius-md: 16px;
  --md-radius-sm: 14px;
  --md-radius-xs: 10px;
  --drawer-shift: min(224px, calc(100vw - 20px));
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47, 91, 218, 0.10), transparent 24%),
    radial-gradient(circle at top right, rgba(140, 79, 125, 0.08), transparent 20%),
    linear-gradient(180deg, #f8faff 0%, #f4f7fb 100%);
  color: var(--md-sys-color-on-surface);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none; }

.app-shell { padding: 0; overflow-x: clip; }
.drawer-layout { position: relative; min-height: 100vh; }
.material-content-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  position: relative;
  min-height: 100vh;
  padding: 8px 10px 10px;
  transition: transform 220ms ease;
  will-change: transform;
}

.drawer-open .material-content-shell {
  transform: translateX(var(--drawer-shift));
}

.page-scene {
  animation: page-enter 180ms ease;
  transform-origin: top center;
  margin-top: 1px;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card,
.panel,
.material-topbar,
.material-drawer {
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  box-shadow: var(--md-elevation-1);
}

.material-login-card {
  width: min(100%, 460px);
  border-radius: var(--md-radius-xl);
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.brand-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
}

.login-card h1,
.topbar-title h1,
.section-title,
.material-drawer-title,
.material-overview-card h3 {
  margin: 0;
  letter-spacing: -0.02em;
}

.login-card h1 { font-size: clamp(24px, 3.4vw, 32px); }

.lead,
.muted,
.tree-meta,
.job-meta,
.editor-subtitle,
.helper-text,
.support-copy,
.material-nav-copy span {
  color: var(--md-sys-color-on-surface-variant);
}

.login-form,
.form-field,
.env-list,
.env-extra,
.material-content-shell,
.editor-page-grid,
.browser-page-grid,
.text-editor-grid,
.compact-grid,
.material-surface-grid {
  display: grid;
  gap: 16px;
}

.browser-page-grid,
.editor-page-grid {
  min-height: 0;
  height: 100%;
  width: 100%;
}

.form-field { gap: 8px; }
.form-label { color: var(--md-sys-color-on-surface); font-size: 14px; }

.text-input,
.text-area,
.env-value-input,
.comment-input {
  width: 100%;
  border-radius: var(--md-radius-xs);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 14px 16px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.text-input:focus,
.text-area:focus,
.env-value-input:focus,
.comment-input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(47, 91, 218, 0.16);
}

.text-area,
.comment-input,
.env-value-input { resize: none; overflow: hidden; }

.checkbox-row,
.topbar-meta,
.env-toolbar,
.status-toolbar,
.status-row,
.button-row,
.tree-nav,
.material-chip-row,
.sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.checkbox-row { color: var(--md-sys-color-on-surface); font-size: 14px; }

.primary-btn,
.secondary-btn,
.ghost-btn,
.action-btn,
.save-btn,
.icon-btn {
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid var(--md-sys-color-outline);
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.material-filled-button,
.primary-btn,
.save-btn {
  background: var(--md-sys-color-success);
  color: #ffffff;
  font-weight: 700;
}

.material-filled-button,
.primary-btn {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-weight: 700;
}

.material-outlined-button,
.ghost-btn,
.secondary-btn,
.icon-btn {
  background: transparent;
  border-color: var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface);
}

.material-tonal-button {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.material-action-button {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
  border-color: rgba(47, 91, 218, 0.28);
}

.action-btn[data-action="stop"] {
  background: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-warning);
}

.action-btn[data-action="uninstall"] {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.action-btn:hover,
.save-btn:hover,
.icon-btn:hover,
.nav-button:hover,
.tree-item:hover {
  transform: translateY(-1px);
}

.material-icon-button,
.sidebar-toggle,
.sidebar-close,
.env-toggle {
  width: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}

.sidebar-toggle span,
.sidebar-close span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.sidebar-close span:first-child { transform: translateY(3px) rotate(45deg); }
.sidebar-close span:last-child { transform: translateY(-3px) rotate(-45deg); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-radius: 18px;
  padding: 5px 8px;
}

.material-topbar {
  background: rgba(244, 247, 251, 0.98);
  backdrop-filter: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  box-shadow: none;
}

.topbar-line {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: space-between;
  align-items: center;
}

.topbar-leading {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title.compact-title { flex: 0 1 auto; }
.topbar-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: nowrap;
}
.title-file-pill {
  min-width: 0;
  max-width: 10ch;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: 1px solid rgba(47, 91, 218, 0.14);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-title h1 {
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title p { margin: 0; }
.topbar-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-left: auto;
  align-items: center;
  min-width: 0;
}

.topbar-action-btn,
.editor-status-chip,
.status-refresh-btn,
.tree-nav > .secondary-btn,
.tree-nav > .ghost-btn,
.tree-nav > .save-btn,
.tree-nav > .action-btn {
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
}

.topbar-action-btn {
  min-height: 28px;
  padding: 0 7px;
  font-size: 13px;
}

.badge.editor-status-chip,
.material-state-chip.editor-status-chip {
  min-height: 18px;
  padding: 0 5px;
  font-size: 8px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
}

.status-refresh-btn {
  min-height: 26px;
  padding: 0 6px;
  font-size: 13px;
}

.pane-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  width: min(100%, 420px);
  padding: 4px;
  border-radius: 999px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  margin-bottom: 10px;
}

.pane-switch::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--md-sys-color-secondary-container);
  transition: transform 220ms ease;
}

.pane-switch[data-pane="preview"]::before {
  transform: translateX(100%);
}

.pane-switch .segmented-button {
  position: relative;
  z-index: 1;
  border-color: transparent;
  background: transparent;
}

.pane-switch .segmented-button.active {
  background: transparent;
  color: var(--md-sys-color-on-secondary-container);
}

.badge,
.material-state-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge.ok { color: var(--md-sys-color-success); border-color: rgba(132,216,168,0.35); }
.badge.warn { color: var(--md-sys-color-warning); border-color: rgba(180,105,14,0.30); }
.badge.danger { color: var(--md-sys-color-error); border-color: rgba(180,35,24,0.26); }
.badge.info { color: var(--md-sys-color-primary); border-color: rgba(47,91,218,0.24); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--md-sys-color-backdrop);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--drawer-shift);
  height: 100vh;
  max-height: none;
  overflow: hidden;
  border-radius: 0;
  z-index: 40;
  transform: translateX(calc(-100% - 12px));
  transition: transform 220ms ease;
  display: flex;
  flex-direction: column;
}

.sidebar.is-open {
  transform: translateX(0);
}

.material-drawer {
  background: var(--md-sys-color-surface-container-low);
  box-shadow: var(--md-elevation-3);
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
}

.material-drawer-topbar,
.material-drawer-section {
  padding: 12px 14px;
}

.material-drawer-section { flex: 0 0 auto; }

.material-drawer-topbar + .material-drawer-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 12px;
}

.material-drawer-supporting {
  margin-top: auto;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  background: var(--md-sys-color-surface-container-low);
}

.material-drawer-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.material-drawer-title { font-size: 18px; }
.material-label { color: var(--md-sys-color-on-surface-variant); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.material-nav-list { gap: 6px; margin-top: 10px; }

.nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 6px 8px;
  min-height: 44px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--md-sys-color-on-surface);
}

.material-nav-indicator {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
}

.material-nav-indicator svg { width: 16px; height: 16px; display: block; }
.material-nav-copy { display: grid; gap: 2px; }
.material-nav-copy strong { font-size: 13px; }

.nav-button.active {
  background: rgba(47, 91, 218, 0.08);
}

.nav-button.active .material-nav-indicator {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.support-card {
  border-radius: 14px;
  background: var(--md-sys-color-surface-container-high);
  padding: 10px;
  display: grid;
  gap: 6px;
}

.support-card.compact { gap: 10px; }
.support-title { font-size: 16px; font-weight: 700; }
.support-copy { font-size: 13px; line-height: 1.45; }
.support-kv { display: flex; justify-content: space-between; gap: 10px; color: var(--md-sys-color-on-surface-variant); font-size: 12px; }
.support-kv strong { color: var(--md-sys-color-on-surface); text-align: right; }

.logout-btn {
  color: var(--md-sys-color-error);
  border-color: rgba(180, 35, 24, 0.28);
  background: var(--md-sys-color-error-container);
  width: 100%;
  justify-content: center;
}

.panel {
  border-radius: var(--md-radius-xl);
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.compact-meta-row {
  margin-bottom: 12px;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
}

.compact-meta-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.compact-meta-button {
  appearance: none;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-left: auto;
  align-self: flex-start;
}

.compact-meta-button:hover {
  transform: translateY(-1px);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: rgba(47,91,218,0.28);
}

.compact-head {
  padding-bottom: 14px;
}

.compact-copy {
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
}

.panel-head,
.panel-body,
.editor-head,
.preview-head,
.job-head,
.env-head,
.editor-body,
.preview-body,
.job-body,
.env-body {
  padding: 10px 12px;
}

.panel-head,
.editor-head,
.preview-head,
.job-head,
.env-head {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.panel > .panel-body:first-child {
  padding-top: 10px;
}

.browser-page-grid .panel-body,
.editor-page-grid .panel-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.material-surface-grid {
  background: var(--md-sys-color-surface-container);
}

.compact-grid.two-up { grid-template-columns: 1.6fr 1fr; }

.browser-filter-row { margin-bottom: 10px; }

.filter-chip,
.segmented-button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.filter-chip.active,
.segmented-button.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.segmented-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--md-sys-color-surface-container-high);
  margin-bottom: 18px;
}

.mode-scene {
  animation: mode-enter 180ms ease;
}

@keyframes mode-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.material-overview-card {
  border-radius: 24px;
  padding: 20px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: grid;
  gap: 10px;
}

.material-overview-card.emphasis {
  background: linear-gradient(180deg, rgba(47,60,110,0.64), rgba(31,31,38,0.95));
}

.material-overview-card h3 { font-size: 22px; }
.material-overview-card p { margin: 0; color: var(--md-sys-color-on-surface-variant); line-height: 1.55; }

.overview-pair {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.overview-pair:last-child { border-bottom: 0; }
.overview-pair span { color: var(--md-sys-color-on-surface-variant); }

.tree-nav {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.tree-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-items: stretch;
  justify-content: flex-start;
}

.tree-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  text-align: left;
  padding: 4px 8px;
  min-height: 42px;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  transition: background 650ms ease, border-color 650ms ease, color 650ms ease, transform 160ms ease;
}

.tree-item.active {
  background: rgba(47, 91, 218, 0.08);
  border-color: rgba(47, 91, 218, 0.22);
}

.tree-item.danger-press {
  background: rgba(180, 35, 24, 0.10);
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--md-sys-color-error);
}

.tree-item-leading { display: flex; align-items: center; }
.tree-item-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--md-sys-color-secondary-container);
  position: relative;
}

.tree-item-icon.folder::before,
.tree-item-icon.file::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 4px;
  background: currentColor;
}

.tree-item-icon.folder { color: var(--md-sys-color-on-secondary-container); }
.tree-item-icon.file { color: var(--md-sys-color-primary); }

.tree-item-body { min-width: 0; display: grid; gap: 1px; align-content: start; align-self: start; padding-top: 0; }
.tree-item-title { display: flex; justify-content: space-between; gap: 6px; align-items: center; font-weight: 600; font-size: 13px; line-height: 1.2; }
.tree-item .badge { min-height: 18px; padding: 0 7px; font-size: 10px; }
.tree-meta {
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-item-trailing { color: var(--md-sys-color-on-surface-variant); font-size: 18px; }

.status-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-metric-card {
  border-radius: 16px;
  padding: 12px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.status-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.status-toolbar-leading,
.status-toolbar-trailing {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-toolbar-inline {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.status-toolbar-inline .status-refresh-btn {
  margin-left: auto;
  width: fit-content;
  flex: 0 0 auto;
}

.action-cluster {
  margin-bottom: 10px;
}

.status-page .dashboard-metric-card,
.status-page .dashboard-metric-card.ok,
.status-page .dashboard-metric-card.warn,
.status-page .dashboard-metric-card.danger,
.status-page .dashboard-metric-card.info,
.status-page .status-card,
.status-page .info-card,
.status-page .job-output {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.status-page .dashboard-metric-grid,
.status-page .status-grid,
.status-page .info-grid {
  gap: 8px;
}

.status-page .dashboard-metric-card,
.status-page .status-card,
.status-page .info-card {
  padding: 6px 0;
  border-radius: 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 58px;
}

.status-page .job-output {
  border-radius: 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.status-page .job-head,
.status-page .job-body {
  padding-left: 0;
  padding-right: 0;
}

.status-page .panel-body {
  padding-top: 3px;
}

.dashboard-metric-card.ok { background: linear-gradient(180deg, rgba(20,55,38,.95), var(--md-sys-color-surface-container-high)); }
.dashboard-metric-card.warn { background: linear-gradient(180deg, rgba(77,56,0,.95), var(--md-sys-color-surface-container-high)); }
.dashboard-metric-card.danger { background: linear-gradient(180deg, rgba(147,0,10,.88), var(--md-sys-color-surface-container-high)); }
.dashboard-metric-card.info { background: linear-gradient(180deg, rgba(47,60,110,.65), var(--md-sys-color-surface-container-high)); }

.dashboard-metric-value {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.status-card,
.info-card,
.editor-card,
.preview-card,
.job-output,
.env-card {
  border-radius: 18px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
}

.env-list.pane-preview .editor-card,
.env-list.pane-preview .editor-body {
  border: 0;
  background: transparent;
  padding: 0;
}

.status-label,
.info-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}

.status-value,
.info-value {
  margin-top: 4px;
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}

.material-log-card pre,
.syntax-preview,
.job-log,
.runtime-log {
  margin: 0;
  background: #f8fafc;
  border-radius: 14px;
  color: var(--md-sys-color-on-surface);
  padding: 12px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-editor-grid { grid-template-columns: minmax(0, 1fr); }
.text-editor-grid.pane-edit,
.text-editor-grid.pane-preview { grid-template-columns: minmax(0, 1fr); }
.text-editor-grid,
.env-list {
  min-height: 0;
  width: 100%;
}
.text-area { min-height: 420px; line-height: 1.55; }
.source-mode { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; }
.no-wrap-editor {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  overflow-x: auto;
}
.code-editor-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 420px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  position: relative;
}

.code-editor-shell:focus-within {
  box-shadow: none;
}

.code-editor-gutter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  flex: 0 0 auto;
  box-sizing: border-box;
  min-width: 0;
  padding: 10px 0.75ch;
  background: transparent;
  border-right: 0;
  color: var(--md-sys-color-on-surface-variant);
  text-align: right;
  user-select: none;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  grid-column: 1;
  grid-row: 1;
}

.code-editor-gutter span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 1.3em;
}

.code-editor-textarea {
  min-height: 420px;
  width: 100%;
  min-width: 0;
  padding: 10px 8px 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 1;
}

.code-editor-textarea,
.code-editor-highlight,
.code-editor-gutter {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-variant-ligatures: none;
  font-kerning: none;
  text-rendering: geometricPrecision;
}

.code-editor-textarea:focus {
  box-shadow: none;
}

.syntax-preview { min-height: 420px; }
.job-log, .runtime-log { min-height: 180px; }

.env-list.pane-preview .preview-card,
.env-list.pane-edit .env-card { display: block; }

.env-card { border-color: rgba(47, 91, 218, 0.10); }
.env-key-row,
.env-value-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
  width: 100%;
}
.env-key-label {
  min-height: 22px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  font-weight: 600;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1 1 auto;
  width: auto;
  max-width: none;
}
.env-toggle {
  min-width: 0;
  min-height: 22px;
  width: fit-content;
  padding: 0 3px;
  flex-direction: row;
  gap: 0;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}
.env-value-input {
  min-height: 24px;
  line-height: 1.25;
  padding: 4px 8px;
  font-size: 13px;
  width: 100%;
  min-width: 0;
}
.env-value-row { margin-top: 6px; }

.env-card {
  width: 100%;
}

.env-body {
  width: 100%;
}

.code-editor-highlight {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 3ch;
  margin: 0;
  padding: 10px 8px 10px 0;
  overflow: hidden auto;
  pointer-events: none;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  z-index: 1;
  background: transparent;
  grid-column: 2;
  grid-row: 1;
}

.code-editor-shell-env .code-editor-gutter {
  min-width: 0;
  padding-left: 1ch;
  padding-right: 1ch;
}
.env-comment-block {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
}
.comment-input {
  min-height: 32px;
  line-height: 1.5;
}

.editor-mode-divider {
  height: 1px;
  width: 100%;
  margin: 0 0 12px;
  background: var(--md-sys-color-outline-variant);
}

.helper-text { font-size: 13px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 55;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: var(--md-elevation-3);
}

.toast.success { border-color: rgba(132,216,168,0.35); }
.toast.error { border-color: rgba(255,180,171,0.35); }
.toast.info { border-color: rgba(182,196,255,0.35); }

.file-action-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.18);
  z-index: 65;
}

.file-action-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 24px));
  padding: 16px;
  border-radius: 18px;
  background: var(--md-sys-color-surface-bright);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-elevation-3);
  z-index: 66;
  display: grid;
  gap: 12px;
}

.file-action-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  word-break: break-word;
}

.clear-cache-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 48px));
  padding: 16px;
  border-radius: 18px;
  background: var(--md-sys-color-surface-bright);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-elevation-3);
  z-index: 66;
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto auto 1fr auto;
}

.clear-cache-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.clear-cache-desc {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  margin: -4px 0;
}

.clear-cache-filter-row {
  display: flex;
  gap: 8px;
}

.clear-cache-filter-row .text-input {
  flex: 1;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
}

.clear-cache-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
  max-height: 240px;
  padding: 4px 0;
}

.clear-cache-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease;
}

.clear-cache-item:hover {
  background: var(--md-sys-color-surface-container-high);
}

.clear-cache-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--md-sys-color-primary);
}

.clear-cache-empty {
  text-align: center;
  padding: 16px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

.clear-cache-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 820px) {
  .clear-cache-modal {
    width: min(100%, calc(100vw - 16px));
    max-height: min(80vh, calc(100vh - 32px));
  }
  .clear-cache-actions {
    flex-direction: column;
  }
  .clear-cache-actions button {
    width: 100%;
  }
}

.file-action-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.danger-btn {
  color: var(--md-sys-color-error);
  border-color: rgba(180, 35, 24, 0.25);
}

.empty-state {
  padding: 22px 16px;
  text-align: center;
  border-radius: 18px;
  border: 1px dashed var(--md-sys-color-outline);
  color: var(--md-sys-color-on-surface-variant);
}

.material-empty-state {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.tok-key { color: #1d4ed8; }
.tok-string { color: #0f766e; }
.tok-number { color: #b45309; }
.tok-bool { color: #8b5cf6; }
.tok-comment { color: #7b8798; }
.tok-heading { color: #0f172a; font-weight: 700; }
.tok-list { color: #334155; }
.tok-code { color: #9333ea; }
.tok-op { color: #ca8a04; }

@media (max-width: 1200px) {
  .text-editor-grid,
  .compact-grid.two-up,
  .dashboard-metric-grid,
  .status-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .topbar-line {
    flex-wrap: nowrap;
    align-items: center;
  }

  .topbar-title {
    flex: 1 1 auto;
  }

  .topbar-meta {
    width: auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .status-toolbar {
    align-items: stretch;
    margin-bottom: 10px;
  }

  .status-toolbar-inline {
    flex-wrap: wrap;
  }

  .sidebar {
    width: var(--drawer-shift);
    height: 100vh;
  }
}

@media (max-width: 820px) {
  .topbar, .panel, .material-login-card { border-radius: 24px; }
  .sidebar { border-radius: 0; }
  .topbar-line { gap: 8px; flex-wrap: nowrap; align-items: center; }
  .topbar-title,
  .topbar-meta { min-width: 0; width: auto; }
  .topbar-title h1 { font-size: 16px; }
  .topbar-meta {
    gap: 6px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .tree-item { grid-template-columns: auto minmax(0, 1fr); }
  .tree-item-trailing { display: none; }
  .env-key-row,
  .env-value-row {
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
  }

  .env-toggle {
    margin-left: 0;
    align-self: flex-end;
  }
  .pane-switch,
  .pane-switch .segmented-button,
  .env-toggle,
  .env-key-label,
  .env-value-input,
  .secondary-btn,
  .save-btn,
  .ghost-btn,
  .action-btn { width: 100%; }
  .file-action-buttons { grid-template-columns: 1fr; }
  .text-input,
  .text-area,
  .env-value-input,
  .comment-input,
  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .action-btn,
  .save-btn,
  .icon-btn { font-size: 13px; }
  .text-area,
  .syntax-preview { min-height: 360px; }
  .code-editor-shell,
  .code-editor-textarea { min-height: 360px; }
  .material-content-shell { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .material-content-shell,
  .sidebar,
  .sidebar-backdrop,
  .page-scene,
  .mode-scene,
  .pane-switch::before {
    animation: none;
    transition: none;
  }
}
