#appRoot {
  --bg: #ecf2ff;
  --bg2: #f8fbff;
  --surface: rgba(255, 255, 255, 0.72);
  --card: #ffffff;
  --text: #122038;
  --muted: #526179;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --border: rgba(148, 163, 184, 0.3);
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  --radius: 16px;
}
#appRoot[data-theme="dark"] {
  --bg: #070c1d;
  --bg2: #0f172a;
  --surface: rgba(15, 23, 42, 0.72);
  --card: #111c34;
  --text: #e8efff;
  --muted: #aab8d6;
  --accent: #60a5fa;
  --accent-2: #22d3ee;
  --success: #4ade80;
  --danger: #fb7185;
  --warning: #facc15;
  --border: rgba(148, 163, 184, 0.28);
  --shadow: 0 14px 32px rgba(2, 6, 23, 0.45);
}
#appRoot,
#appRoot * {
  box-sizing: border-box;
}

#appRoot {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(155deg, var(--bg), var(--bg2));
  transition: background .35s ease, color .35s ease;
}

#appRoot.app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 16px;
}

#appRoot .glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
}

#appRoot .topbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#appRoot .topbar h1 {
  margin: 0;
  font-size: clamp(1.15rem, 1.6vw, 1.7rem);
}

#appRoot .topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

#appRoot .topbar-actions {
  display: flex;
  gap: 8px;
}

#appRoot .layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  align-items: start;
}

#appRoot .controls {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 30px);
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}

#appRoot .section {
  background: color-mix(in srgb, var(--card) 76%, transparent);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px;
}

#appRoot .section h2 {
  margin: 0 0 10px;
  font-size: .92rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

#appRoot .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#appRoot label {
  display: grid;
  gap: 6px;
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 9px;
}

#appRoot input,
#appRoot select,
#appRoot button {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--text);
  padding: 10px 12px;
  font-size: .95rem;
  transition: border-color .2s ease, transform .2s ease, background .2s ease, box-shadow .2s ease;
}

#appRoot input:focus,
#appRoot select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}

#appRoot .inline-actions {
  display: flex;
  gap: 8px;
}

#appRoot .inline-actions.wrap {
  flex-wrap: wrap;
}

#appRoot .btn {
  cursor: pointer;
  font-weight: 600;
}

#appRoot .btn:hover {
  transform: translateY(-1px);
}

#appRoot .btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

#appRoot .btn.ghost {
  background: color-mix(in srgb, var(--card) 88%, transparent);
}

#appRoot .btn.danger {
  color: #fff;
  background: linear-gradient(120deg, var(--danger), #fb7185);
  border-color: transparent;
}

#appRoot .workspace {
  padding: 14px;
  min-height: 740px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

#appRoot .workspace-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

#appRoot #statusText {
  color: var(--muted);
}

#appRoot .warnings {
  text-align: right;
  max-width: 70%;
  font-size: .86rem;
}

#appRoot .warning-item {
  color: var(--warning);
  margin-top: 4px;
}

#appRoot .warning-item.error {
  color: var(--danger);
}

#appRoot .canvas-host {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 24%, transparent), transparent 50%), color-mix(in srgb, var(--card) 88%, transparent);
  min-height: 560px;
  touch-action: none;
}

#appRoot #packSvg {
  width: 100%;
  height: 100%;
  display: block;
}

#appRoot .legend {
  color: var(--muted);
  font-size: .84rem;
}

#appRoot .stats-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

#appRoot .stat-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 84%, transparent);
  padding: 10px;
}

#appRoot .stat-card .k {
  color: var(--muted);
  font-size: .74rem;
}

#appRoot .stat-card .v {
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 700;
}

#appRoot .cell-shape {
  transition: transform .18s ease, filter .18s ease, opacity .2s ease;
}

#appRoot .cell:hover .cell-shape {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

#appRoot .cell-text {
  font-size: 10px;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
  fill: var(--text);
}

#appRoot .tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  min-width: 160px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -114%);
  transition: opacity .15s ease;
  font-size: .8rem;
}

#appRoot .tooltip.show {
  opacity: 1;
}

#appRoot .micro-help {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .78rem;
}

#appRoot .hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  #appRoot .layout {
    grid-template-columns: 1fr;
  }
  #appRoot .controls {
    position: static;
    max-height: none;
  }
  #appRoot .workspace {
    min-height: 620px;
  }
}

@media (max-width: 700px) {
  #appRoot.app {
    padding: 10px;
  }
  #appRoot .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  #appRoot .topbar-actions {
    width: 100%;
  }
  #appRoot .topbar-actions .btn {
    flex: 1;
  }
  #appRoot .grid-2 {
    grid-template-columns: 1fr;
  }
  #appRoot .canvas-host {
    min-height: 440px;
  }
}



