/*
 * PhononIQ - Professional Phononic Bandgap Prediction Tool
 * COMSOL-inspired Light Theme
 *
 * Color palette derived from COMSOL Multiphysics UI
 * with NewFOS brand accents (teal, orange, brown)
 *
 * Fonts: Inter (UI), Space Grotesk (headings), JetBrains Mono (code/data)
 */

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

/* ============================================================
   1. CSS Custom Properties (Design Tokens) — LIGHT THEME
   ============================================================ */
:root {
    /* Backgrounds — Pure white COMSOL theme */
    --ap-bg: #fafafa;
    --ap-bg-alt: #f5f5f5;
    --ap-bg-panel: #ffffff;
    --ap-bg-toolbar: #ffffff;
    --ap-bg-sidebar: #ffffff;
    --ap-bg-input: #ffffff;

    /* Borders */
    --ap-border: #d0d0d0;
    --ap-border-light: #c0c0c0;
    --ap-border-focus: #0078d4;

    /* Text */
    --ap-text: #1a1a1a;
    --ap-text-secondary: #555555;
    --ap-text-muted: #888888;

    /* Accent Colors */
    --ap-accent: #0078d4;
    --ap-accent-teal: #1a6b7a;
    --ap-accent-orange: #d46a1a;
    --ap-accent-brown: #8a3a08;
    --ap-accent-highlight: #0e8a94;

    /* Semantic Colors */
    --ap-success: #16a34a;
    --ap-warning: #d97706;
    --ap-danger: #dc2626;

    /* Shadows */
    --ap-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --ap-shadow-md: 0 2px 6px rgba(0, 0, 0, 0.1);
    --ap-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --ap-shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.08);

    /* Transitions */
    --ap-transition-fast: 0.15s ease;
    --ap-transition-normal: 0.25s ease;
    --ap-transition-slow: 0.4s ease;

    /* Fonts */
    --ap-font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ap-font-heading: 'Space Grotesk', 'Inter', sans-serif;
    --ap-font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

    /* Layout */
    --ap-toolbar-height: 132px;
    --ap-statusbar-height: 28px;
    --ap-sidebar-width: 260px;
}


/* ============================================================
   2. Reset & Base
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--ap-bg);
    color: var(--ap-text);
    font-family: var(--ap-font-ui);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

a {
    color: var(--ap-accent-highlight);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--ap-bg);
}

::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

::-webkit-scrollbar-corner {
    background: var(--ap-bg);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #bbb var(--ap-bg);
}


/* ============================================================
   3. Typography
   ============================================================ */
h1, h2, h3, h4 {
    font-family: var(--ap-font-heading);
    color: var(--ap-text);
    margin: 0 0 0.5em 0;
    line-height: 1.3;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.ap-mono {
    font-family: var(--ap-font-mono);
    font-size: 0.85em;
}

.ap-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.ap-text-secondary {
    color: var(--ap-text-secondary);
}

.ap-text-muted {
    color: var(--ap-text-muted);
}

.ap-text-accent {
    color: var(--ap-accent-highlight);
}

.ap-text-success {
    color: var(--ap-success);
}

.ap-text-warning {
    color: var(--ap-warning);
}

.ap-text-danger {
    color: var(--ap-danger);
}


/* ============================================================
   4. Layout System
   ============================================================ */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.ap-app-layout {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}


/* ============================================================
   5. Ribbon Toolbar (COMSOL-style)
   ============================================================ */

/* --- Ribbon container --- */
.ap-ribbon {
    display: flex;
    flex-direction: column;
    user-select: none;
    z-index: 100;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* --- Top bar (tabs + brand) --- */
.ap-ribbon-topbar {
    height: 32px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: linear-gradient(180deg, #1a9ba8, #158a96);
    gap: 0;
}

.ap-ribbon-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 16px;
    margin-right: 2px;
}

.ap-ribbon-logo {
    height: 22px;
    width: auto;
    filter: brightness(1.3);
}

.ap-ribbon-title {
    font-family: var(--ap-font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    white-space: nowrap;
}

.ap-ribbon-ver {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.4);
    margin-left: 2px;
}

/* Tab buttons */
.ap-ribbon-tabs {
    display: flex;
    align-items: stretch;
    height: 100%;
    gap: 0;
}

.ap-ribbon-tab {
    padding: 0 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    font-family: var(--ap-font-ui);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.02em;
}

.ap-ribbon-tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.ap-ribbon-tab.active {
    color: #fff;
    border-bottom-color: #4ec9d4;
    background: rgba(255,255,255,0.06);
    font-weight: 600;
}

.ap-ribbon-breadcrumb {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.55);
    flex-shrink: 1;
    overflow: hidden;
    white-space: nowrap;
    margin-right: 12px;
}

.ap-ribbon-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ap-ribbon-uni-logo {
    height: 20px;
    width: auto;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.ap-ribbon-uni-logo:hover { opacity: 1; }

/* --- Ribbon bar (icon groups) — COMSOL-wide style --- */
.ap-ribbon-bar {
    height: 100px;
    display: flex;
    align-items: stretch;
    padding: 0 4px;
    background: #ffffff;
    border-bottom: 1px solid #d0d4da;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    transition: height 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
}

/* Collapsed ribbon */
.ap-ribbon.collapsed .ap-ribbon-bar {
    height: 0;
    padding: 0;
    overflow: hidden;
    border-bottom: none;
    opacity: 0;
}
.ap-ribbon.collapsed {
    --ap-toolbar-height: 32px;
}

/* Toggle button */
.ap-ribbon-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
}
.ap-ribbon-toggle:hover { color: #fff; }
.ap-ribbon-toggle svg {
    transition: transform 0.2s ease;
}
.ap-ribbon.collapsed .ap-ribbon-toggle svg {
    transform: rotate(180deg);
}

/* --- Group --- */
.ap-ribbon-group {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e3e8;
    padding: 0;
}

.ap-ribbon-group:last-child { border-right: none; }

.ap-ribbon-group-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 12px 2px 12px;
}

.ap-ribbon-group-label {
    text-align: center;
    font-size: 0.64rem;
    color: #777;
    letter-spacing: 0.04em;
    font-weight: 500;
    padding: 3px 12px 5px 12px;
    line-height: 1;
    border-top: 1px solid #ebedf0;
    margin-top: auto;
    white-space: nowrap;
    overflow: visible;
}

/* --- Ribbon button (icon above label) — COMSOL size --- */
.ap-ribbon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px 4px 10px;
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    color: #333;
    font-size: 0.64rem;
    font-family: var(--ap-font-ui);
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    transition: all 0.12s;
    min-width: 52px;
}

.ap-ribbon-btn svg {
    flex-shrink: 0;
    transition: all 0.15s;
}

.ap-ribbon-btn:hover {
    background: #e8ecf1;
    border-color: #c0c6ce;
    color: #111;
}

.ap-ribbon-btn:hover svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.12));
}

.ap-ribbon-btn:active {
    background: #dde1e7;
    border-color: #b0b6be;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

.ap-ribbon-btn span {
    display: block;
    max-width: 120px;
    overflow: visible;
    white-space: nowrap;
}

/* Primary button (Run All / Analyze) — green with 3D pop */
.ap-ribbon-btn-primary {
    background: linear-gradient(180deg, #4a9e4a, #367036);
    border-color: #2a5a2a;
    color: #fff;
    padding: 6px 16px 4px 16px;
    min-width: 56px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

.ap-ribbon-btn-primary svg {
    stroke: none;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

.ap-ribbon-btn-primary:hover {
    background: linear-gradient(180deg, #5ab55a, #428542);
    border-color: #367036;
    color: #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ap-ribbon-btn-primary:hover svg { stroke: none; fill: #fff; }

.ap-ribbon-btn-primary:active {
    background: linear-gradient(180deg, #2a5a2a, #367036);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    transform: translateY(1px);
}

.ap-ribbon-btn-primary span {
    font-size: 0.72rem;
    font-weight: 600;
}

/* Danger button (Stop/Clear) — red with 3D pop */
.ap-ribbon-btn-danger {
    background: linear-gradient(180deg, #cc4444, #993333);
    border-color: #882222;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}

.ap-ribbon-btn-danger svg {
    stroke: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

.ap-ribbon-btn-danger:hover {
    background: linear-gradient(180deg, #dd5555, #aa3333);
    border-color: #993333;
    color: #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.25);
}

.ap-ribbon-btn-danger:hover svg { stroke: #fff; }

.ap-ribbon-btn-danger:active {
    background: linear-gradient(180deg, #882222, #993333);
    transform: translateY(1px);
}

.ap-ribbon-btn-danger span {
    font-size: 0.68rem;
    font-weight: 600;
}

/* Compute button — NewFoS teal with 3D pop */
.ap-ribbon-btn-compute {
    background: linear-gradient(180deg, #4ec9d4, #1a9ba8);
    border-color: #158a96;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.25);
}

.ap-ribbon-btn-compute svg {
    stroke: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.ap-ribbon-btn-compute svg polygon {
    fill: #fff;
}

.ap-ribbon-btn-compute:hover {
    background: linear-gradient(180deg, #5dd8e3, #2bb5c2);
    border-color: #1a9ba8;
    color: #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.3);
}

.ap-ribbon-btn-compute:hover svg { stroke: #fff; }

.ap-ribbon-btn-compute:active {
    background: linear-gradient(180deg, #158a96, #1a9ba8);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    transform: translateY(1px);
}

.ap-ribbon-btn-compute span {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Needs-update pulse on Compute */
.ap-ribbon-btn-compute.needs-update {
    animation: pulse-analyze 1.5s infinite;
}

@keyframes pulse-analyze {
    0%, 100% { box-shadow: 0 0 0 0 rgba(78,201,212,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(78,201,212,0); }
}

/* Active ribbon navigation button highlight */
.ap-ribbon-btn-active {
    background: linear-gradient(180deg, #dbeafe, #bfdbfe) !important;
    border-color: #3b82f6 !important;
    color: #1e40af !important;
    box-shadow: 0 1px 3px rgba(59,130,246,0.25), inset 0 1px 0 rgba(255,255,255,0.5) !important;
}

.ap-ribbon-btn-active svg {
    stroke: #2563eb !important;
}


/* ============================================================
   6. Sidebar
   ============================================================ */
.ap-sidebar {
    width: var(--ap-sidebar-width);
    min-width: var(--ap-sidebar-width);
    background: #ffffff;
    border-right: 1px solid #e0e3e8;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    user-select: none;
}

/* Tree Section */
.ap-tree-section {
    margin-bottom: 4px;
}

.ap-tree-header {
    padding: 8px 12px;
    font-weight: 600;
    color: #777;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--ap-transition-fast);
}

.ap-tree-header:hover {
    color: #444;
}

.ap-tree-chevron {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.ap-tree-section.collapsed .ap-tree-chevron {
    transform: rotate(-90deg);
}

.ap-tree-section.collapsed .ap-tree-content {
    display: none;
}

/* Tree Items */
.ap-tree-item {
    padding: 6px 12px 6px 28px;
    cursor: pointer;
    color: #444;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
    transition: all var(--ap-transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-tree-item:hover {
    background: #e0e8ef;
    color: #1a1a1a;
}

.ap-tree-item.active {
    background: #dbeafe;
    color: var(--ap-accent);
    border-left-color: var(--ap-accent);
}

.ap-tree-icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.ap-tree-item.active .ap-tree-icon {
    opacity: 0.9;
}

/* ── Topology Sub-Navigation ────────────────────────────────────── */
.ap-tree-sub-header {
  padding: 6px 12px 6px 28px;
  font-weight: 600;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s ease;
  user-select: none;
}
.ap-tree-sub-header:hover { color: #ccc; }
.ap-tree-sub-header .ap-tree-chevron {
  font-size: 0.55rem;
  transition: transform 0.2s ease;
}
.ap-tree-sub-header.collapsed .ap-tree-chevron {
  transform: rotate(-90deg);
}
.ap-tree-sub-items {
  transition: all 0.2s ease;
}
.ap-tree-sub-item {
  padding-left: 48px !important;
  font-size: 0.78rem !important;
}

/* ── Section Dividers (Single Design / Dataset Summary) ────────── */
.ap-section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: #888;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 4px;
}
.ap-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(78,201,212,0.3), transparent);
}

/* Sidebar Panel */
.ap-sidebar-panel {
    padding: 12px;
    border-top: 1px solid var(--ap-border);
}

.ap-sidebar-panel .ap-panel-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

/* Parameter Tree — COMSOL-style */
.ap-param-tree {
    padding: 8px 10px !important;
}

.ap-ptree-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ap-text);
    cursor: pointer;
    border-bottom: 1px solid var(--ap-border);
    margin-bottom: 4px;
}

.ap-ptree-header-icon {
    flex-shrink: 0;
}

.ap-ptree-header-text {
    font-family: var(--ap-font-heading);
}

.ap-ptree-chevron {
    font-size: 0.65rem;
    color: #999;
    width: 10px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.ap-ptree-subheader {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 4px 4px 8px;
    margin-top: 6px;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--ap-text-secondary);
    cursor: pointer;
}

.ap-ptree-sub-icon {
    flex-shrink: 0;
}

.ap-ptree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 2px 24px;
}

.ap-ptree-icon {
    flex-shrink: 0;
}

.ap-ptree-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ap-text);
}

.ap-ptree-input {
    padding: 2px 4px 6px 24px;
}

.ap-ptree-input .ap-select,
.ap-ptree-input .ap-input {
    width: 100%;
    background: var(--ap-bg-input);
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.82rem;
    color: var(--ap-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ap-ptree-input .ap-select:focus,
.ap-ptree-input .ap-input:focus {
    border-color: var(--ap-border-focus);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.12);
    outline: none;
}

.ap-ptree-hint {
    font-size: 0.66rem;
    color: #999;
    margin-top: 2px;
    padding-left: 2px;
}

.ap-ptree-check {
    padding-top: 2px;
    padding-bottom: 4px;
}

.ap-ptree-check .ap-checkbox-label {
    font-size: 0.78rem;
    gap: 6px;
}

/* ============================================================
   7. Workspace & Pages
   ============================================================ */
.ap-workspace {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--ap-bg);
}

.ap-page {
    display: none;
}

.ap-page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Panels */
.ap-panel {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
}

.ap-panel-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ap-text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ap-panel-header svg {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

.ap-panel-header .ap-panel-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

/* Dual Panel Grid */
.ap-dual-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Triple Panel Grid */
.ap-triple-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* Full-width panel in grid */
.ap-panel-full {
    grid-column: 1 / -1;
}


/* ============================================================
   8. 3D Button System
   ============================================================ */
.ap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(180deg, #ffffff, #ececec);
    border: 1px solid #b8b8b8;
    border-bottom-color: #a0a0a0;
    border-right-color: #a0a0a0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    color: #333;
    padding: 6px 14px;
    border-radius: 3px;
    font-family: var(--ap-font-ui);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--ap-transition-fast);
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
}

.ap-btn:hover {
    background: linear-gradient(180deg, #f0f0f0, #e2e2e2);
    border-color: #999;
    color: #111;
    text-decoration: none;
}

.ap-btn:active {
    background: linear-gradient(180deg, #ddd, #e8e8e8);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
    transform: translateY(1px);
    border-color: #999;
}

.ap-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.ap-btn svg {
    width: 14px;
    height: 14px;
}

/* Primary Button (COMSOL blue) */
.ap-btn-primary {
    background: linear-gradient(180deg, #3d8fd4, #0068b8);
    color: #fff;
    border-color: var(--ap-accent);
    border-bottom-color: #005a9e;
    border-right-color: #005a9e;
}

.ap-btn-primary:hover {
    background: linear-gradient(180deg, #4da0e0, #0078d4);
    border-color: #3d8fd4;
    color: #fff;
}

.ap-btn-primary:active {
    background: linear-gradient(180deg, #005a9e, #0068b8);
    border-color: #004578;
    border-top-color: #3d8fd4;
    border-left-color: #3d8fd4;
}

/* Run Button (NewFOS teal) */
.ap-btn-run {
    background: linear-gradient(180deg, #3d8080, #2a5a5a);
    color: #fff;
    border-color: var(--ap-accent-teal);
    border-bottom-color: #1a3838;
    border-right-color: #1a3838;
    font-weight: 600;
    padding: 8px 20px;
}

.ap-btn-run:hover {
    background: linear-gradient(180deg, #4d9090, #335c68);
    border-color: #4d9090;
    color: #fff;
}

.ap-btn-run:active {
    background: linear-gradient(180deg, #1a3838, #2a5a5a);
    border-color: #0e2020;
    border-top-color: #4d9090;
    border-left-color: #4d9090;
}

/* Danger Button */
.ap-btn-danger {
    background: linear-gradient(180deg, #d44040, #b02020);
    color: #fff;
    border-color: #c03030;
    border-bottom-color: #8a1a1a;
    border-right-color: #8a1a1a;
}

.ap-btn-danger:hover {
    background: linear-gradient(180deg, #e05050, #c03030);
    border-color: #e05050;
    color: #fff;
}

.ap-btn-danger:active {
    background: linear-gradient(180deg, #8a1a1a, #b02020);
    border-color: #601010;
    border-top-color: #d44040;
    border-left-color: #d44040;
}

/* Small Button */
.ap-btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.ap-btn-sm svg {
    width: 12px;
    height: 12px;
}

/* Icon-only Button */
.ap-btn-icon {
    padding: 6px;
    min-width: 30px;
    min-height: 30px;
}

/* Button Group */
.ap-btn-group {
    display: flex;
    gap: 0;
}

.ap-btn-group > .ap-btn {
    border-radius: 0;
    margin-left: -1px;
}

.ap-btn-group > .ap-btn:first-child {
    border-radius: 3px 0 0 3px;
    margin-left: 0;
}

.ap-btn-group > .ap-btn:last-child {
    border-radius: 0 3px 3px 0;
}

.ap-btn-group > .ap-btn:only-child {
    border-radius: 3px;
}


/* ============================================================
   9. Form Controls
   ============================================================ */
.ap-control {
    margin-bottom: 10px;
}

.ap-control > label {
    display: block;
    font-size: 0.75rem;
    color: var(--ap-text-secondary);
    margin-bottom: 4px;
}

/* Select */
.ap-select {
    background: var(--ap-bg-input);
    border: 1px solid #b8b8b8;
    color: var(--ap-text);
    padding: 5px 8px;
    border-radius: 3px;
    font-family: var(--ap-font-ui);
    font-size: 0.82rem;
    width: 100%;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    transition: border-color var(--ap-transition-fast);
}

.ap-select:focus {
    border-color: var(--ap-border-focus);
    outline: none;
}

.ap-select:hover {
    border-color: #888;
}

.ap-select option {
    background: var(--ap-bg-input);
    color: var(--ap-text);
}

/* Input */
.ap-input {
    background: var(--ap-bg-input);
    border: 1px solid #b8b8b8;
    color: var(--ap-text);
    padding: 5px 8px;
    border-radius: 3px;
    font-family: var(--ap-font-ui);
    font-size: 0.82rem;
    width: 100%;
    transition: border-color var(--ap-transition-fast);
}

.ap-input:focus {
    border-color: var(--ap-border-focus);
    outline: none;
}

.ap-input:hover {
    border-color: #888;
}

.ap-input::placeholder {
    color: #aaa;
}

.ap-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Textarea */
.ap-textarea {
    background: var(--ap-bg-input);
    border: 1px solid #b8b8b8;
    color: var(--ap-text);
    padding: 6px 8px;
    border-radius: 3px;
    font-family: var(--ap-font-ui);
    font-size: 0.82rem;
    width: 100%;
    resize: vertical;
    min-height: 60px;
    transition: border-color var(--ap-transition-fast);
}

.ap-textarea:focus {
    border-color: var(--ap-border-focus);
    outline: none;
}

/* Slider (Range Input) */
.ap-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.ap-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--ap-accent-teal);
    border: 2px solid var(--ap-accent-highlight);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--ap-transition-fast);
}

.ap-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.ap-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--ap-accent-teal);
    border: 2px solid var(--ap-accent-highlight);
    border-radius: 50%;
    cursor: pointer;
}

.ap-slider::-moz-range-track {
    background: #ccc;
    height: 4px;
    border-radius: 2px;
}

/* Checkbox */
.ap-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #444;
    cursor: pointer;
    user-select: none;
}

.ap-checkbox-label input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid #b8b8b8;
    background: #fff;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--ap-transition-fast);
}

.ap-checkbox-label input[type="checkbox"]:checked {
    background: var(--ap-accent-teal);
    border-color: var(--ap-accent-highlight);
}

.ap-checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ap-checkbox-label input[type="checkbox"]:focus {
    border-color: var(--ap-border-focus);
    outline: none;
}

/* Radio Button */
.ap-radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #444;
    cursor: pointer;
    user-select: none;
}

.ap-radio-label input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid #b8b8b8;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--ap-transition-fast);
}

.ap-radio-label input[type="radio"]:checked {
    border-color: var(--ap-accent-highlight);
}

.ap-radio-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    background: var(--ap-accent-highlight);
    border-radius: 50%;
}

.ap-radio-label input[type="radio"]:focus {
    border-color: var(--ap-border-focus);
    outline: none;
}

/* Inline Controls */
.ap-inline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ap-inline-controls .ap-control {
    margin-bottom: 0;
}

/* Control with Unit */
.ap-input-unit {
    display: flex;
    align-items: center;
}

.ap-input-unit .ap-input {
    border-radius: 3px 0 0 3px;
    border-right: none;
}

.ap-input-unit .ap-unit {
    background: #eee;
    border: 1px solid #b8b8b8;
    padding: 5px 8px;
    font-size: 0.75rem;
    color: #666;
    border-radius: 0 3px 3px 0;
    white-space: nowrap;
}


/* ============================================================
   10. Status Bar
   ============================================================ */
.ap-statusbar {
    background: var(--ap-bg-panel);
    border-top: 1px solid var(--ap-border-light);
    padding: 4px 16px;
    font-size: 0.75rem;
    color: #888;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--ap-statusbar-height);
    user-select: none;
    z-index: 100;
}

.ap-status-sep {
    color: var(--ap-border-light);
}

.ap-status-sep::after {
    content: '|';
}

.ap-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ap-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ap-success);
}

.ap-status-dot.warning {
    background: var(--ap-warning);
}

.ap-status-dot.error {
    background: var(--ap-danger);
}

.ap-statusbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}


/* ============================================================
   11. Data Display
   ============================================================ */

/* Metrics Row */
.ap-metrics {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ap-metric {
    background: var(--ap-bg-alt);
    border: 1px solid var(--ap-border);
    border-radius: 6px;
    padding: 10px 14px;
    min-width: 120px;
}

.ap-metric-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ap-accent-highlight);
    font-family: var(--ap-font-heading);
    line-height: 1.2;
}

.ap-metric-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* Table */
.ap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.ap-table th {
    text-align: left;
    padding: 6px 10px;
    color: #666;
    border-bottom: 1px solid var(--ap-border-light);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ap-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

.ap-table tr:hover td {
    background: #f0f4f8;
}

.ap-table tr:last-child td {
    border-bottom: none;
}

.ap-table td.ap-mono {
    font-family: var(--ap-font-mono);
    font-size: 0.8rem;
}

/* Badges */
.ap-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.ap-badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--ap-success);
}

.ap-badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--ap-warning);
}

.ap-badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--ap-danger);
}

.ap-badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.ap-badge-teal {
    background: rgba(78, 201, 212, 0.15);
    color: var(--ap-accent-highlight);
}

/* Tags */
.ap-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    background: #eee;
    color: #555;
    border: 1px solid #ccc;
}

/* Progress Bar */
.ap-progress {
    width: 100%;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    overflow: hidden;
}

.ap-progress-bar {
    height: 100%;
    background: var(--ap-accent-highlight);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.ap-progress-bar.success {
    background: var(--ap-success);
}

.ap-progress-bar.warning {
    background: var(--ap-warning);
}

.ap-progress-bar.danger {
    background: var(--ap-danger);
}


/* ============================================================
   12. Plotly Container
   ============================================================ */
.ap-plot {
    width: 100%;
    min-height: 300px;
    border-radius: 4px;
    overflow: visible;
}

.ap-plot .plotly {
    background: transparent !important;
}

.ap-plot-full {
    min-height: 450px;
}

.ap-plot-compact {
    min-height: 200px;
}


/* ============================================================
   13. 3D Canvas Container
   ============================================================ */
.ap-canvas-3d {
    width: 100%;
    background: #f0f4f8;
    border-radius: 4px;
    border: 1px solid #ccc;
    overflow: hidden;
    position: relative;
}

.ap-canvas-3d canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.ap-canvas-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.ap-canvas-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 0.72rem;
    color: var(--ap-text-secondary);
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    border-radius: 3px;
}


/* ============================================================
   14. Animations
   ============================================================ */
@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    0% {
        opacity: 0;
        transform: translateX(-12px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(12px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes scaleIn {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading Spinner */
.ap-loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--ap-border);
    border-top-color: var(--ap-accent-highlight);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ap-loading-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.ap-loading-lg {
    width: 36px;
    height: 36px;
    border-width: 4px;
}

/* Loading Container */
.ap-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--ap-text-secondary);
    font-size: 0.85rem;
}


/* ============================================================
   15. Splash Page Styles (index.html)
   ============================================================ */
.splash-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #ffffff 0%, #e8eef4 100%);
    text-align: center;
    padding: 20px;
    overflow: hidden;
}

.splash-title {
    font-family: var(--ap-font-heading);
    font-weight: 700;
    font-size: 3.5rem;
    background: linear-gradient(135deg, var(--ap-accent-highlight), var(--ap-accent-teal), var(--ap-accent-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.splash-subtitle {
    font-size: 1.2rem;
    color: var(--ap-text-secondary);
    letter-spacing: 0.05em;
    font-weight: 300;
    margin-bottom: 8px;
}

.splash-description {
    font-size: 0.9rem;
    color: var(--ap-text-muted);
    max-width: 500px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.splash-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin: 40px 0;
}

.splash-logos img {
    height: 55px;
    width: auto;
    filter: brightness(0.9);
}

.splash-enter-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(180deg, #4a90c4, #3a7ab5);
    border: 1px solid #3a7ab5;
    padding: 14px 48px;
    font-family: var(--ap-font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all var(--ap-transition-normal);
    text-decoration: none;
}

.splash-enter-btn:hover {
    background: linear-gradient(180deg, #5a9ed0, #4a8ac5);
    border-color: #4a8ac5;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    text-decoration: none;
    color: #fff;
}

.splash-enter-btn:active {
    background: linear-gradient(180deg, #3a7ab5, #2a6a95);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
    transform: translateY(1px);
}

.splash-version {
    font-size: 0.8rem;
    color: var(--ap-text-muted);
    margin-top: 16px;
}

.splash-partners {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 48px;
}

.splash-partners img {
    height: 28px;
    width: auto;
    filter: grayscale(100%) brightness(0.8);
    transition: all 0.3s ease;
}

.splash-partners img:hover {
    filter: grayscale(0%) brightness(1);
}

.splash-footer {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #555;
    font-size: 0.75rem;
    white-space: nowrap;
}


/* ============================================================
   16. Tooltip
   ============================================================ */
.ap-tooltip {
    position: relative;
}

.ap-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.72rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--ap-transition-fast);
    pointer-events: none;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    box-shadow: var(--ap-shadow-md);
}

.ap-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
    opacity: 0;
    transition: opacity var(--ap-transition-fast);
    pointer-events: none;
    z-index: 1000;
}

.ap-tooltip:hover::after,
.ap-tooltip:hover::before {
    opacity: 1;
}

/* Tooltip position variants */
.ap-tooltip-right::after {
    bottom: auto;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
}

.ap-tooltip-right::before {
    bottom: auto;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-right-color: #333;
}

.ap-tooltip-bottom::after {
    bottom: auto;
    top: calc(100% + 6px);
}

.ap-tooltip-bottom::before {
    bottom: auto;
    top: calc(100% + 2px);
    border: 4px solid transparent;
    border-bottom-color: #333;
}


/* ============================================================
   17. Modal / Dialog
   ============================================================ */
.ap-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

.ap-modal {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 8px;
    box-shadow: var(--ap-shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

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

.ap-modal-title {
    font-family: var(--ap-font-heading);
    font-size: 1rem;
    font-weight: 600;
}

.ap-modal-close {
    background: none;
    border: none;
    color: var(--ap-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.ap-modal-close:hover {
    color: var(--ap-text);
}

.ap-modal-body {
    padding: 16px;
}

.ap-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--ap-border);
}


/* ============================================================
   18. Tabs
   ============================================================ */
.ap-tabs {
    display: flex;
    border-bottom: 1px solid var(--ap-border);
    gap: 0;
    margin-bottom: 12px;
}

.ap-tab {
    padding: 8px 16px;
    font-size: 0.82rem;
    color: var(--ap-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--ap-transition-fast);
    user-select: none;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--ap-font-ui);
}

.ap-tab:hover {
    color: var(--ap-text);
    background: rgba(255, 255, 255, 0.03);
}

.ap-tab.active {
    color: var(--ap-accent-highlight);
    border-bottom-color: var(--ap-accent-teal);
}

.ap-tab-content {
    display: none;
}

.ap-tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}


/* ============================================================
   19. Notification / Toast
   ============================================================ */
.ap-notification {
    position: fixed;
    bottom: 40px;
    right: 20px;
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-left: 3px solid var(--ap-accent);
    border-radius: 4px;
    padding: 10px 16px;
    box-shadow: var(--ap-shadow-lg);
    z-index: 3000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
    font-size: 0.85rem;
}

.ap-notification-success {
    border-left-color: var(--ap-success);
}

.ap-notification-warning {
    border-left-color: var(--ap-warning);
}

.ap-notification-error {
    border-left-color: var(--ap-danger);
}

.ap-notification-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.ap-notification-body {
    color: var(--ap-text-secondary);
    font-size: 0.8rem;
}


/* ============================================================
   20. Code / Console
   ============================================================ */
.ap-code-block {
    background: #f5f7fa;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 12px;
    font-family: var(--ap-font-mono);
    font-size: 0.8rem;
    color: #333;
    overflow-x: auto;
    line-height: 1.6;
}

.ap-console {
    background: #1a1a2e;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 8px 12px;
    font-family: var(--ap-font-mono);
    font-size: 0.75rem;
    color: #0f0;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

.ap-console-line {
    padding: 1px 0;
}

.ap-console-line.error {
    color: var(--ap-danger);
}

.ap-console-line.warn {
    color: var(--ap-warning);
}

.ap-console-line.info {
    color: var(--ap-accent-highlight);
}


/* ============================================================
   21. Dividers & Utility
   ============================================================ */
.ap-divider {
    height: 1px;
    background: var(--ap-border);
    margin: 12px 0;
    border: none;
}

.ap-divider-vertical {
    width: 1px;
    background: var(--ap-border);
    align-self: stretch;
}

.ap-flex {
    display: flex;
}

.ap-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ap-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ap-flex-col {
    display: flex;
    flex-direction: column;
}

.ap-gap-4 { gap: 4px; }
.ap-gap-8 { gap: 8px; }
.ap-gap-12 { gap: 12px; }
.ap-gap-16 { gap: 16px; }

.ap-mt-4 { margin-top: 4px; }
.ap-mt-8 { margin-top: 8px; }
.ap-mt-12 { margin-top: 12px; }
.ap-mt-16 { margin-top: 16px; }

.ap-mb-4 { margin-bottom: 4px; }
.ap-mb-8 { margin-bottom: 8px; }
.ap-mb-12 { margin-bottom: 12px; }
.ap-mb-16 { margin-bottom: 16px; }

.ap-hidden {
    display: none !important;
}

.ap-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.ap-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-no-select {
    user-select: none;
}

.ap-clickable {
    cursor: pointer;
}


/* ============================================================
   22. Help / Documentation Pages
   ============================================================ */
.ap-help-panel {
    line-height: 1.65;
    color: var(--ap-text);
    font-size: 0.88rem;
}

.ap-help-panel p {
    margin: 0 0 6px;
}

.ap-help-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--ap-border);
}

.ap-help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ap-help-h3 {
    font-family: var(--ap-font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ap-accent-highlight);
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(78, 201, 212, 0.2);
}

.ap-help-h4 {
    font-family: var(--ap-font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ap-text);
    margin: 16px 0 8px;
}

.ap-help-list {
    margin: 8px 0;
    padding-left: 20px;
    list-style: disc;
}

.ap-help-list li {
    margin-bottom: 6px;
    color: var(--ap-text-secondary);
}

.ap-help-list li strong {
    color: var(--ap-text);
}

.ap-help-table td,
.ap-help-table th {
    vertical-align: top;
    line-height: 1.5;
}

.ap-help-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}

.ap-help-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #f0f4f8;
    border-radius: 6px;
    padding: 14px;
    border-left: 3px solid var(--ap-accent-teal);
}

.ap-help-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ap-accent-teal);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ap-help-step strong {
    display: block;
    color: var(--ap-text);
    margin-bottom: 2px;
}

.ap-help-step p {
    color: var(--ap-text-secondary);
    font-size: 0.82rem;
    margin: 0;
}

.ap-equation {
    background: #f0f4f8;
    border: 1px solid var(--ap-border);
    border-left: 3px solid var(--ap-accent-highlight);
    border-radius: 4px;
    padding: 12px 16px;
    margin: 10px 0;
    font-family: var(--ap-font-mono);
    font-size: 0.88rem;
    color: var(--ap-text);
    letter-spacing: 0.02em;
    overflow-x: auto;
}

/* About modal (inline) */
.ap-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.ap-modal-content {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--ap-shadow-lg);
    max-height: 80vh;
    overflow-y: auto;
}


/* ============================================================
   23a. Page Guide Button & Modal
   ============================================================ */

/* Topology Model Selection Buttons */
.ap-topo-model-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.25s ease;
    flex: 1;
    min-width: 220px;
}
.ap-topo-model-btn:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.2);
}
.ap-topo-model-btn.active {
    border-color: #4ec9d4;
    background: rgba(78,201,212,0.08);
    box-shadow: 0 0 12px rgba(78,201,212,0.15);
}
.ap-topo-model-btn.active[id="topoModelPlate"] {
    border-color: #f59e0b;
    background: rgba(245,158,11,0.08);
    box-shadow: 0 0 12px rgba(245,158,11,0.15);
}
.ap-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    margin-left: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #4ec9d4;
    background: rgba(78, 201, 212, 0.08);
    border: 1px solid rgba(78, 201, 212, 0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    letter-spacing: 0.02em;
}
.ap-guide-btn:hover {
    background: rgba(78, 201, 212, 0.18);
    border-color: rgba(78, 201, 212, 0.5);
    box-shadow: 0 0 8px rgba(78, 201, 212, 0.15);
}
.ap-guide-content {
    max-width: 680px;
    padding: 0;
}
.ap-guide-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 14px;
    border-bottom: 1px solid var(--ap-border);
}
.ap-guide-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.ap-guide-close:hover { color: #fff; }

.ap-guide-section {
    display: flex;
    gap: 14px;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ap-guide-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(78, 201, 212, 0.12);
    color: #4ec9d4;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 2px;
}
.ap-guide-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ap-text);
}
.ap-guide-subtitle {
    margin: 2px 0 0;
    font-size: 0.74rem;
    color: #999;
    font-style: italic;
}
.ap-guide-body {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--ap-text-secondary);
    line-height: 1.6;
}
.ap-guide-body p { margin: 6px 0; }
.ap-guide-body ul {
    margin: 6px 0;
    padding-left: 18px;
}
.ap-guide-body li { margin: 4px 0; }

.ap-guide-formula {
    background: rgba(78, 201, 212, 0.06);
    border: 1px solid rgba(78, 201, 212, 0.15);
    border-radius: 6px;
    padding: 8px 14px;
    margin: 10px 0;
    font-family: 'Georgia', serif;
    font-size: 0.88rem;
    color: #4ec9d4;
    text-align: center;
    letter-spacing: 0.02em;
}
.ap-guide-pipeline {
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 8px 0;
}
.ap-guide-pipe-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 0.82rem;
}
.ap-guide-pipe-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1a6b7a;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ap-guide-pipe-arrow {
    text-align: center;
    color: #666;
    font-size: 0.75rem;
    padding: 2px 0;
}

/* ============================================================
   23. Responsive
   ============================================================ */
@media (max-width: 1024px) {
    :root {
        --ap-sidebar-width: 200px;
    }

    .ap-dual-panel {
        grid-template-columns: 1fr;
    }

    .ap-triple-panel {
        grid-template-columns: 1fr 1fr;
    }

    .splash-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .ap-sidebar {
        display: none;
    }

    .ap-workspace {
        width: 100%;
    }

    .ap-dual-panel {
        grid-template-columns: 1fr;
    }

    .ap-triple-panel {
        grid-template-columns: 1fr;
    }

    .ap-metrics {
        flex-direction: column;
    }

    .splash-title {
        font-size: 2rem;
    }

    .splash-logos {
        gap: 20px;
    }

    .splash-logos img {
        height: 40px;
    }

    .splash-enter-btn {
        padding: 12px 36px;
        font-size: 1rem;
    }
}

@media (max-width: 600px) {
    .ap-ribbon-bar {
        height: 44px;
        padding: 0 4px;
    }

    .ap-ribbon-btn span { display: none; }
    .ap-ribbon-btn { padding: 3px 6px; min-width: 32px; }
    .ap-ribbon-group-label { display: none; }
    .ap-ribbon-topbar { height: 26px; padding: 0 8px; }
    .ap-ribbon-title { font-size: 0.8rem; }

    .ap-workspace {
        padding: 8px;
    }

    .ap-panel {
        padding: 12px;
    }

    .splash-title {
        font-size: 1.6rem;
    }

    .splash-subtitle {
        font-size: 0.95rem;
    }

    .splash-partners {
        flex-wrap: wrap;
        gap: 16px;
    }
}


/* ============================================================
   23. Print Styles
   ============================================================ */
@media print {
    .ap-toolbar,
    .ap-ribbon,
    .ap-statusbar,
    .ap-sidebar {
        display: none !important;
    }

    .ap-app-layout {
        display: block !important;
        height: auto !important;
    }

    .ap-workspace {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    /* Only print the active page, not all 26+ pages */
    .ap-page {
        display: none !important;
    }
    .ap-page.active {
        display: block !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        overflow: visible !important;
    }

    .ap-panel {
        border: 1px solid #ccc !important;
        background: #fff !important;
        break-inside: avoid;
    }

    .ap-btn {
        display: none !important;
    }
}

/* ── 23. Inverse Design Cards ────────────────────────────────── */
.inverse-result-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--ap-bg-panel, #2a2a2a);
    border: 1px solid var(--ap-border, #3a3a3a);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 0.82rem;
}
.inverse-result-rank {
    font-weight: 700;
    color: var(--ap-accent-teal);
    min-width: 28px;
    font-size: 0.9rem;
}
.inverse-result-params, .inverse-result-gap {
    display: flex;
    gap: 12px;
}
.inverse-result-params .param-label,
.inverse-result-gap .param-label {
    color: var(--ap-text-muted);
    font-size: 0.72rem;
    display: block;
}
.inverse-result-params .param-value,
.inverse-result-gap .param-value {
    color: var(--ap-text);
    font-weight: 600;
}
.inverse-result-gap .param-value.accent {
    color: var(--ap-accent-teal);
}
.inverse-apply-btn {
    margin-left: auto;
    background: linear-gradient(180deg, #3e6e7a, #335c68);
    color: #fff;
    border: 1px solid #3a7a8a;
    border-radius: 4px;
    padding: 4px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.inverse-apply-btn:hover {
    background: linear-gradient(180deg, #4a8a96, #3e6e7a);
}
.inverse-verify-btn {
    background: linear-gradient(180deg, #6b5a2e, #5a4a22);
    color: #fbbf24;
    border: 1px solid #8a7a3a;
    border-radius: 4px;
    padding: 4px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.inverse-verify-btn:hover {
    background: linear-gradient(180deg, #8a7a3a, #6b5a2e);
}
.inverse-result-dims {
    display: flex;
    gap: 12px;
}
.inverse-result-dims .param-label {
    color: var(--ap-text-muted);
    font-size: 0.72rem;
    display: block;
}
.inverse-result-dims .param-value {
    color: #b45309;
    font-weight: 600;
}

/* ── Fabrication Summary Panel ─────────────────────────────── */
.fab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.fab-section {
    background: rgba(78,201,212,0.04);
    border: 1px solid rgba(78,201,212,0.12);
    border-radius: 6px;
    padding: 12px;
}
.fab-title {
    color: var(--ap-accent-teal);
    font-weight: 700;
    font-size: 0.82rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.fab-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.82rem;
    color: var(--ap-text-secondary);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.fab-row:last-child { border-bottom: none; }
.fab-val {
    color: var(--ap-text);
    font-weight: 600;
    font-family: "JetBrains Mono", monospace;
}
.fab-val.accent {
    color: #b45309;
}

/* ── 24. Demo/Method Toggle Buttons ──────────────────────────── */
.demo-toggle {
    background: linear-gradient(180deg, #f0f0f0, #e0e0e0);
    border: 1px solid #c0c0c0;
    border-bottom-color: #b0b0b0;
    color: var(--ap-text-secondary);
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
}
.demo-toggle:hover {
    background: linear-gradient(180deg, #f5f5f5, #e8e8e8);
    color: var(--ap-text);
}
.demo-toggle.active {
    background: linear-gradient(180deg, #4a90c4, #3a7ab5);
    border-color: #3a7ab5;
    color: #fff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15), 0 0 6px rgba(0,120,212,0.2);
}

/* ============================================================
   V2: Advanced Feature Styles
   ============================================================ */

/* Batch Results Table */
.ap-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
}
.ap-results-table th {
    background: #f0f4f8;
    color: var(--ap-accent-teal);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid var(--ap-accent-teal);
}
.ap-results-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--ap-border);
    color: var(--ap-text);
}
.ap-results-table tr:hover td {
    background: rgba(78, 201, 212, 0.08);
}
.ap-results-table .best-value {
    color: #22c55e;
    font-weight: 600;
}

/* Compare Design Chips */
.ap-design-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #fff;
    margin: 2px 4px;
}
.ap-design-chip .remove-btn {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1rem;
    line-height: 1;
}
.ap-design-chip .remove-btn:hover {
    opacity: 1;
}

/* Metric Cards (for robustness, stopband, etc.) */
.ap-metric-card {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    min-width: 120px;
}
.ap-metric-card .ap-metric-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ap-accent-teal);
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.2;
}
.ap-metric-card .ap-metric-card-label {
    font-size: 0.72rem;
    color: var(--ap-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ap-metric-card.success .ap-metric-card-value { color: #22c55e; }
.ap-metric-card.warning .ap-metric-card-value { color: #f59e0b; }
.ap-metric-card.danger  .ap-metric-card-value { color: #ef4444; }

/* Metric Cards Row */
.ap-metric-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* Code Block (for widget embed) */
.ap-code-block {
    background: #f5f7fa;
    border: 1px solid var(--ap-border);
    border-radius: 6px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: #1a6b7a;
    overflow-x: auto;
    position: relative;
    white-space: pre;
    line-height: 1.5;
}
.ap-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--ap-accent-teal);
    border: 1px solid var(--ap-accent-teal);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
}
.ap-copy-btn:hover {
    background: var(--ap-accent-highlight);
}

/* Animation canvas container */
#waveAnimCanvas {
    background: #f0f4f8;
    display: block;
}

/* Active Learning Suggestion Table */
.ap-suggestion-table {
    width: 100%;
    max-width: 600px;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.ap-suggestion-table th {
    background: #f0f4f8;
    color: var(--ap-accent-orange);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
}
.ap-suggestion-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--ap-border);
    color: var(--ap-text);
}
.ap-suggestion-table tr:hover td {
    background: rgba(235, 117, 36, 0.1);
}

/* Pareto Progress Bar */
.ap-progress-bar {
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.ap-progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #4ec9d4, #22c55e);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Session file input styling */
.ap-file-input-wrap {
    position: relative;
    display: inline-block;
}
.ap-file-input-wrap input[type="file"] {
    color: var(--ap-text);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
}

/* Report print styles */
@media print {
    .ap-toolbar, .ap-ribbon, .ap-sidebar, .ap-statusbar { display: none !important; }
    .ap-app-layout { display: block !important; }
    .ap-workspace { margin: 0 !important; padding: 0 !important; width: 100% !important; overflow: visible !important; }
    .ap-page { display: none !important; }
    .ap-page.active { display: block !important; }
    .ap-panel { break-inside: avoid; border: 1px solid #ddd; margin-bottom: 12px; }
}

/* Widget configurator form */
.ap-widget-config {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.ap-widget-config .ap-control {
    margin: 0;
}

/* Badge variants for v2 features */
.ap-badge-info {
    background: rgba(78, 201, 212, 0.15);
    color: #4ec9d4;
    border: 1px solid rgba(78, 201, 212, 0.3);
}
.ap-badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.ap-badge-warning {
    background: rgba(235, 117, 36, 0.15);
    color: #eb7524;
    border: 1px solid rgba(235, 117, 36, 0.3);
}

/* (Old dashboard-* classes removed — replaced by home-grid system) */

/* ============================================================
   GLASSMORPHISM PANEL UPGRADE
   ============================================================ */
.ap-panel {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.ap-panel:hover {
    border-color: rgba(78, 201, 212, 0.12);
}
.ap-panel-header {
    position: relative;
    padding-left: 8px;
}
.ap-panel-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, #4ec9d4, rgba(78, 201, 212, 0.2));
    border-radius: 2px;
}

/* Metric card top accent */
.ap-metric-card {
    border-top: 2px solid transparent;
    border-image: linear-gradient(90deg, #4ec9d4, rgba(78, 201, 212, 0.1)) 1;
    transition: transform 0.2s ease;
}
.ap-metric-card:hover {
    transform: translateY(-1px);
}

/* ============================================================
   ENHANCED STATUS BAR
   ============================================================ */
.ap-statusbar-timer {
    font-family: var(--ap-font-mono);
    font-size: 0.72rem;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
    padding: 1px 8px;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.ap-skeleton {
    background: linear-gradient(90deg, rgba(200,200,200,0.5) 25%, rgba(0,120,212,0.06) 50%, rgba(200,200,200,0.5) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

/* ============================================================
   ANALYZE BUTTON PULSE (when params changed)
   ============================================================ */
@keyframes analyzePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(78, 201, 212, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(78, 201, 212, 0); }
}
.ap-btn-run.needs-update {
    animation: analyzePulse 2s ease-in-out infinite;
}

/* ============================================================
   LIVE PREVIEW IN SIDEBAR
   ============================================================ */
.sidebar-preview {
    margin: 6px 0;
    padding: 0;
    position: relative;
}
.sidebar-preview-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--ap-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.sidebar-preview-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s ease-in-out infinite;
}
.sidebar-preview canvas {
    width: 100%;
    height: 130px;
    border-radius: 6px;
    border: 1px solid var(--ap-border);
    background: #f5f7fa;
}
.sidebar-preview-info {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-family: var(--ap-font-mono);
    font-size: 0.7rem;
}
.sidebar-preview-gap {
    color: #f59e0b;
    font-weight: 600;
}
.sidebar-preview-center {
    color: var(--ap-text-muted);
}
.sidebar-preview-no-gap {
    color: var(--ap-text-muted);
    font-style: italic;
}

/* ============================================================
   DESIGN HISTORY CHIPS
   ============================================================ */
.design-history {
    padding: 6px 10px;
    border-top: 1px solid var(--ap-border);
}
.design-history-title {
    font-size: 0.7rem;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.design-history-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.design-history-chip {
    font-family: var(--ap-font-mono);
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(78, 201, 212, 0.08);
    border: 1px solid rgba(78, 201, 212, 0.15);
    color: var(--ap-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.design-history-chip:hover {
    border-color: #4ec9d4;
    color: #4ec9d4;
    background: rgba(78, 201, 212, 0.15);
}

/* ============================================================
   PAGE SLIDE TRANSITION
   ============================================================ */
.ap-page.active {
    animation: slideInPage 0.3s ease;
}
@keyframes slideInPage {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   DASHBOARD v2 — Clean Modern 3D Style
   ============================================================ */
/* ============================================================
   Home / Dashboard — 3D hero + cards
   ============================================================ */
/* Sidebar module quick-access buttons */
.sidebar-module-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.sidebar-mod-btn {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 6px;
    color: var(--ap-text-secondary);
    font-size: 0.68rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 6px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-mod-btn:hover {
    background: #e0e8ef;
    border-color: var(--ap-accent-teal);
    color: var(--ap-accent-teal);
}
.sidebar-mod-btn:active {
    transform: scale(0.97);
}

.home-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
    height: 100%;
    align-content: start;
}
.home-hero {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, #0f2b3c 0%, #1a4a5e 40%, #1a6b7a 70%, #1a9ba8 100%);
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 180px;
    max-height: 220px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.home-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(78,201,212,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 30%, rgba(255,255,255,0.06) 0%, transparent 40%);
    pointer-events: none;
}
.home-hero-canvas {
    display: none;
}
.home-hero-canvas canvas {
    display: none;
}
.home-hero-overlay {
    position: relative;
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 1;
    background: none;
}
.home-hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.home-hero-sub {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.55);
    margin-top: 0;
    line-height: 1.5;
}
.home-hero-stats {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 32px 36px;
    gap: 14px;
    z-index: 1;
}
.home-hero-stat {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.home-hero-stat-val {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4ec9d4;
    letter-spacing: -0.02em;
}
.home-hero-stat-label {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.home-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
    align-content: start;
}

/* --- Module card — 3D premium raised card --- */
.hc {
    position: relative;
    padding: 28px 28px 24px;
    border-radius: 14px;
    cursor: pointer;
    background: linear-gradient(170deg, #ffffff 0%, #f7f8fa 50%, #f0f1f3 100%);
    border: 1px solid rgba(0,0,0,0.08);
    border-top: 1px solid rgba(255,255,255,0.9);
    border-left: 1px solid rgba(255,255,255,0.6);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,1),
        inset 0 -1px 0 rgba(0,0,0,0.04),
        0 1px 1px rgba(0,0,0,0.04),
        0 4px 8px rgba(0,0,0,0.06),
        0 8px 16px rgba(0,0,0,0.04),
        0 12px 0 -6px #f0f0f0,
        0 12px 1px -5px rgba(0,0,0,0.06);
    overflow: hidden;
}
.hc::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1a9ba8, #4ec9d4);
    border-radius: 14px 14px 0 0;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.hc:hover::before {
    opacity: 1;
}
.hc:hover {
    transform: translateY(-4px) scale(1.01);
    background: linear-gradient(170deg, #ffffff 0%, #fafbfc 50%, #f5f6f8 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,1),
        0 2px 4px rgba(26,155,168,0.08),
        0 8px 16px rgba(0,0,0,0.08),
        0 16px 32px rgba(0,0,0,0.06),
        0 16px 0 -8px #eeeeee,
        0 16px 1px -7px rgba(0,0,0,0.06);
}
.hc:active {
    transform: translateY(1px) scale(0.99);
    background: linear-gradient(170deg, #f5f5f5 0%, #eeeeee 100%);
    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.08),
        0 1px 2px rgba(0,0,0,0.05);
}

.hc-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #ffffff, #e8f4f6);
    margin-bottom: 16px;
    position: relative;
    box-shadow:
        6px 6px 12px rgba(26,155,168,0.12),
        -3px -3px 8px rgba(255,255,255,0.9),
        inset 0 1px 0 rgba(255,255,255,0.8),
        inset 0 -1px 2px rgba(26,155,168,0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.hc:hover .hc-icon {
    transform: translateY(-2px);
    box-shadow:
        8px 8px 16px rgba(26,155,168,0.16),
        -4px -4px 10px rgba(255,255,255,1),
        inset 0 1px 0 rgba(255,255,255,0.9),
        inset 0 -1px 2px rgba(26,155,168,0.1);
}
.hc-icon svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 2px rgba(26,107,122,0.2));
}
.hc-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ap-text);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.hc-desc {
    font-size: 0.76rem;
    color: var(--ap-text-muted);
    line-height: 1.5;
}

/* --- Quick Start section --- */
.home-qs {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 2px 0 #d0d0d0, 0 4px 8px rgba(0,0,0,0.06);
}
.home-qs-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}
.home-qs-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.hq {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px;
    background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
    border: 1px solid var(--ap-border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: 'Inter', sans-serif;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.8),
        0 3px 0 #d0d0d0,
        0 4px 8px rgba(0,0,0,0.06);
}
.hq:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.9),
        0 5px 0 #d0d0d0,
        0 8px 16px rgba(0,0,0,0.1);
}
.hq:active {
    transform: translateY(2px);
    background: linear-gradient(180deg, #e8e8e8 0%, #e0e0e0 100%);
    box-shadow:
        inset 0 2px 3px rgba(0,0,0,0.08),
        0 0 0 #d0d0d0;
}
.hq-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ap-text);
}
.hq-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    color: var(--ap-text-muted);
}

/* ============================================================
   Design History Sidebar
   ============================================================ */
.sidebar-history {
    padding: 8px 12px;
    border-top: 1px solid var(--ap-border);
}
.sidebar-history-header {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.sidebar-history-chips {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 160px;
    overflow-y: auto;
}
.history-chip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    background: rgba(0,0,0,0.02);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 2px solid transparent;
}
.history-chip:hover {
    background: rgba(0,120,212,0.06);
    border-left-color: var(--ap-accent-teal);
}
.history-chip-params {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--ap-text-secondary);
}
.history-chip-gap {
    font-size: 0.62rem;
    color: var(--ap-accent-teal);
    font-weight: 500;
}

/* ============================================================
   Breadcrumb Navigation
   ============================================================ */
.ap-toolbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.7);
    margin-left: 12px;
    flex-shrink: 1;
    overflow: hidden;
    white-space: nowrap;
}
.bc-root { color: rgba(255,255,255,0.5); }
.bc-sep { color: rgba(255,255,255,0.4); font-size: 0.9rem; }
.bc-section { color: rgba(255,255,255,0.7); }
.bc-page { color: #fff; font-weight: 500; }

.ap-toolbar-shortcut-hint {
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: color 0.2s;
}
.ap-toolbar-shortcut-hint:hover { color: #fff; }

/* ============================================================
   Status Bar Enhancement
   ============================================================ */
.ap-status-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ap-statusbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.ap-statusbar-shortcut {
    font-size: 0.68rem;
    color: var(--ap-text-muted);
    font-family: var(--ap-font-mono);
}

/* ============================================================
   Engineering Metrics Panel
   ============================================================ */
.eng-metrics-panel {
    margin-bottom: 8px;
}
.eng-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px;
}
.eng-metric {
    text-align: center;
    padding: 12px 8px;
    background: rgba(78,201,212,0.04);
    border-radius: 8px;
    border: 1px solid rgba(78,201,212,0.1);
}
.eng-metric-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ap-accent-teal);
    margin-bottom: 4px;
}
.eng-metric-label {
    font-size: 0.72rem;
    color: var(--ap-text-secondary);
    margin-bottom: 2px;
}
.eng-metric-sub {
    font-size: 0.65rem;
    color: var(--ap-text-muted);
}

/* ============================================================
   Filter Designer
   ============================================================ */
.filter-result-card {
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.filter-result-card:hover {
    border-color: rgba(78,201,212,0.3);
}
.filter-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ap-border);
}
.filter-result-rank {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ap-accent-teal);
}
.filter-result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 10px;
}
.filter-result-section {
    font-size: 0.78rem;
}
.filter-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.filter-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    color: var(--ap-text-secondary);
    font-size: 0.75rem;
}
.filter-row .accent {
    color: var(--ap-accent-teal);
    font-weight: 600;
}
.filter-result-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--ap-border);
}

/* ============================================================
   Glassmorphism Panel Enhancement
   ============================================================ */
.ap-panel {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 0.3s, box-shadow 0.3s;
}
.ap-panel:hover {
    border-color: rgba(0,120,212,0.2);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.5);
}

/* ============================================================
   Page Transitions
   ============================================================ */
.ap-page {
    animation: pageSlideIn 0.25s ease-out;
}
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Analyze Button Pulse
   ============================================================ */
.ap-btn-run.needs-update {
    animation: analyzePulse 1.5s ease-in-out infinite;
}
@keyframes analyzePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(78,201,212,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(78,201,212,0); }
}

/* ============================================================
   Keyboard Shortcut Styles
   ============================================================ */
kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--ap-text);
    background: #f0f0f0;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    box-shadow: 0 1px 0 #b0b0b0;
}

/* ============================================================
   Skeleton Loading Shimmer
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================================
   Metric Value Counter Animation
   ============================================================ */
.ap-metric-value {
    transition: color 0.3s;
}
.metric-updated {
    animation: metricFlash 0.5s ease;
}
@keyframes metricFlash {
    0% { color: #fff; transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ============================================================
   Badge Variants
   ============================================================ */
.ap-badge-success {
    background: rgba(34,197,94,0.15) !important;
    color: #22c55e !important;
    border: 1px solid rgba(34,197,94,0.3);
}
.ap-badge-warning {
    background: rgba(245,158,11,0.15) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245,158,11,0.3);
}
.ap-badge-danger {
    background: rgba(239,68,68,0.15) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239,68,68,0.3);
}

/* ============================================================
   Topological Acoustics
   ============================================================ */
.topo-indicators-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
}
.topo-card {
    flex: 1;
    min-width: 120px;
    background: var(--ap-bg-panel);
    border: 1px solid var(--ap-border);
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}
.topo-card .topo-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ap-accent-teal);
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1.2;
}
.topo-card .topo-card-label {
    font-size: 0.72rem;
    color: var(--ap-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.topo-card.topo-nontrivial {
    border-color: var(--ap-accent-teal);
    background: rgba(26,107,122,0.06);
}
.topo-card.topo-nontrivial .topo-card-value {
    color: var(--ap-accent-teal);
}
.topo-card.topo-trivial {
    border-color: var(--ap-border);
}
.topo-card.topo-trivial .topo-card-value {
    color: var(--ap-text-muted);
}
/* ML Topology prediction cards */
.topo-ml-card {
    flex: 1;
    min-width: 110px;
    max-width: 180px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.15s;
}
.topo-ml-card:hover { transform: translateY(-2px); box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.topo-ml-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a9ba8;
    font-family: 'Space Grotesk', monospace;
    line-height: 1.3;
}
.topo-ml-label {
    font-size: 0.68rem;
    color: #6b7280;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.topo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.topo-table th {
    background: #f0f4f8;
    color: var(--ap-accent-teal);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--ap-accent-teal);
}
.topo-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--ap-border);
    color: var(--ap-text);
}
.topo-table tr:hover td {
    background: rgba(26,107,122,0.04);
}
.topo-row-highlight {
    font-weight: 600;
    color: var(--ap-accent-teal) !important;
}
.ap-status-text {
    font-size: 0.82rem;
    color: var(--ap-text-secondary);
    margin: 8px 0;
}
.ap-hint-text {
    font-size: 0.75rem;
    color: var(--ap-text-muted);
    font-style: italic;
    margin: 4px 0;
}
.ap-label-text {
    font-size: 0.72rem;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* ============================================================
   Responsive: smaller screens
   ============================================================ */
@media (max-width: 1200px) {
    .home-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .home-qs-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .filter-result-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .eng-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   Chat-style Inverse Designer
   ============================================================ */
#chatDesigner .chat-feed {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 10px;
  height: 220px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 8px;
}
#chatDesigner .chat-msg {
  display: flex;
  margin: 6px 0;
}
#chatDesigner .chat-you  { justify-content: flex-end; }
#chatDesigner .chat-bot  { justify-content: flex-start; }
#chatDesigner .chat-bubble {
  max-width: 78%;
  padding: 7px 10px;
  border-radius: 8px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
}
#chatDesigner .chat-you .chat-bubble {
  background: #134e4a;
  border-color: #0f766e;
  color: #ccfbf1;
}
#chatDesigner .chat-who {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 2px;
  font-weight: 600;
}
#chatDesigner .chat-you .chat-who { color: #5eead4; }
#chatDesigner .chat-tip {
  display: inline-block;
  font-size: 0.74rem;
  color: #94a3b8;
  font-style: italic;
}
#chatDesigner .chat-inputrow {
  display: flex;
  gap: 6px;
}
#chatDesigner .chat-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 7px 10px;
}
#chatDesigner .chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
#chatDesigner .chat-chip {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
}
#chatDesigner .chat-chip:hover {
  background: #134e4a;
  border-color: #0f766e;
  color: #ccfbf1;
}

/* Smart-chat (WebLLM) lazy-loader UI */
#chatDesigner .smart-chat-bar {
  margin-top: 8px;
  padding: 8px 10px;
  background: #0b1220;
  border: 1px dashed #334155;
  border-radius: 6px;
  font-size: 0.78rem;
}
#chatDesigner .smart-chat-btn {
  background: #1e293b;
  color: #5eead4;
  border: 1px solid #0f766e;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  margin-right: 8px;
}
#chatDesigner .smart-chat-btn:hover:not(:disabled) {
  background: #134e4a;
}
#chatDesigner .smart-chat-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
#chatDesigner .smart-chat-btn.smart-chat-active {
  color: #86efac;
  border-color: #16a34a;
  background: #14532d;
}
#chatDesigner .smart-chat-note {
  color: #94a3b8;
  font-style: italic;
}
#chatDesigner .smart-chat-progress {
  margin-top: 8px;
}
#chatDesigner .smart-chat-bar-fill {
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #334155;
}
#chatDesigner #smartChatBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #14b8a6, #5eead4);
  transition: width 0.25s ease;
}
#chatDesigner .smart-chat-progress-text {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================================
   Chat Designer v2 — light, modern, two-column layout
   ============================================================ */
#chatDesigner.chat-light {
  background: #475569;                       /* slate-600 — clearly its own block */
  border: 1px solid #334155;                 /* slate-700 border */
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
  padding: 0;
  overflow: hidden;
  /* Span the full width of the inverse-design page container. */
  width: 100%;
  margin: 0 0 16px;
}
#chatDesigner.chat-light .chat-header {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);  /* slate-700 → slate-800 */
  color: #f1f5f9;
  padding: 12px 16px;
  border-bottom: 1px solid #0f172a;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
#chatDesigner.chat-light .chat-subhead { color: #cbd5e1; }
#chatDesigner.chat-light .chat-left   { background: #475569; border-right-color: #334155; }
#chatDesigner.chat-light .chat-right  { background: #3f4a5e; }
#chatDesigner.chat-light .chat-right-header { color: #cbd5e1; }
#chatDesigner.chat-light .smart-chat-bar { background: #3f4a5e; border-color: #64748b; }
#chatDesigner.chat-light .smart-chat-note { color: #cbd5e1; }
#chatDesigner.chat-light .smart-chat-icon { vertical-align: -2px; margin-right: 4px; }
#chatDesigner.chat-light .chat-subhead {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 400;
  font-style: italic;
}
#chatDesigner.chat-light .chat-split,
#chatDesigner.chat-light .chat-single {
  display: block;
  min-height: 65vh;
}
#chatDesigner.chat-light .chat-left {
  padding: 14px;
  display: flex;
  flex-direction: column;
  border-right: none;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
}
#chatDesigner.chat-light .chat-right {
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}
#chatDesigner.chat-light .chat-right-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 10px;
}
#chatDesigner.chat-light .chat-feed {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px;
  flex: 1;
  min-height: 0;                             /* let flex shrink to fill column */
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 10px;
}
#chatDesigner.chat-light .chat-msg {
  display: flex;
  margin: 6px 0;
}
#chatDesigner.chat-light .chat-you  { justify-content: flex-end; }
#chatDesigner.chat-light .chat-bot  { justify-content: flex-start; }
#chatDesigner.chat-light .chat-bubble {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
#chatDesigner.chat-light .chat-you .chat-bubble {
  background: #14b8a6;
  border-color: #0d9488;
  color: #ffffff;
}
#chatDesigner.chat-light .chat-who {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 3px;
  font-weight: 600;
}
#chatDesigner.chat-light .chat-you .chat-who { color: rgba(255,255,255,0.85); }
#chatDesigner.chat-light .chat-tip {
  display: inline-block;
  font-size: 0.74rem;
  color: #64748b;
  font-style: italic;
}
#chatDesigner.chat-light .chat-you .chat-tip { color: rgba(255,255,255,0.85); }
#chatDesigner.chat-light .chat-inputrow {
  display: flex;
  gap: 6px;
}
#chatDesigner.chat-light .chat-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
#chatDesigner.chat-light .chat-input:focus {
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20,184,166,0.15);
}
#chatDesigner.chat-light .chat-send-btn {
  background: #0d9488;
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
#chatDesigner.chat-light .chat-send-btn:hover { background: #0f766e; }
#chatDesigner.chat-light .chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
#chatDesigner.chat-light .chat-chip {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
}
#chatDesigner.chat-light .chat-chip:hover {
  background: #f0fdfa;
  border-color: #14b8a6;
  color: #0f766e;
}

/* Smart-chat lazy-loader (light) */
#chatDesigner.chat-light .smart-chat-bar {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  font-size: 0.78rem;
}
#chatDesigner.chat-light .smart-chat-btn {
  background: #ffffff;
  color: #0f766e;
  border: 1px solid #14b8a6;
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  margin-right: 6px;
}
#chatDesigner.chat-light .smart-chat-btn:hover:not(:disabled) {
  background: #f0fdfa;
}
#chatDesigner.chat-light .smart-chat-btn:disabled { opacity: 0.7; cursor: not-allowed; }
#chatDesigner.chat-light .smart-chat-btn.smart-chat-active {
  color: #ffffff;
  background: #14b8a6;
  border-color: #0d9488;
}
#chatDesigner.chat-light .smart-chat-disable {
  color: #ef4444;
  border-color: #fca5a5;
}
#chatDesigner.chat-light .smart-chat-disable:hover { background: #fef2f2; }
#chatDesigner.chat-light .smart-chat-note {
  color: #64748b;
  font-style: italic;
}
#chatDesigner.chat-light #smartChatBarFill {
  background: linear-gradient(90deg, #14b8a6, #0d9488);
}
#chatDesigner.chat-light .smart-chat-progress-text { color: #64748b; }

/* Right-pane design preview */
#chatDesigner.chat-light .chat-design-preview {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
#chatDesigner.chat-light .chat-empty {
  color: #94a3b8;
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
  margin: auto 0;
}
#chatDesigner.chat-light .preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
#chatDesigner.chat-light .preview-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
#chatDesigner.chat-light .preview-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  font-weight: 600;
}
#chatDesigner.chat-light .preview-value {
  font-size: 1.05rem;
  color: #0f172a;
  font-weight: 600;
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
#chatDesigner.chat-light .preview-unit {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-left: 3px;
  font-weight: 400;
}
#chatDesigner.chat-light .preview-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.85rem;
}
#chatDesigner.chat-light .preview-row:last-of-type { border-bottom: none; }
#chatDesigner.chat-light .preview-row .preview-label {
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  color: #64748b;
  font-weight: 500;
}
#chatDesigner.chat-light .preview-accent {
  color: #0d9488;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
#chatDesigner.chat-light .preview-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}
#chatDesigner.chat-light .preview-btn {
  flex: 1;
  background: #ffffff;
  color: #0f766e;
  border: 1px solid #14b8a6;
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#chatDesigner.chat-light .preview-btn:hover { background: #f0fdfa; }
#chatDesigner.chat-light .preview-btn-primary {
  background: #0d9488;
  color: #ffffff;
  border-color: #0d9488;
}
#chatDesigner.chat-light .preview-btn-primary:hover { background: #0f766e; }

/* Stack columns on narrow screens */
@media (max-width: 760px) {
  #chatDesigner.chat-light .chat-split {
    grid-template-columns: 1fr;
  }
  #chatDesigner.chat-light .chat-left { border-right: none; border-bottom: 1px solid #e2e8f0; }
}

/* Voice-input mic button (chat) */
#chatDesigner.chat-light .chat-mic-btn {
  background: #f1f5f9;
  color: #0d9488;
  border: 1px solid #cbd5e1;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#chatDesigner.chat-light .chat-mic-btn:hover:not(:disabled) {
  background: #ccfbf1;
  border-color: #14b8a6;
}
#chatDesigner.chat-light .chat-mic-btn.chat-mic-active {
  background: #ef4444;
  border-color: #b91c1c;
  color: #ffffff;
  animation: chatMicPulse 1.2s ease-in-out infinite;
}
@keyframes chatMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Image-upload button (chat) — same style as mic */
#chatDesigner.chat-light .chat-upload-btn {
  background: #f1f5f9;
  color: #0d9488;
  border: 1px solid #cbd5e1;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#chatDesigner.chat-light .chat-upload-btn:hover:not(:disabled) {
  background: #ccfbf1;
  border-color: #14b8a6;
}

/* Inline design-card inside the chat feed (replaces the right pane) */
#chatDesigner.chat-light .chat-design-card { max-width: 92%; min-width: 360px; }
#chatDesigner.chat-light .chat-design-card .preview-grid {
  grid-template-columns: repeat(3, 1fr);
  margin: 6px 0 4px;
}
#chatDesigner.chat-light .chat-design-card .preview-actions { flex-wrap: wrap; }
#chatDesigner.chat-light .chat-design-card .preview-btn {
  flex: 1 1 auto;
  min-width: 110px;
  font-size: 0.74rem;
  padding: 7px 10px;
}
#chatDesigner.chat-light .chat-design-card .chat-bandplot-slot { margin-top: 0; }

/* Persistent action menu (below chat input) — operates on the latest design */
#chatDesigner.chat-light .chat-actionbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid #0f172a;
  border-radius: 6px;
}
#chatDesigner.chat-light .chat-actionbar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 600;
  margin-right: 4px;
}
#chatDesigner.chat-light .chat-action-btn {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 5px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#chatDesigner.chat-light .chat-action-btn:hover { background: #475569; border-color: #64748b; color: #f1f5f9; }
#chatDesigner.chat-light .chat-action-primary {
  background: #14b8a6;
  border-color: #0d9488;
  color: #ffffff;
}
#chatDesigner.chat-light .chat-action-primary:hover { background: #0d9488; border-color: #0f766e; }
