/* ── CSS variables ───────────────────────────────────────────────────────── */
:root {
  --pw-accent:       #5b8dee;
  --pw-accent2:      #a78bfa;
  --pw-header-h:     56px;

  /* light palette */
  --pw-bg:           #f0f2f8;
  --pw-surface:      #ffffff;
  --pw-surface2:     #f1f4fb;
  --pw-border:       #d1d9e6;
  --pw-text:         #1e293b;
  --pw-text-muted:   #64748b;
  --pw-card-header:  #e8ecf5;
}

/* ── Global ──────────────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--pw-bg);
  color: var(--pw-text);
  padding-top: var(--pw-header-h);
  transition: background 0.2s, color 0.2s;
}

/* ── Custom header / navbar ──────────────────────────────────────────────── */
.pw-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--pw-header-h);
  background: rgba(15, 17, 23, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #2e3350;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1030;
}

.pw-header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.pw-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #e2e8f0;
  white-space: nowrap;
}
.pw-logo:hover { text-decoration: none; color: #e2e8f0; }

.pw-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--pw-accent), var(--pw-accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.pw-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pw-header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pw-header-nav-link {
  padding: 5px 13px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.pw-header-nav-link:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}
.pw-header-nav-link.active {
  color: var(--pw-accent);
  background: rgba(91, 141, 238, 0.13);
}

.pw-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pw-tagline {
  color: #64748b;
  font-size: 0.78rem;
}

#darkModeBtn {
  background: none;
  border: 1px solid #2e3350;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 1rem;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#darkModeBtn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--pw-accent);
  color: #e2e8f0;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--pw-surface);
  border-color: var(--pw-border);
}

.card-header {
  background: var(--pw-card-header);
  color: var(--pw-text);
  border-bottom-color: var(--pw-border);
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── CodeMirror ──────────────────────────────────────────────────────────── */
.CodeMirror {
  height: 420px;
  font-size: 14px;
  font-family: "Fira Code", "Cascadia Code", "Consolas", monospace;
  border-radius: 0 0 0.375rem 0.375rem;
}

/* ── Output panel ────────────────────────────────────────────────────────── */
.output-panel {
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  font-family: "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 13.5px;
  background: #1a1d27;
  color: #cdd6f4;
  padding: 0.75rem;
  border-radius: 0.25rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-panel.has-error {
  color: #f38ba8;
}

/* ── Flowchart ───────────────────────────────────────────────────────────── */
#flowchartDiagram {
  overflow-x: auto;
  min-height: 120px;
}

#flowchartDiagram svg {
  max-width: 100%;
  height: auto;
}

/* ── Vertical rule ───────────────────────────────────────────────────────── */
.vr {
  opacity: 0.25;
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
body.dark-mode {
  --pw-bg:           #0f1117;
  --pw-surface:      #1a1d27;
  --pw-surface2:     #22263a;
  --pw-border:       #2e3350;
  --pw-text:         #e2e8f0;
  --pw-text-muted:   #94a3b8;
  --pw-card-header:  #22263a;
  background: var(--pw-bg);
  color: var(--pw-text);
}

body.dark-mode .card {
  background: var(--pw-surface);
  border-color: var(--pw-border);
}

body.dark-mode .card-header {
  background: var(--pw-card-header);
  color: var(--pw-text);
  border-bottom-color: var(--pw-border);
}

body.dark-mode .toolbar {
  background: var(--pw-surface);
  border-color: var(--pw-border);
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
}

body.dark-mode .form-control {
  background: var(--pw-surface2);
  color: var(--pw-text);
  border-color: var(--pw-border);
}

body.dark-mode .form-control::placeholder {
  color: var(--pw-text-muted);
}

body.dark-mode .btn-outline-secondary {
  color: #94a3b8;
  border-color: #2e3350;
}
body.dark-mode .btn-outline-secondary:hover {
  background: #2e3350;
  color: #e2e8f0;
}

body.dark-mode .dropdown-menu {
  background: var(--pw-surface2);
  border-color: var(--pw-border);
}
body.dark-mode .dropdown-item {
  color: var(--pw-text);
}
body.dark-mode .dropdown-item:hover {
  background: rgba(91, 141, 238, 0.12);
  color: #e2e8f0;
}
body.dark-mode .dropdown-divider {
  border-color: var(--pw-border);
}
body.dark-mode .dropdown-header {
  color: var(--pw-text-muted);
}

body.dark-mode .text-muted {
  color: var(--pw-text-muted) !important;
}

body.dark-mode .vr {
  border-color: var(--pw-border);
  opacity: 0.6;
}
