/* Two persistent background layers; polling never restarts their animation. */
:root {
  --surface-depth: 0 8px 24px #00000024, inset 0 1px 0 #ffffff08;
  --label-glow: 0 0 15px color-mix(in srgb, currentColor 13%, transparent);
  --selection-glow: 0 0 22px #a6ed7810, inset 0 1px 0 #d6ffbd0a;
}

.ambient-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
.ambient-backdrop::before, .ambient-backdrop::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
.ambient-backdrop::before {
  inset: -56px;
  background-image: linear-gradient(#a6ed7809 1px, transparent 1px), linear-gradient(90deg, #a6ed7809 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(#0009, transparent 85%);
  animation: ambient-grid-drift 52s ease-in-out infinite alternate;
}
.ambient-backdrop::after {
  inset: -12%;
  background: radial-gradient(ellipse at 76% 12%, #95e87120, transparent 42%), radial-gradient(ellipse at 20% 66%, #5f9cd714, transparent 45%);
  animation: ambient-light-drift 28s ease-in-out infinite alternate;
}
.app-shell { position: relative; z-index: 1; }
.sidebar { background: linear-gradient(165deg, #17201a 0, #10151c 180px, #101319 70%); }
.topbar { background: #0e131aed; box-shadow: inset 0 1px 0 #ffffff03; }
.footer { background: #0b1015b8; }

/* Light edges separate surfaces without making every panel a glowing button. */
.project-group, .container-card, .host-card, .stat-card, .login-card { box-shadow: var(--surface-depth); }
.project-group-header { background: linear-gradient(110deg, #18231f, #151d25 65%); border-bottom-color: #2e3943; }
.project-title p, .service-note { color: #8c9eaf; }
.project-group-footer { background: #10161d; }
.workspace-status, .host-fleet { box-shadow: inset 0 1px 0 #c6f8a911, var(--surface-depth); }
.project-emblem, .host-symbol { box-shadow: inset 0 1px 0 #d4fdb912; }
.brand-mark { box-shadow: 0 4px 20px #a6ed7820, inset 0 1px 0 #e5ffd680; }
.stat-card.green .stat-number { text-shadow: 0 0 28px #a6ed7820; }
.stat-card.amber .stat-number { text-shadow: 0 0 28px #e7ba6919; }

/* Glow follows the existing status color; stopped and offline remain neutral. */
.status.running, .status.error, .status.starting, .status.external,
.reviewed-tag, .tag, .mini-tag, .container-health, .nav-count { box-shadow: var(--label-glow); }
.status.running .dot, .status.error .dot, .status.starting .dot, .status.external .dot {
  box-shadow: 0 0 7px currentColor;
}
.nav-item.active { border-color: #354631; box-shadow: inset 3px 0 0 var(--accent); background: linear-gradient(90deg, #253122, #19231d); }
.nav-item.active > .icon { filter: drop-shadow(0 0 5px #a6ed7836); }
.filter-tabs button.active { color: #c6eba9; box-shadow: inset 0 -2px 0 var(--accent), inset 0 1px 0 #d6ffbd0a; background: #253023; }
.host-card.selected { border-color: #779a57; box-shadow: var(--surface-depth), var(--selection-glow); }
.log-project.selected, .log-app.selected, .shell-session.selected { box-shadow: inset 0 0 24px #a6ed7808; }
.ai-steps .active b { box-shadow: var(--label-glow); }

.motion-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #344333;
  border-radius: 6px;
  background: #19251c;
  color: #b1d396;
  font-size: 11px;
  white-space: nowrap;
  transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease, background-color var(--motion-fast) ease;
}
.motion-toggle > .icon, .motion-toggle > span > .icon { width: 14px; height: 14px; }
.motion-toggle[aria-pressed=false] { background: #151c23; color: #91a0af; border-color: #303c48; }
.motion-toggle:hover:not(:disabled) { border-color: #91ae76; color: #d2e9bf; }
.motion-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@keyframes ambient-grid-drift { to { transform: translate(28px, -28px); } }
@keyframes ambient-light-drift { to { transform: translate(-3%, 4%) scale(1.04); } }

html[data-page-hidden=true] .ambient-backdrop::before,
html[data-page-hidden=true] .ambient-backdrop::after { animation-play-state: paused; }
html[data-motion=off] { --surface-depth: inset 0 1px 0 #ffffff06; --label-glow: 0 0 transparent; --selection-glow: 0 0 transparent; }
html[data-motion=off] .ambient-backdrop { display: none; }
html[data-motion=off] *, html[data-motion=off] *::before, html[data-motion=off] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html[data-motion=off] .brand-mark, html[data-motion=off] .status .dot { box-shadow: none; }
html[data-motion=off] .stat-number { text-shadow: none; }
html[data-motion=off] .nav-item.active > .icon { filter: none; }

@media (hover: hover) and (pointer: fine) {
  .project-group:hover, .container-card:hover, .host-card:hover { border-color: #4e6556; }
  .host-card.selected:hover { border-color: #92b774; }
  .service-row:hover { background: linear-gradient(90deg, transparent, #a6ed7804, transparent); }
}
@media (max-width: 760px) {
  .ambient-backdrop::before { background-size: 40px 40px; opacity: .6; }
  .ambient-backdrop::after { opacity: .65; }
  .motion-toggle { min-width: 32px; min-height: 32px; padding: 6px; }
  #motion-label { display: none; }
}
@media (pointer: coarse) { .motion-toggle { min-width: 40px; min-height: 40px; } }
@media (prefers-reduced-motion: reduce) {
  .ambient-backdrop::before, .ambient-backdrop::after { animation: none; transform: none; }
  .ambient-backdrop { opacity: .65; }
}
@media (forced-colors: active) {
  .ambient-backdrop { display: none; }
  .nav-item.active, .filter-tabs button.active, .host-card.selected { border: 1px solid Highlight; }
  .motion-toggle { border-color: ButtonText; color: ButtonText; }
  .motion-toggle:focus-visible { outline-color: Highlight; }
  .nav-item.active > .icon { filter: none; }
}

/* Native disclosure keeps host setup readable without another view or UI state. */
.onboarding-step { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 16px 0; min-width: 0; background: #101a2270; }
.onboarding-step summary { cursor: pointer; color: #c4d6bd; font-size: 13px; line-height: 1.8; }
.onboarding-step summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 3px; }
.onboarding-step[open] summary { margin-bottom: 14px; }
.onboarding-step .detail-notes { margin: 12px 0 0; }
.onboarding-guide .text-button { white-space: normal; overflow-wrap: anywhere; text-align: left; line-height: 1.7; margin: 8px 0; }
.onboarding-guide .text-button > .icon { flex-shrink: 0; }
.onboarding-links { display: flex; flex-wrap: wrap; column-gap: 18px; }

/* Shared surface details: existing components, palette and layout. */
.panel, .project-group, .stat-card, .container-card, .host-card,
.maintenance-step, .login-card, .ai-service, .ai-batch-item, .ai-recent-item,
.ops-parameter, .ops-recipe, .ops-deploy-preview { box-shadow: var(--surface-depth); }
.project-group { background: radial-gradient(ellipse at 96% 0, #a6ed7807, transparent 44%), #111820; transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease; }
.project-group, .stat-card, .container-card, .host-card { border-color: #34404a; }
.project-title h2 { color: #e3ebe1; }
.service-command code, .container-port-map { color: #98a9ba; }
.project-app-count { color: #93a88b; }
.service-row { transition: background-color var(--motion-fast) ease; }
.stat-card { background: radial-gradient(ellipse at 100% 0, #a6ed7808, transparent 55%), linear-gradient(130deg, #151c25, #11151d); transform: none; }
.stat-card.green { border-color: #42573b; background: radial-gradient(ellipse at 100% 0, #a6ed7813, transparent 60%), linear-gradient(135deg, #19251f, #131c19); }
.stat-card.amber { border-color: #51442f; background: radial-gradient(ellipse at 100% 0, #e7ba6910, transparent 60%), linear-gradient(135deg, #251f1a, #161920); }
.stat-top { color: #a1adbc; }
.stat-number { font-weight: 600; }
.page-heading p, .application-count, .chart-labels, .terminal-footer, .shell-cwd, .container-card-top code { color: #8c9eaf; }

/* Selection is persistent; hover and keyboard focus remain separate. */
.project-group:focus-within, .container-card:focus-within, .host-card:focus-within { border-color: #718765; }
.project-group:has(.project-select > input:checked), .host-card.selected {
  border-color: #8db76b; box-shadow: inset 3px 0 0 var(--accent), var(--surface-depth);
}
.log-project.selected, .log-app.selected, .shell-session.selected, .project-option.selected {
  box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 #d6ffbd0a;
}
.ai-directory-item.is-selected { border-color: #8db76b; box-shadow: inset 3px 0 0 var(--accent), var(--surface-depth); }
.ai-tabs .button.primary, #modal .ops-tabs button[aria-selected=true] { color: #c6eba9; background: #253023; border-color: #506844; box-shadow: inset 0 -2px 0 var(--accent); }
.ai-tabs .button.primary:hover:not(:disabled) { color: #c6eba9; background: #2d3b28; border-color: #6d8956; box-shadow: inset 0 -2px 0 var(--accent), inset 0 1px 0 #d6ffbd0a; }
.log-reader-controls [aria-pressed=true] { color: #c6eba9; text-decoration: underline; text-underline-offset: 4px; }
.maintenance-step.step-active { border-color: #79955e; box-shadow: inset 3px 0 0 var(--accent), var(--surface-depth); }

/* Shared buttons, forms and dialogs. No fields or actions are changed. */
.button.primary { box-shadow: 0 3px 15px #a6ed781c, inset 0 1px 0 #e5ffd64d; }
.button:not(.primary):not(.stop-button):not(.migration-button):not(.danger-text) { box-shadow: inset 0 1px 0 #ffffff06; }
.search-field:focus-within { border-color: #8bb06c; box-shadow: 0 0 0 2px #a6ed7814; }
:is(.form-body, .step-editor, .shell-input-form, .login-card) :is(input:not([type=checkbox]):not([type=radio]), textarea, select),
.ai-host-panel select, .log-level-select { border-color: #3b4856; box-shadow: inset 0 1px 0 #ffffff05; }
:is(.form-body, .step-editor, .shell-input-form, .login-card) :is(input:not([type=checkbox]):not([type=radio]), textarea, select):focus,
.ai-host-panel select:focus, .log-level-select:focus { border-color: #8bb06c; }
.form-body label, .login-card label, .shell-input-form > label { color: #b7c4d1; }
:is(.button, .icon-button, .text-button, .project-toggle, .project-picker, .entity-link,
.stat-card, .filter-tabs button, .detail-list-row, .log-project-toggle):focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
:is(.button, .icon-button, .project-toggle, .project-picker, .stat-card, .filter-tabs button):active:not(:disabled) {
  transform: translateY(1px); box-shadow: inset 0 2px 4px #00000032;
}
:is(.button, .icon-button, .project-toggle, .project-picker):disabled,
:is(.button, .icon-button, .project-toggle, .project-picker):disabled:hover {
  color: #8a97a6; border-color: #2f3944; box-shadow: none; transform: none; opacity: .62;
}
.button.primary:disabled { background: #19222b; border-color: #2f3944; color: #9ba7b5; }
input:disabled, textarea:disabled, select:disabled { color: #8b99a9; opacity: .72; }
.button[aria-busy=true]:not(:disabled) { border-color: #718765; }
#modal { border-color: #465349; box-shadow: 0 24px 64px #00000070, inset 0 1px 0 #ffffff0c; }
#modal::backdrop { background: #070b12b8; }
.modal-heading, .modal-footer, .panel-heading, .shell-header, .terminal-header { border-color: #303c48; }
.modal-heading p, .modal-host-scope, .detail-description, .detail-notes { color: #96a7b7; }
.table-panel thead { background: #111a22; color: #a0b1bf; }
.table-panel th { color: #a0b1bf; border-color: #303c48; }
.table-panel td { border-color: #26333e; }

/* Empty, pending and error states remain readable without extra animation. */
.empty-state, .connection-empty, .terminal-empty, .shell-no-sessions, .connecting { color: #98a9ba; }
:is(.empty-state, .connection-empty, .terminal-empty, .connecting) :is(h2, h3) { color: #d7e0e9; }
.form-error, .resource-error { color: #eeaaa1; }
:is(input, textarea, select)[aria-invalid=true] { border-color: var(--red); }
.loading-ring { border-color: #34414c; border-top-color: var(--accent); }
.step-result.success { color: #b2d896; }
.step-result.failed { color: #e4a39a; }
.ai-provider-list > .button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

/* Login uses the same surface, hierarchy and focus treatment. */
.login-card {
  border-color: #40523d;
  background: radial-gradient(ellipse at 100% 0, #a6ed780d, transparent 62%), linear-gradient(150deg, #17211e, #111821 65%);
}
.login-card h1 { color: #e3ebe1; }
.login-card > p { color: #9aabbc; }
.login-foot { color: #93a89e; }
.login-card input { background: #0d161c; }
.login-card .trusted-remember { color: #a4b6a0; }
.trusted-login-actions { border-color: #34404a; }

/* Keep the topology's existing cyan identity and independent state colors. */
#topology-workspace :is(.topology-metric, .topology-map, .topology-rack, .topology-detail) { box-shadow: var(--surface-depth); }
#topology-workspace .topology-project { box-shadow: inset 0 1px 0 #ffffff07; }
#topology-workspace .topology-project.is-selected { border-color: var(--topology-cyan); box-shadow: inset 3px 0 0 var(--topology-cyan), inset 0 1px 0 #b9e9e90c; }
#topology-workspace .topology-filters > button.is-active { box-shadow: inset 0 -2px 0 var(--topology-cyan); }
#topology-workspace .topology-metric > small, #topology-workspace .topology-sync { color: #91a8b6; }
#topology-workspace .topology-search:focus-within { border-color: var(--topology-cyan); box-shadow: 0 0 0 2px #6ccbd418; }
#topology-workspace :is(button, a, input):focus-visible { outline-color: var(--topology-cyan); }
#topology-workspace .topology-project:focus-visible { outline: 2px solid var(--topology-cyan); outline-offset: -3px; }

@media (hover: hover) and (pointer: fine) {
  .project-group:hover, .container-card:hover, .host-card:hover { border-color: #58705d; box-shadow: 0 10px 28px #00000030, inset 0 1px 0 #ffffff0b; }
  .project-group:has(.project-select > input:checked):hover, .host-card.selected:hover { border-color: #a1c982; box-shadow: inset 3px 0 0 var(--accent), 0 10px 28px #00000030; }
  .stat-card:hover { border-color: #758b62; box-shadow: 0 8px 24px #00000030, inset 0 1px 0 #ffffff0c; transform: none; }
  .service-row:hover, .table-panel tbody tr:hover { background: #a6ed7805; }
  .button.primary:hover:not(:disabled) { box-shadow: 0 4px 19px #a6ed782a, inset 0 1px 0 #e5ffd64d; }
  .filter-tabs button:not(.active):hover { background: #1a222a; color: #c7d0db; }
  #topology-workspace .topology-project:hover { border-color: #78afb6; }
  #topology-workspace .topology-project.is-selected:hover { border-color: var(--topology-cyan); }
}
@media (pointer: coarse) {
  .topology-filters > button, .process-table .process-manage, #main .service-actions .button,
  .heading-actions .button, .container-card-actions .button.small, .project-actions .project-toggle { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .loading-ring, #modal, #modal::backdrop { animation: none !important; transition: none !important; }
  :is(.button, .icon-button, .project-toggle, .project-picker, .stat-card, .filter-tabs button):active:not(:disabled) { transform: none !important; }
}
html[data-motion=off] :is(.button, .icon-button, .project-toggle, .project-picker, .stat-card, .filter-tabs button):active:not(:disabled) { transform: none !important; }
@media (forced-colors: active) {
  .project-group:has(.project-select > input:checked), .project-group:has(.project-select > input:checked):hover,
  .host-card.selected, .host-card.selected:hover, .nav-item.active,
  .filter-tabs button.active, .log-app.selected, .log-project.selected, .shell-session.selected,
  .ai-directory-item.is-selected { border-color: Highlight; box-shadow: none; }
  #topology-workspace .topology-project.is-selected, #topology-workspace .topology-project.is-selected:hover { border-color: Highlight; box-shadow: none; }
  #main #topology-workspace :is(button, a, input):focus-visible, #topology-workspace .topology-project:focus-visible { outline-color: Highlight; }
}
