:root {
  --navy: #004a99;
  --navy-dark: #003a7a;
  --navy-mid: #1a5cb3;
  --blue: #1d5bb8;
  --page: #eef2f6;
  --card: #ffffff;
  --line: #d7dee8;
  --text: #1c2430;
  --muted: #6b7787;
  --ok: #146c42;
  --warn: #8a4b12;
  --danger: #8b1e1e;
  --deep: #071833;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--page);
  font-size: 15px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.logo-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  flex-shrink: 0;
}
.logo-mark .logo-svg { width: 100%; height: 100%; display: block; }
.logo-mark.light { color: #fff; }

/* —— Login (home-style deep blue) —— */
.sofia-login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  color: #eef4ff;
  background:
    radial-gradient(ellipse 70% 50% at 12% -10%, rgba(73, 140, 230, 0.35), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 10%, rgba(20, 70, 150, 0.55), transparent 50%),
    linear-gradient(165deg, #071833 0%, #0d3b7a 48%, #08244f 100%);
  position: relative;
  overflow: hidden;
}
.sofia-glow {
  pointer-events: none;
  position: absolute;
  inset: auto -6rem 10% auto;
  width: min(28rem, 65vw);
  height: min(28rem, 65vw);
  border-radius: 50%;
  border: 16px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.04);
}
.sofia-login-card {
  width: min(420px, 100%);
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  border-radius: 12px;
  padding: 1.6rem 1.4rem 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 20, 60, 0.35);
}
.sofia-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.1rem;
}
.sofia-brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.sofia-brand span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}
.sofia-login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.sofia-lead {
  color: var(--muted);
  margin: 0 0 1.1rem;
  line-height: 1.45;
  font-size: 0.95rem;
}
.sofia-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  color: var(--text);
}
.sofia-form input,
.sofia-upload select,
.sofia-layer-card textarea,
.sofia-common textarea,
.sofia-inline-form input {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.sofia-form input:focus,
.sofia-upload select:focus,
.sofia-layer-card textarea:focus,
.sofia-common textarea:focus {
  outline: 2px solid rgba(29, 91, 184, 0.25);
  border-color: var(--blue);
}

.sofia-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
}
.sofia-btn-primary {
  background: var(--blue);
  color: #fff;
  width: 100%;
  margin-top: 0.35rem;
}
.sofia-btn-primary:hover { background: var(--navy-mid); }
.sofia-btn-outline {
  border-color: var(--blue);
  color: var(--blue);
  background: #fff;
}
.sofia-btn-outline:hover { background: #f3f7fc; }
.sofia-btn-ghost {
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  background: transparent;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
}
.sofia-btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.sofia-error { color: var(--danger); font-weight: 600; margin: 0 0 0.75rem; }

/* —— App shell —— */
.sofia-app { min-height: 100vh; background: var(--page); }
.sofia-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.6rem;
  padding: 0.55rem 1.2rem;
  background: rgba(7, 24, 51, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}
.sofia-logo-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}
.sofia-logo-btn:hover { color: #fff; text-decoration: none; opacity: 0.9; }
.sofia-logo-btn .logo-mark { color: #fff; width: 26px; height: 26px; }
.sofia-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.sofia-logo-text strong {
  font-size: 0.95rem;
  letter-spacing: -0.03em;
}
.sofia-logo-text em {
  font-style: normal;
  font-size: 0.7rem;
  color: #9fbfef;
  font-weight: 600;
}
.sofia-nav-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-left: auto;
}
.sofia-who { color: #b8cce8; font-size: 0.85rem; }
.sofia-nav-link {
  color: #d7e6ff;
  font-size: 0.88rem;
  font-weight: 600;
}
.sofia-nav-link:hover { color: #fff; text-decoration: none; }

.sofia-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1.4rem 1.1rem 3rem;
}
.sofia-hero-band {
  margin-bottom: 1.15rem;
}
.sofia-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--navy);
  font-weight: 700;
  margin: 0 0 0.35rem;
}
.sofia-hero-band h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.55rem, 3vw, 1.95rem);
  color: var(--navy);
  letter-spacing: -0.03em;
}
.sofia-flashes { margin-bottom: 0.9rem; }
.sofia-flash {
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
}
.sofia-flash-ok { background: #e3f6ec; color: var(--ok); }
.sofia-flash-error { background: #f8e4e4; color: var(--danger); }

.sofia-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.15rem 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(16, 40, 80, 0.04);
}
.sofia-card-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  color: var(--navy);
}
.sofia-card-head p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.sofia-hint { color: var(--muted); font-size: 0.85rem; margin: 0.75rem 0 0; }
.sofia-empty { color: var(--muted); margin: 0; }

/* Shared common prompt */
.sofia-common {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 0.9rem;
  overflow: hidden;
}
.sofia-common summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.75rem 0.9rem;
}
.sofia-common summary::-webkit-details-marker { display: none; }
.sofia-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #e8eef8;
  color: var(--navy);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sofia-common summary strong { color: var(--text); }
.sofia-common summary small { color: var(--muted); }
.sofia-common textarea {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 120px;
}

/* —— Horizontal pipeline with cycle arrows —— */
.sofia-pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  overflow-x: auto;
  padding: 0.15rem 0 0.4rem;
  scrollbar-width: thin;
}
.sofia-pipeline .sofia-layer-card {
  flex: 1 1 0;
  min-width: 11.5rem;
}
.sofia-cycle-btn {
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  margin-top: 2.4rem;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--blue);
  cursor: default;
  display: grid;
  place-items: center;
}
.sofia-cycle-btn svg {
  width: 2.35rem;
  height: 2.35rem;
  animation: sofia-spin-slow 12s linear infinite;
}
.sofia-cycle-btn:hover svg {
  animation-duration: 4s;
  color: var(--navy);
}
@keyframes sofia-spin-slow {
  to { transform: rotate(360deg); }
}
.sofia-layers-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}
.sofia-layer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sofia-layer-card[open] {
  border-color: #a8c2e8;
  box-shadow: 0 4px 16px rgba(0, 74, 153, 0.08);
}
.sofia-layer-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.85rem 0.8rem 0.9rem;
  min-height: 7.2rem;
  background: linear-gradient(180deg, #f6f9fc 0%, #fff 70%);
}
.sofia-layer-card summary::-webkit-details-marker { display: none; }
.sofia-layer-num {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}
.sofia-layer-card summary strong {
  font-size: 0.92rem;
  color: var(--navy);
  line-height: 1.25;
}
.sofia-layer-card summary small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}
.sofia-layer-card textarea {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.4;
  resize: vertical;
}
.sofia-save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
}

.sofia-upload-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.sofia-file span,
.sofia-upload label > span {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}
.sofia-test { width: auto; min-width: 12rem; }

.sofia-runs { display: grid; gap: 0.75rem; }
.sofia-run {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  background: #fafbfd;
}
.sofia-run header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.sofia-meta { color: var(--muted); font-size: 0.82rem; margin: 0.25rem 0 0.6rem; }
.sofia-status {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e8eef8;
  color: var(--navy);
}
.sofia-status-running, .sofia-status-queued { background: #fff3d6; color: var(--warn); }
.sofia-status-done { background: #e3f6ec; color: var(--ok); }
.sofia-status-failed { background: #f8e4e4; color: var(--danger); }

.sofia-layer-status {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}
.sofia-layer-status li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  min-width: 0;
}
.sofia-layer-status span {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.72rem;
}
.sofia-layer-status em { font-style: normal; font-weight: 700; color: var(--blue); }
.sofia-layer-status small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sofia-artifacts {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.sofia-artifacts a {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  background: #fff;
}
.sofia-artifacts a:hover {
  border-color: var(--blue);
  text-decoration: none;
  background: #f3f7fc;
}

.sofia-table { width: 100%; border-collapse: collapse; }
.sofia-table th, .sofia-table td {
  text-align: left;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 0.92rem;
}
.sofia-inline-form { display: flex; gap: 0.4rem; align-items: center; }
.sofia-inline-form input { width: auto; min-width: 10rem; margin: 0; }
.sofia-simple-list { margin: 0; padding-left: 1.1rem; }
.sofia-simple-list li { margin-bottom: 0.35rem; }

/* —— Neural file graph —— */
.sofia-net {
  position: relative;
  min-height: 34rem;
  margin: 0.4rem 0 1rem;
  padding: 0.5rem 0.35rem 0.75rem;
}
.sofia-net-input {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-bottom: 2.2rem;
}
.sofia-net-output {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-top: 2.2rem;
}
.sofia-input-node,
.sofia-output-node {
  width: min(720px, 100%);
  border-radius: 12px;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid rgba(140, 190, 255, 0.35);
  box-shadow: 0 0 28px rgba(60, 150, 255, 0.18);
}
.sofia-output-node {
  border-color: rgba(180, 140, 255, 0.4);
  box-shadow: 0 0 28px rgba(140, 100, 255, 0.2);
}
.sofia-input-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.65rem;
  margin-bottom: 0.75rem;
}
.sofia-input-head strong {
  color: #eaf2ff;
  font-size: 0.95rem;
}
.sofia-input-head small { color: #9eb6d6; font-size: 0.78rem; }
.sofia-upload-compact { margin-bottom: 0.75rem; }
.sofia-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  min-height: 7.5rem;
  margin-bottom: 0.85rem;
  padding: 1.1rem 1rem;
  border-radius: 14px;
  border: 1.5px dashed rgba(120, 180, 255, 0.45);
  background:
    linear-gradient(160deg, rgba(20, 50, 100, 0.35), rgba(8, 18, 40, 0.55)),
    rgba(6, 16, 36, 0.5);
  color: #cfe0ff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.sofia-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.sofia-dropzone-icon {
  width: 2.4rem;
  height: 2.4rem;
  color: #8ec5ff;
}
.sofia-dropzone-icon svg { width: 100%; height: 100%; }
.sofia-dropzone-title {
  font-size: 0.95rem;
  font-weight: 650;
  color: #eef5ff;
}
.sofia-dropzone-name {
  font-style: normal;
  font-size: 0.78rem;
  color: #9eb6d6;
}
.sofia-dropzone:hover,
.sofia-dropzone.is-drag {
  border-color: rgba(140, 210, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(100, 180, 255, 0.25), 0 12px 36px rgba(40, 120, 255, 0.2);
}
.sofia-dropzone.has-file {
  border-style: solid;
  border-color: rgba(100, 220, 180, 0.55);
}
.sofia-dropzone.has-file .sofia-dropzone-name { color: #9ee7c8; }
.sofia-input-node .sofia-test { width: auto; min-width: 11rem; }
.sofia-synapse-input {
  stroke: rgba(80, 220, 200, 0.65);
  stroke-width: 1.8;
  stroke-dasharray: 4 6;
  animation: sofia-pulse-line 2.2s linear infinite;
  filter: drop-shadow(0 0 5px rgba(60, 220, 200, 0.55));
}
.sofia-synapse-output {
  stroke: rgba(190, 140, 255, 0.7);
  stroke-width: 1.7;
  stroke-dasharray: 5 7;
  animation: sofia-pulse-line 2.6s linear infinite;
  filter: drop-shadow(0 0 5px rgba(160, 110, 255, 0.55));
}
.sofia-synapses {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.sofia-synapse {
  fill: none;
  stroke: rgba(110, 180, 255, 0.55);
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(80, 160, 255, 0.55));
}
.sofia-synapse-hub {
  stroke-dasharray: 5 7;
  animation: sofia-pulse-line 2.8s linear infinite;
}
.sofia-synapse-side {
  stroke: rgba(160, 130, 255, 0.55);
  stroke-width: 1.4;
  animation: sofia-pulse-line 3.4s linear infinite reverse;
}
.sofia-synapse-node {
  fill: #8ec5ff;
  filter: drop-shadow(0 0 6px rgba(120, 190, 255, 0.9));
}
@keyframes sofia-pulse-line {
  to { stroke-dashoffset: -48; }
}
.sofia-net-hub {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-bottom: 2.4rem;
}
.sofia-net-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}
.sofia-net-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 920px;
  margin-inline: auto;
}
.sofia-layer-status-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
.sofia-agent-cell {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
.sofia-model-pick {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.68rem;
  color: #9eb6d6;
}
.sofia-model-pick em {
  font-style: normal;
  opacity: 0.7;
}
.sofia-model-pick select {
  width: 100%;
  font-size: 0.72rem;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(140, 190, 255, 0.35);
  background: rgba(6, 18, 40, 0.85);
  color: #e8f0ff;
}
.sofia-model-hint {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: #8aa0c0;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  justify-content: center;
  align-items: center;
}
.sofia-model-hint a {
  color: #7eb6ff;
}
.sofia-model-default-btn {
  appearance: none;
  border: 1px solid rgba(140, 190, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}
.sofia-model-default-btn:hover {
  background: rgba(80, 150, 255, 0.18);
}
.sofia-model-refresh {
  font-size: 0.78rem;
  font-weight: 600;
}
.sofia-theme-light .sofia-model-default-btn {
  color: #0b4ea2 !important;
  border-color: rgba(11, 78, 162, 0.35) !important;
  background: #fff !important;
}
.sofia-theme-light .sofia-model-refresh {
  color: #0b4ea2 !important;
}

/* Prompt popup */
.sofia-modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(920px, calc(100vw - 1.5rem));
  width: 100%;
  margin: auto;
}
.sofia-modal::backdrop {
  background: rgba(6, 14, 32, 0.62);
  backdrop-filter: blur(4px);
}
.sofia-modal-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(140, 190, 255, 0.28);
  background: rgba(8, 22, 48, 0.96);
  box-shadow: 0 24px 64px rgba(0, 10, 40, 0.45);
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 760px);
}
.sofia-modal-head {
  position: relative;
  padding-right: 2.8rem;
}
.sofia-modal-close {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  opacity: 0.8;
}
.sofia-modal-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.sofia-modal .sofia-editor-pane {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: 55vh;
}
.sofia-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid rgba(140, 190, 255, 0.16);
}
.sofia-theme-light .sofia-modal-card {
  background: #fff !important;
  border-color: rgba(40, 100, 180, 0.28) !important;
  color: #1a2433;
}
.sofia-theme-light .sofia-modal::backdrop {
  background: rgba(20, 40, 70, 0.45);
}
.sofia-theme-light .sofia-modal-close { color: #1a2433; }
.sofia-theme-light .sofia-modal-actions {
  border-top-color: rgba(40, 100, 180, 0.16);
}

.sofia-models-meta {
  font-size: 0.72rem !important;
  word-break: break-word;
}
.sofia-file-node {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
  padding: 0.85rem 0.55rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(140, 190, 255, 0.28);
  background: rgba(8, 22, 48, 0.55);
  color: #dce8ff;
  cursor: pointer;
  font: inherit;
  backdrop-filter: blur(10px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  min-width: 0;
}
.sofia-file-node:hover {
  border-color: rgba(150, 200, 255, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(20, 80, 180, 0.25);
}
.sofia-file-node.is-active {
  border-color: rgba(120, 200, 255, 0.85);
  box-shadow:
    0 0 0 1px rgba(120, 190, 255, 0.35),
    0 0 28px rgba(60, 150, 255, 0.35);
  background: rgba(20, 50, 110, 0.55);
}
.sofia-file-node.is-hub {
  min-width: 9.5rem;
  padding: 0.95rem 1.1rem;
}
.sofia-file-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #7eb6ff;
  text-transform: uppercase;
}
.sofia-file-icon {
  width: 2.6rem;
  height: 3.1rem;
  color: #9fc8ff;
  display: grid;
  place-items: center;
}
.sofia-file-icon svg { width: 100%; height: 100%; }
.sofia-file-node.is-active .sofia-file-icon { color: #dff0ff; }
.sofia-file-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: #eef5ff;
  word-break: break-all;
}
.sofia-file-role {
  font-size: 0.72rem;
  color: #9eb6d6;
  line-height: 1.3;
}
.sofia-file-editor {
  border: 1px solid rgba(140, 190, 255, 0.22);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.sofia-file-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.7rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(140, 190, 255, 0.16);
  background: rgba(10, 30, 70, 0.35);
}
.sofia-file-editor-head strong {
  color: #eaf2ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}
.sofia-file-editor-head small { color: #9eb6d6; }
.sofia-editor-pane {
  display: none;
  width: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  min-height: 240px;
  padding: 0.85rem 0.95rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
  background: rgba(4, 14, 32, 0.72);
  color: #e8f0ff;
}
.sofia-editor-pane.is-active { display: block; }

@media (max-width: 980px) {
  .sofia-layers-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sofia-layer-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sofia-pipeline {
    flex-wrap: wrap;
    justify-content: center;
  }
  .sofia-pipeline .sofia-layer-card {
    flex: 1 1 calc(50% - 2rem);
    min-width: 12rem;
  }
  .sofia-cycle-btn { margin-top: 1.2rem; }
  .sofia-net-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sofia-net-row-3 { grid-template-columns: 1fr; max-width: none; }
  .sofia-net { min-height: 40rem; }
  .sofia-net-hub { margin-bottom: 2rem; }
  .sofia-net-input { margin-bottom: 2rem; }
  .sofia-net-output { margin-top: 2rem; }
}
@media (max-width: 640px) {
  .sofia-nav { flex-wrap: wrap; }
  .sofia-nav-right { width: 100%; justify-content: flex-end; }
  .sofia-layers-row { grid-template-columns: 1fr; }
  .sofia-upload-grid { grid-template-columns: 1fr; }
  .sofia-layer-status { grid-template-columns: 1fr 1fr; }
  .sofia-who { display: none; }
  .sofia-pipeline .sofia-layer-card { flex: 1 1 100%; }
  .sofia-cycle-btn {
    width: 100%;
    height: 2rem;
    margin: 0.15rem 0;
    transform: rotate(90deg);
  }
  .sofia-net-row { grid-template-columns: 1fr 1fr; gap: 0.55rem; }
  .sofia-net-hub { margin-bottom: 1.6rem; }
}

/* —— Futuristic trainer shell —— */
.sofia-futuristic {
  color: #e8f0ff;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(56, 160, 255, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 45% at 95% 15%, rgba(120, 80, 255, 0.22), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(0, 180, 200, 0.14), transparent 55%),
    linear-gradient(165deg, #050d1c 0%, #0a1f45 42%, #071833 100%);
  position: relative;
  isolation: isolate;
}
.sofia-fx {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.sofia-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 180, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 180, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
  opacity: 0.55;
}
.sofia-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: sofia-drift 18s ease-in-out infinite alternate;
}
.sofia-orb-a {
  width: 28rem;
  height: 28rem;
  left: -8rem;
  top: 10%;
  background: rgba(40, 130, 255, 0.35);
}
.sofia-orb-b {
  width: 22rem;
  height: 22rem;
  right: -4rem;
  top: 35%;
  background: rgba(130, 90, 255, 0.28);
  animation-delay: -6s;
}
.sofia-orb-c {
  width: 18rem;
  height: 18rem;
  left: 35%;
  bottom: -4rem;
  background: rgba(0, 200, 220, 0.2);
  animation-delay: -11s;
}
@keyframes sofia-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2rem, -1.5rem, 0) scale(1.08); }
}
.sofia-futuristic .sofia-nav,
.sofia-futuristic .sofia-main {
  position: relative;
  z-index: 1;
}
.sofia-futuristic .sofia-nav {
  background: rgba(5, 14, 32, 0.55);
  border-bottom-color: rgba(140, 190, 255, 0.18);
  backdrop-filter: blur(16px);
}
.sofia-futuristic .sofia-eyebrow { color: #7eb6ff; }
.sofia-futuristic .sofia-hero-band h1 { color: #f2f7ff; }
.sofia-futuristic .sofia-lead,
.sofia-futuristic .sofia-card-head p,
.sofia-futuristic .sofia-empty,
.sofia-futuristic .sofia-meta,
.sofia-futuristic .sofia-hint {
  color: #a8bddc;
}
.sofia-futuristic .sofia-card-head h2 { color: #eaf2ff; }
.sofia-glass {
  background: rgba(12, 28, 58, 0.38);
  border: 1px solid rgba(140, 190, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 18px 50px rgba(0, 10, 40, 0.28);
  backdrop-filter: blur(18px);
}
.sofia-glass-inner {
  background: rgba(8, 22, 48, 0.45) !important;
  border-color: rgba(140, 190, 255, 0.2) !important;
}
.sofia-futuristic .sofia-common summary strong,
.sofia-futuristic .sofia-layer-card summary strong {
  color: #eaf2ff;
}
.sofia-futuristic .sofia-common summary small,
.sofia-futuristic .sofia-layer-card summary small {
  color: #9eb6d6;
}
.sofia-futuristic .sofia-layer-card summary {
  background: linear-gradient(180deg, rgba(40, 90, 170, 0.22) 0%, rgba(8, 22, 48, 0.15) 100%);
}
.sofia-futuristic .sofia-layer-card[open] {
  border-color: rgba(120, 190, 255, 0.55) !important;
  box-shadow: 0 0 24px rgba(60, 140, 255, 0.18);
}
.sofia-futuristic .sofia-layer-num {
  background: linear-gradient(145deg, #3d8dff, #1a4fbf);
  box-shadow: 0 0 12px rgba(80, 160, 255, 0.45);
}
.sofia-futuristic .sofia-pill {
  background: rgba(80, 150, 255, 0.2);
  color: #b6d4ff;
}
.sofia-futuristic .sofia-common textarea,
.sofia-futuristic .sofia-layer-card textarea,
.sofia-futuristic .sofia-form input,
.sofia-futuristic .sofia-upload select,
.sofia-futuristic input[type="file"] {
  background: rgba(4, 14, 32, 0.55);
  color: #e8f0ff;
  border-color: rgba(140, 190, 255, 0.22);
}
.sofia-futuristic .sofia-cycle-btn {
  color: #7eb6ff;
  filter: drop-shadow(0 0 8px rgba(80, 160, 255, 0.45));
}
.sofia-futuristic .sofia-btn-outline {
  border-color: rgba(140, 190, 255, 0.45);
  color: #d7e6ff;
  background: rgba(255, 255, 255, 0.04);
}
.sofia-futuristic .sofia-btn-outline:hover {
  background: rgba(80, 150, 255, 0.15);
}
.sofia-futuristic .sofia-btn-primary {
  box-shadow: 0 0 20px rgba(40, 120, 255, 0.35);
}
.sofia-futuristic .sofia-run {
  background: rgba(8, 22, 48, 0.4);
}
.sofia-futuristic .sofia-layer-status li {
  background: rgba(4, 14, 32, 0.45);
  border-color: rgba(140, 190, 255, 0.18);
}
.sofia-futuristic .sofia-layer-status span { color: #9fbfef; }
.sofia-futuristic .sofia-layer-status em { color: #7eb6ff; }
.sofia-futuristic .sofia-layer-status small { color: #8aa0c0; }
.sofia-futuristic .sofia-artifacts a {
  background: rgba(8, 22, 48, 0.55);
  border-color: rgba(140, 190, 255, 0.28);
  color: #d7e6ff;
}
.sofia-futuristic .sofia-flash-ok {
  background: rgba(30, 120, 80, 0.35);
  color: #b8f0d0;
  border: 1px solid rgba(100, 220, 160, 0.25);
}
.sofia-futuristic .sofia-flash-error {
  background: rgba(120, 30, 40, 0.4);
  color: #ffc4c4;
  border: 1px solid rgba(255, 120, 120, 0.25);
}
.sofia-futuristic .sofia-file span,
.sofia-futuristic .sofia-upload label > span {
  color: #d7e6ff;
}

/* —— Prefs (theme + language) —— */
.sofia-prefs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.sofia-pref-form { margin: 0; }
.sofia-pref-btn {
  appearance: none;
  border: 1px solid rgba(140, 190, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.sofia-pref-btn:hover {
  background: rgba(120, 170, 255, 0.18);
  text-decoration: none;
}
.sofia-login-prefs {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 3;
}
.sofia-login-prefs .sofia-pref-btn {
  color: #eef4ff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(0, 20, 60, 0.35);
  backdrop-filter: blur(8px);
}

/* —— Light mode (beats dark futuristic + !important glass) —— */
.sofia-app.sofia-theme-light,
.sofia-theme-light.sofia-futuristic {
  color: #1a2433;
  background:
    radial-gradient(ellipse 70% 45% at 8% -5%, rgba(70, 140, 230, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 0%, rgba(100, 160, 255, 0.1), transparent 50%),
    linear-gradient(180deg, #f4f7fb 0%, #e8eef6 100%);
}
.sofia-theme-light .sofia-fx { opacity: 0.28; }
.sofia-theme-light .sofia-grid {
  background-image:
    linear-gradient(rgba(30, 80, 160, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 80, 160, 0.06) 1px, transparent 1px);
  opacity: 0.65;
}
.sofia-theme-light .sofia-orb { opacity: 0.28; filter: blur(2px); }
.sofia-theme-light .sofia-nav {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(20, 60, 120, 0.12);
  color: #1a2433;
  backdrop-filter: blur(12px);
}
.sofia-theme-light .sofia-logo-text strong { color: #003a7a; }
.sofia-theme-light .sofia-logo-text em,
.sofia-theme-light .sofia-who,
.sofia-theme-light .sofia-nav-link { color: #3d4f66; }
.sofia-theme-light .sofia-btn-ghost {
  color: #1a2433;
  border-color: rgba(20, 60, 120, 0.22);
}
.sofia-theme-light .sofia-btn-ghost:hover { background: rgba(0, 74, 153, 0.08); }
.sofia-theme-light .sofia-pref-btn {
  color: #1a2433;
  border-color: rgba(20, 60, 120, 0.22);
  background: #fff;
}
.sofia-theme-light .sofia-hero-band h1,
.sofia-theme-light.sofia-futuristic .sofia-hero-band h1 { color: #003a7a !important; }
.sofia-theme-light .sofia-lead,
.sofia-theme-light .sofia-card-head p,
.sofia-theme-light .sofia-hint,
.sofia-theme-light.sofia-futuristic .sofia-lead,
.sofia-theme-light.sofia-futuristic .sofia-card-head p,
.sofia-theme-light.sofia-futuristic .sofia-hint {
  color: #3d4f66 !important;
}
.sofia-theme-light .sofia-model-hint {
  color: #3d4f66 !important;
}
.sofia-theme-light .sofia-model-hint a {
  color: #0b4ea2 !important;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sofia-theme-light .sofia-empty,
.sofia-theme-light .sofia-meta,
.sofia-theme-light.sofia-futuristic .sofia-empty,
.sofia-theme-light.sofia-futuristic .sofia-meta {
  color: #3d4f66 !important;
}
.sofia-theme-light .sofia-glass,
.sofia-theme-light .sofia-card {
  background: #ffffff !important;
  border: 1px solid rgba(20, 60, 120, 0.14) !important;
  box-shadow: 0 12px 40px rgba(20, 50, 100, 0.08);
  color: #1a2433;
  backdrop-filter: none;
}
.sofia-theme-light .sofia-card-head h2,
.sofia-theme-light.sofia-futuristic .sofia-card-head h2 { color: #0d2d5c !important; }
.sofia-theme-light .sofia-glass-inner,
.sofia-theme-light .sofia-input-node,
.sofia-theme-light .sofia-output-node {
  background: #f7f9fc !important;
  border: 1px solid rgba(40, 100, 180, 0.28) !important;
  box-shadow: 0 8px 24px rgba(30, 80, 160, 0.07);
  color: #1a2433 !important;
}
.sofia-theme-light .sofia-input-head strong,
.sofia-theme-light .sofia-file-editor-head strong {
  color: #0d2d5c !important;
}
.sofia-theme-light .sofia-input-head small,
.sofia-theme-light .sofia-file-editor-head small {
  color: #3d4f66 !important;
}
.sofia-theme-light .sofia-file-badge {
  background: rgba(0, 74, 153, 0.12);
  color: #004a99 !important;
}
.sofia-theme-light .sofia-pill,
.sofia-theme-light.sofia-futuristic .sofia-pill {
  background: rgba(0, 74, 153, 0.1);
  color: #004a99 !important;
}
.sofia-theme-light .sofia-dropzone {
  border-color: rgba(0, 74, 153, 0.4);
  background: linear-gradient(160deg, #f7faff, #eef4fb);
  color: #1a2433;
}
.sofia-theme-light .sofia-dropzone-title { color: #0d2d5c; }
.sofia-theme-light .sofia-dropzone-name { color: #3d4f66; }
.sofia-theme-light .sofia-dropzone-icon { color: #1d5bb8; }
.sofia-theme-light .sofia-file-node {
  background: #fff !important;
  border-color: rgba(40, 100, 180, 0.28) !important;
  color: #1a2433 !important;
  box-shadow: 0 6px 18px rgba(30, 80, 160, 0.06);
}
.sofia-theme-light .sofia-file-node.is-active {
  border-color: #1d5bb8 !important;
  box-shadow: 0 0 0 2px rgba(29, 91, 184, 0.22);
}
.sofia-theme-light .sofia-file-name { color: #0d2d5c !important; }
.sofia-theme-light .sofia-file-role,
.sofia-theme-light .sofia-model-pick {
  color: #3d4f66 !important;
}
.sofia-theme-light .sofia-model-pick select {
  background: #fff !important;
  color: #1a2433 !important;
  border-color: rgba(40, 100, 180, 0.35) !important;
}
.sofia-theme-light .sofia-synapse,
.sofia-theme-light .sofia-synapse-hub,
.sofia-theme-light .sofia-synapse-side,
.sofia-theme-light .sofia-synapse-input,
.sofia-theme-light .sofia-synapse-output {
  stroke: rgba(40, 110, 200, 0.5);
  filter: none;
}
.sofia-theme-light .sofia-synapse-node { fill: #1d5bb8; filter: none; }
.sofia-theme-light .sofia-file-editor {
  border-color: rgba(40, 100, 180, 0.24) !important;
  background: #fff !important;
}
.sofia-theme-light .sofia-file-editor-head {
  background: #eef3f9 !important;
  border-bottom-color: rgba(40, 100, 180, 0.16);
}
.sofia-theme-light .sofia-editor-pane,
.sofia-theme-light.sofia-futuristic .sofia-editor-pane {
  background: #fbfcfe !important;
  color: #1a2433 !important;
}
.sofia-theme-light .sofia-run,
.sofia-theme-light.sofia-futuristic .sofia-run {
  background: #fff !important;
  border: 1px solid rgba(40, 100, 180, 0.16);
  color: #1a2433;
}
.sofia-theme-light .sofia-layer-status li,
.sofia-theme-light.sofia-futuristic .sofia-layer-status li {
  background: #eef3f9 !important;
  border-color: rgba(40, 100, 180, 0.18) !important;
  color: #1a2433 !important;
}
.sofia-theme-light .sofia-layer-status span,
.sofia-theme-light.sofia-futuristic .sofia-layer-status span { color: #3d4f66 !important; }
.sofia-theme-light .sofia-layer-status em,
.sofia-theme-light.sofia-futuristic .sofia-layer-status em { color: #0b4ea2 !important; }
.sofia-theme-light .sofia-layer-status small,
.sofia-theme-light.sofia-futuristic .sofia-layer-status small { color: #4a5d78 !important; }
.sofia-theme-light .sofia-artifacts a,
.sofia-theme-light.sofia-futuristic .sofia-artifacts a {
  background: #eef3f9 !important;
  border-color: rgba(40, 100, 180, 0.24) !important;
  color: #0b4ea2 !important;
}
.sofia-theme-light .sofia-btn-outline,
.sofia-theme-light.sofia-futuristic .sofia-btn-outline {
  border-color: rgba(0, 74, 153, 0.4) !important;
  color: #004a99 !important;
  background: #fff !important;
}
.sofia-theme-light .sofia-table th { color: #3d4f66; }
.sofia-theme-light .sofia-table td { color: #1a2433; border-color: rgba(20, 60, 120, 0.12); }
.sofia-theme-light .sofia-simple-list,
.sofia-theme-light .sofia-simple-list li { color: #1a2433; }
.sofia-theme-light.sofia-login-body {
  color: #1a2433;
  background:
    radial-gradient(ellipse 70% 50% at 12% -10%, rgba(73, 140, 230, 0.2), transparent 55%),
    linear-gradient(165deg, #e8eef8 0%, #dce6f4 48%, #eef2f8 100%);
}
.sofia-theme-light.sofia-login-body .sofia-pref-btn {
  color: #1a2433;
  border-color: rgba(20, 60, 120, 0.22);
  background: rgba(255, 255, 255, 0.95);
}

@media (max-width: 720px) {
  .sofia-pref-btn span { display: none; }
}

