/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables */
:root {
  --bg:      #0f1117;   /* page background */
  --bg2:     #161b27;   /* editor / output pane background */
  --bg3:     #1e2535;   /* toolbar / hover background */
  --bg4:     #252d3d;   /* active hover */
  --border:  #2a3347;
  --border2: #3a4560;
  --text:    #e2e8f0;
  --text2:   #94a3b8;
  --text3:   #64748b;
  --accent:  #6366f1;   /* primary action color */
  --accent2: #818cf8;
  --green:   #22c55e;   --green-bg: #052e16;
  --red:     #f87171;   --red-bg:   #2d0a0a;
  --yellow:  #fbbf24;   --yellow-bg:#2d1f00;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --sans: 'Sora', system-ui, sans-serif;
  --radius:    8px;
  --radius-lg: 12px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
}

/* Light Theme Overrides */
body.light-theme {
  --bg:      #f0f4f8;
  --bg2:     #ffffff;
  --bg3:     #e2e8f0;
  --bg4:     #cbd5e1;
  --border:  #cbd5e1;
  --border2: #94a3b8;
  --text:    #0f172a;
  --text2:   #334155;
  --text3:   #64748b;
  --accent:  #4f46e5;
  --accent2: #6366f1;
  --green:   #16a34a;   --green-bg: #dcfce7;
  --red:     #dc2626;   --red-bg:   #fee2e2;
  --yellow:  #d97706;   --yellow-bg:#fef3c7;
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.12);
}

body.light-theme .site-header {
  background-color: rgba(240, 244, 248, 0.90);
}

body.light-theme ::-webkit-scrollbar-track {
  background: var(--bg3);
}

body.light-theme ::-webkit-scrollbar-thumb {
  background: var(--border2);
}

/* Light theme: fix switch toggle thumb color (dark dot on light bg) */
body.light-theme .switch-slider:before {
  background-color: var(--text3);
}

/* Light theme: unchecked switch track should use light surface */
body.light-theme .switch-slider {
  background-color: var(--bg3);
  border-color: var(--border2);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border2);
}

/* Sticky Header & Blur */
.site-header {
  position: sticky;
  top: 0;
  height: 54px;
  background-color: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-container {
  width: 100%;
  max-width: 1400px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent2), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
  -webkit-text-fill-color: white;
}

/* Navigation & Hamburger */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.nav-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 14px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}

.nav-pill:hover {
  color: var(--text);
  background-color: var(--bg3);
}

.nav-pill.active {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.35);
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* Page Layout Wrapper: sidebar ads + main content */
.page-layout-wrapper {
  display: flex;
  flex: 1;
  align-items: flex-start;
  width: 100%;
  gap: 0;
}

/* Sidebar Ad Rail */
.ad-sidebar {
  width: 160px;
  flex-shrink: 0;
  padding: 24px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ad-sidebar-left {
  padding-left: 12px;
  padding-right: 4px;
}

.ad-sidebar-right {
  padding-right: 12px;
  padding-left: 4px;
}

.ad-sidebar-inner {
  position: sticky;
  top: 78px; /* below the 54px header */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 160px;
  min-height: 600px;
}

.ad-sidebar-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Hide sidebar ads on screens narrower than 1300px */
@media (max-width: 1299px) {
  .ad-sidebar {
    display: none;
  }
}

/* Main Content Layout */
.main-content {
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.tab-section {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.section-desc {
  font-size: 14px;
  color: var(--text2);
}

/* Two Column Editor Grid */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

.editor-card {
  background-color: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Code Editor & Output Pane */
.code-editor {
  width: 100%;
  min-height: 320px;
  background-color: #0b0d12;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: var(--transition);
}

.code-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.code-output {
  width: 100%;
  min-height: 320px;
  max-height: 520px;
  background-color: #0b0d12;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  transition: var(--transition);
}

.code-output.flash-green {
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

/* Actions Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 16px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn:hover {
  background-color: var(--bg4);
  border-color: var(--text3);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background-color: var(--accent2);
  border-color: var(--accent2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text3);
}

.btn-ghost:hover {
  background-color: var(--bg3);
  color: var(--text2);
}

/* Select Control */
.select-control {
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-control:focus {
  border-color: var(--accent);
}

/* Input Control */
.input-control {
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.input-control:focus {
  border-color: var(--accent);
}

/* Status Bar */
.status-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-top: 16px;
  animation: slideUp 0.2s ease-out;
}

.status-bar.show {
  display: flex;
}

.status-bar.ok {
  background-color: var(--green-bg);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.status-bar.err {
  background-color: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
}

.status-bar.warn {
  background-color: var(--yellow-bg);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--yellow);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* TOON Legend Bar */
.toon-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background-color: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  align-items: center;
}

.legend-label {
  font-size: 12px;
  color: var(--text3);
  margin-right: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.token {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid;
}

/* Token Colors */
.t-str {
  color: #4ade80;
  background-color: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.2);
}

.t-int {
  color: #fbbf24;
  background-color: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.2);
}

.t-float {
  color: #fb923c;
  background-color: rgba(251, 146, 60, 0.1);
  border-color: rgba(251, 146, 60, 0.2);
}

.t-bool {
  color: #c084fc;
  background-color: rgba(192, 132, 252, 0.1);
  border-color: rgba(192, 132, 252, 0.2);
}

.t-null {
  color: #94a3b8;
  background-color: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
}

.t-arr {
  color: #60a5fa;
  background-color: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.2);
}

.t-obj {
  color: #a78bfa;
  background-color: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.2);
}

/* Interactive Tree View CSS */
.tree-container {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.tree-node {
  margin-left: 18px;
  position: relative;
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
  font-weight: bold;
  color: var(--accent2);
  margin-right: 4px;
  display: inline-block;
  transition: transform 0.1s ease;
}

.tree-toggle.collapsed {
  transform: rotate(-90deg);
}

.tree-children {
  display: block;
}

.tree-children.hidden {
  display: none;
}

.tree-key {
  color: #a78bfa;
}

.tree-val-str { color: #4ade80; }
.tree-val-num { color: #fbbf24; }
.tree-val-bool { color: #c084fc; }
.tree-val-null { color: #64748b; }

.tree-expand-bracket {
  color: var(--text3);
}

/* Diff Rendering Styles */
.diff-line {
  display: block;
  font-family: var(--mono);
  padding: 2px 8px;
}

.diff-added {
  background-color: var(--green-bg);
  color: var(--green);
}

.diff-removed {
  background-color: var(--red-bg);
  color: var(--red);
}

/* Footer styling */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  margin-top: 40px;
}

/* Responsive Rules */
@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }
  .code-editor, .code-output {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .site-header {
    height: auto;
    padding: 12px 0;
  }
  
  .header-container {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .hamburger-btn {
    display: block;
    position: absolute;
    right: 24px;
    top: 14px;
  }
  
  .nav-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
  }
  
  .nav-menu.show {
    display: flex;
  }
  
  .nav-pill {
    text-align: left;
    border-radius: 6px;
    padding: 8px 12px;
  }
}

/* Interstitial Ad Modal Styles */
.ad-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.ad-modal-overlay.show {
  display: flex;
}

.ad-modal-content {
  background-color: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 90%;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ad-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.ad-modal-label {
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-modal-body {
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0b0d12;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* TOON Studio Settings & Metrics CSS */
.toon-settings-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.settings-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.settings-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

@media (max-width: 768px) {
  .settings-left {
    width: 100%;
    justify-content: space-between;
    gap: 16px;
  }
  .settings-right {
    width: 100%;
    margin-left: 0;
  }
  .history-dropdown-container {
    width: 100%;
  }
  .btn-history {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .settings-left {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}

.settings-group {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}

.settings-label {
  font-size: 13px;
  color: var(--text2);
}

/* Custom Select Control Wrapper */
.select-wrapper {
  position: relative;
  display: inline-block;
}

.select-control {
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 32px 8px 12px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: var(--transition);
}

.select-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.select-wrapper::after {
  content: "▾";
  font-size: 12px;
  color: var(--text3);
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: var(--transition);
}

.select-wrapper:hover::after {
  color: var(--text2);
}

/* Custom Switch Styling */
.switch-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  transition: var(--transition);
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text2);
  border-radius: 50%;
  transition: var(--transition);
}

.switch-container input:checked + .switch-slider {
  background-color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.switch-container input:checked + .switch-slider:before {
  transform: translateX(18px);
  background-color: #fff;
}

.switch-container:hover .switch-slider {
  border-color: var(--text3);
}

.switch-label {
  font-size: 13px;
  color: var(--text2);
  transition: var(--transition);
}

.switch-container:hover .switch-label {
  color: var(--text);
}

/* History Button & Dropdown */
.btn-history {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-weight: 500;
  transition: var(--transition);
}

.btn-history:hover {
  color: var(--text);
  border-color: var(--accent);
  background-color: var(--bg4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.history-badge {
  background-color: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.btn-history .chevron {
  font-size: 10px;
  color: var(--text3);
  transition: var(--transition);
}

.btn-history:hover .chevron {
  color: var(--text2);
}

.history-dropdown-container {
  position: relative;
}

.history-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background-color: rgba(22, 27, 39, 0.95);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 150;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-dropdown-menu.hidden {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn-clear-history {
  padding: 4px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 4px !important;
  background-color: rgba(248, 113, 113, 0.1) !important;
  color: var(--red) !important;
  border: 1px solid rgba(248, 113, 113, 0.2) !important;
  transition: var(--transition) !important;
}

.btn-clear-history:hover {
  background-color: var(--red) !important;
  color: #fff !important;
  border-color: var(--red) !important;
}

.history-items-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.history-no-items {
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  padding: 24px 0;
  font-style: italic;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background-color: rgba(30, 37, 53, 0.4);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.05);
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text3);
}

.history-item-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-color: rgba(11, 13, 18, 0.4);
  padding: 4px 6px;
  border-radius: 4px;
}

.history-item-savings {
  color: var(--green);
  font-weight: 600;
  background-color: rgba(34, 197, 94, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Premium Dashboard Metrics Panel */
.toon-metrics-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(192, 132, 252, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.toon-metrics-banner.hidden {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: var(--radius);
  background-color: rgba(22, 27, 39, 0.5);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.metric-item:hover {
  background-color: rgba(30, 37, 53, 0.5);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
}

.highlight-savings {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(34, 197, 94, 0.12));
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.highlight-savings:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.18));
  border-color: rgba(34, 197, 94, 0.4);
}

.highlight-savings .metric-label {
  color: var(--green);
}

.highlight-savings .metric-value {
  color: var(--green);
  text-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

/* Diagnostics & Error Highlighting Wrapper */
.editor-wrapper {
  position: relative;
  width: 100%;
  display: flex;
}

/* Scrollbar Track Error Marker Tick */
.error-scrollbar-marker {
  position: absolute;
  right: 2px;
  width: 6px;
  height: 4px;
  background-color: var(--red);
  border-radius: 1px;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 6px var(--red);
  transition: opacity 0.15s ease;
}

/* Editor Input Error State styling */
.code-editor.error-active {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
}

/* ==========================================
 * 8. Premium Theme & Utilities Extensions
 * ========================================== */

/* Light Theme Variables Override */
.light-theme {
  --bg:      #f8fafc;
  --bg2:     #ffffff;
  --bg3:     #f1f5f9;
  --bg4:     #e2e8f0;
  --border:  #cbd5e1;
  --border2: #94a3b8;
  --text:    #0f172a;
  --text2:   #475569;
  --text3:   #64748b;
  --accent:  #4f46e5;
  --accent2: #6366f1;
  --green:   #16a34a;   --green-bg: #dcfce7;
  --red:     #dc2626;   --red-bg:   #fee2e2;
  --yellow:  #ca8a04;   --yellow-bg:#fef9c3;
  --shadow:  0 4px 20px -2px rgba(15, 23, 42, 0.08);
}

.light-theme .site-header {
  background-color: rgba(248, 250, 252, 0.85);
  border-bottom-color: var(--border);
}

.light-theme .code-editor,
.light-theme .code-output {
  background-color: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.light-theme .toon-legend {
  background-color: #ffffff;
}

.light-theme .metric-item {
  background-color: #f8fafc;
}

/* Header utility actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon-only {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
}

.btn-icon-only:hover {
  background-color: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}

/* ============================================
   3D Flip Card Theme Toggle
   ============================================ */
.theme-flip-card {
  width: 36px;
  height: 36px;
  perspective: 700px;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
}

.theme-flip-card:focus-visible .theme-flip-inner {
  box-shadow: 0 0 0 2px var(--accent);
}

.theme-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: 50%;
}

/* When the card has .flipped class, rotate to show moon */
.theme-flip-card.flipped .theme-flip-inner {
  transform: rotateY(180deg);
}

.theme-flip-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: visible;
}

/* ---- Sun face (dark mode, shown by default) ---- */
.theme-flip-front {
  background: linear-gradient(135deg, #2d1f00 0%, #3b2800 100%);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}

.theme-flip-card:not(.flipped):hover .theme-flip-front {
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.4), inset 0 0 8px rgba(251, 191, 36, 0.08);
}

.theme-flip-front svg {
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.7));
  animation: sun-spin 12s linear infinite;
  transform-origin: center;
}

/* Pause spin while flipping for a clean feel */
.theme-flip-card.flipped .theme-flip-front svg {
  animation-play-state: paused;
}

@keyframes sun-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---- Moon face (light mode, hidden by default via rotateY) ---- */
.theme-flip-back {
  background: linear-gradient(135deg, #13104a 0%, #1e1a60 100%);
  color: #c4b5fd;
  border-color: rgba(129, 140, 248, 0.25);
  transform: rotateY(180deg);
}

.theme-flip-card.flipped:hover .theme-flip-back {
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 14px rgba(129, 140, 248, 0.45), inset 0 0 8px rgba(129, 140, 248, 0.08);
}

.theme-flip-back svg {
  filter: drop-shadow(0 0 4px rgba(196, 181, 253, 0.7));
}

/* ---- Star dots on the moon face ---- */
.flip-star {
  position: absolute;
  border-radius: 50%;
  background: #e0d9ff;
  box-shadow: 0 0 3px 1px rgba(224, 217, 255, 0.8);
  animation: star-twinkle 2.4s ease-in-out infinite;
}

.flip-star-1 { width: 3px; height: 3px; top:  5px; right:  7px; animation-delay: 0s;    }
.flip-star-2 { width: 2px; height: 2px; top:  8px; right: 13px; animation-delay: 0.8s; }
.flip-star-3 { width: 2px; height: 2px; bottom: 7px; right: 6px; animation-delay: 1.5s; }

@keyframes star-twinkle {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.6); }
}

/* Click pulse */
.theme-flip-card:active .theme-flip-inner {
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.5);
}
.theme-flip-card.flipped:active .theme-flip-inner {
  box-shadow: 0 0 22px rgba(129, 140, 248, 0.5);
}

/* Key Shortcuts Help Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 17, 23, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background-color: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  font-size: 13px;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-keys {
  font-family: var(--mono);
  background-color: var(--bg3);
  border: 1px solid var(--border2);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

/* Tree search styles */
.tree-search-container {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
}

.tree-search-input {
  flex: 1;
}

.tree-node-match {
  background-color: rgba(251, 191, 36, 0.25);
  border-radius: 4px;
  padding: 0 4px;
  border: 1px dotted var(--yellow);
}

.tree-node-dimmed {
  opacity: 0.35;
  transition: opacity 0.2s ease;
}

/* Utilities Action Items */
.utility-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.mock-settings {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
