:root {
  --bg: #0f1526;
  --bg2: #161d33;
  --accent: #2dd4bf;
  --accent2: #2563eb;
  --text: #e6ebf5;
  --muted: #93a0bb;
  --border: #2a3350;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
}

body { display: flex; flex-direction: column; height: 100vh; }

/* ------------------------------------------------------------ brand bar */
#brandbar {
  background: linear-gradient(90deg, #0c1120, #141b34 45%, #101a30 100%);
  background-size: 200% 100%;
  animation: brandSheen 10s ease-in-out infinite;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  overflow: hidden;
}
@keyframes brandSheen {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
#brandbar-inner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeInDown 0.5s ease both;
}
#brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04211d;
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 2px 10px rgba(45,212,191,0.35);
}
#brand-name {
  font-size: 15.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--text);
}
#brand-name strong {
  color: var(--accent);
  font-weight: 800;
}
#brand-tagline {
  color: var(--muted);
  font-size: 12px;
  flex: 1;
}
#brand-badge {
  font-size: 10.5px;
  color: #04211d;
  background: linear-gradient(135deg, var(--accent), #7bf0e0);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  animation: fadeInDown 0.5s ease both;
  animation-delay: 0.05s;
}

.tb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 3px 0;
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tb-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 2px 2px;
}

.tb-label { color: var(--muted); margin-right: 2px; }
.tb-group label { display: flex; align-items: center; gap: 4px; color: var(--muted); }

button, select, input[type="range"] {
  font-family: inherit;
  font-size: 12.5px;
}

button {
  background: #1e274a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              transform 0.1s ease, box-shadow 0.15s ease;
}

button:hover { background: #283058; border-color: #394480; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.active {
  background: var(--accent);
  color: #04211d;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,212,191,0.18);
  animation: activePulse 2.2s ease-in-out infinite;
}
@keyframes activePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(45,212,191,0.18); }
  50% { box-shadow: 0 0 0 5px rgba(45,212,191,0.30); }
}

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

select {
  background: #1e274a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  transition: border-color 0.15s ease;
}

#palette { display: flex; flex-wrap: wrap; gap: 4px; max-width: 216px; }
#palette-generated { display: flex; flex-wrap: wrap; gap: 4px; max-width: 168px; margin-left: 6px; }
#palette .swatch, #palette-generated .swatch {
  width: 20px; height: 20px; border-radius: 4px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
#palette .swatch:hover, #palette-generated .swatch:hover { transform: scale(1.15); }
#palette .swatch.active { border-color: var(--accent); transform: scale(1.1); }
#palette-generated:empty { display: none; }
#harmony-group { flex-wrap: wrap; max-width: 320px; }

input[type="color"] {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--border);
  border-radius: 5px; background: none; cursor: pointer;
}

#workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.1s;
}

#canvas-wrap {
  flex: 1;
  overflow: auto;
  background: #0b0f1c;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(45,212,191,0.05), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(37,99,235,0.06), transparent 45%);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 20px;
}

#canvas {
  background: #f7f6f1;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--border), 0 12px 30px rgba(0,0,0,0.35);
  cursor: crosshair;
  touch-action: none;
  transition: box-shadow 0.2s ease;
  will-change: transform; /* smoother zoom scaling (GPU-composited) */
}

#side-panel {
  width: 360px;
  border-left: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.panel-title { color: var(--muted); font-weight: 600; }

#preview-wrap {
  background: #f7f6f1;
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
#preview-canvas { width: 100%; height: 100%; }

#tikz-output {
  flex: 1;
  min-height: 160px;
  resize: none;
  background: #0b0f1c;
  color: #b7f5d8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.panel-buttons { display: flex; gap: 8px; }
.panel-buttons button { flex: 1; }
.panel-buttons button:hover { background: linear-gradient(135deg, #283058, #32407a); }

#statusbar {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}
#status-text { transition: color 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  #brandbar, #brandbar-inner, #toolbar, #workspace, button.active {
    animation: none !important;
  }
}
