:root {
      --bg: #f6f8fb;
      --card: rgba(255, 255, 255, 0.92);
      --text: #152033;
      --muted: #65758b;
      --line: #dbe3ef;
      --primary: #2563eb;
      --primary-weak: #eaf1ff;
      --danger: #dc2626;
      --danger-bg: #fff1f2;
      --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
      --radius: 22px;
      --focus: 0 0 0 4px rgba(37, 99, 235, 0.14);
    }

    * { box-sizing: border-box; }

    html { scroll-behavior: smooth; }

    body {
      margin: 0;
      min-height: 100vh;
      color: var(--text);
      font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
      background:
        radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.12), transparent 30%),
        radial-gradient(circle at 86% 16%, rgba(20, 184, 166, 0.12), transparent 28%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
    }

    .app {
      width: min(100%, 1060px);
      margin: 0 auto;
      padding: 22px 14px 34px;
    }

    .hero {
      margin: 10px 0 18px;
      text-align: center;
    }

    .hero h1 {
      margin: 0;
      font-size: clamp(1.7rem, 5vw, 3.2rem);
      letter-spacing: -0.045em;
      line-height: 1.1;
    }

    .hero p {
      max-width: 740px;
      margin: 12px auto 0;
      color: var(--muted);
      font-size: 0.98rem;
      line-height: 1.7;
    }

    .panel {
      margin-top: 18px;
      padding: 18px;
      border: 1px solid rgba(219, 227, 239, 0.78);
      border-radius: var(--radius);
      background: var(--card);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
      transition: transform 180ms ease, box-shadow 180ms ease;
    }

    .panel:hover { box-shadow: 0 22px 58px rgba(15, 23, 42, 0.13); }

    .panel-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }

    .panel-title h2 {
      margin: 0;
      font-size: 1.02rem;
      letter-spacing: -0.015em;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 10px;
      border-radius: 999px;
      color: #0f766e;
      background: #e6fffb;
      font-size: 0.78rem;
      font-weight: 700;
      white-space: nowrap;
    }

    math-field {
      display: block;
      width: 100%;
      min-height: 76px;
      padding: 16px 18px;
      border: 1px solid var(--line);
      border-radius: 18px;
      background: #ffffff;
      color: var(--text);
      font-size: clamp(1.25rem, 4vw, 1.9rem);
      box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
      transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
    }

    math-field:focus-within {
      border-color: var(--primary);
      box-shadow: var(--focus);
    }

    math-field::part(menu-toggle),
    math-field::part(menu-toggle-button),
    math-field::part(menu-button) {
      display: none !important;
    }

    .hint {
      margin: 10px 2px 8px;
      color: var(--muted);
      font-size: 0.86rem;
      line-height: 1.55;
    }

    .formula-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 12px;
    }

    .input-mode-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }

    .input-mode-tabs {
      display: inline-flex;
      gap: 6px;
      padding: 5px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: rgba(248, 250, 252, 0.78);
    }

    .input-mode-btn {
      min-height: 34px;
      padding: 0 13px;
      border-radius: 999px;
      background: transparent;
      color: var(--muted);
      box-shadow: none;
      font-size: 0.82rem;
      font-weight: 900;
    }

    .input-mode-btn.is-active {
      color: var(--primary);
      background: var(--primary-weak);
      box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
    }

    .input-mode-note {
      margin: 0;
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.45;
    }

    .formula-understanding {
      display: grid;
      gap: 4px;
      margin: 8px 2px 0;
      padding: 8px 10px;
      border: 1px solid rgba(37, 99, 235, 0.20);
      border-radius: 14px;
      background: rgba(234, 241, 255, 0.58);
      color: #1e3a8a;
      font-size: 0.86rem;
      line-height: 1.45;
    }

    .formula-understanding.is-empty {
      display: none;
    }

    .formula-understanding.is-warning {
      border-color: rgba(217, 119, 6, 0.26);
      background: rgba(255, 251, 235, 0.78);
      color: #92400e;
    }

    .formula-understanding.is-error {
      border-color: rgba(220, 38, 38, 0.22);
      background: var(--danger-bg);
      color: var(--danger);
    }

    .formula-understanding-title {
      font-size: 0.76rem;
      font-weight: 900;
      letter-spacing: 0.02em;
      opacity: 0.8;
    }

    .formula-understanding-main {
      font-weight: 900;
      word-break: break-word;
    }

    .formula-understanding-detail {
      color: inherit;
      opacity: 0.78;
      font-size: 0.78rem;
      word-break: break-word;
    }

    .formula-input-wrap.is-hidden { display: none; }

    .plain-formula-input {
      display: block;
      width: 100%;
      min-height: 76px;
      resize: vertical;
      padding: 18px 20px;
      border: 1px solid var(--line);
      border-radius: 18px;
      outline: none;
      background: #ffffff;
      color: var(--text);
      font: 800 clamp(1.05rem, 3.4vw, 1.55rem) / 1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
      transition: border-color 160ms ease, box-shadow 160ms ease;
    }

    .plain-formula-input:focus {
      border-color: var(--primary);
      box-shadow: var(--focus);
    }

    .plain-formula-input::placeholder {
      color: #a4afbd;
      font-weight: 700;
    }

    .function-list {
      display: grid;
      gap: 8px;
      margin-top: 12px;
    }

    .function-list:empty { display: none; }

    .function-item {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto auto auto;
      align-items: center;
      gap: 8px;
      padding: 9px 10px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
    }

    .function-color {
      width: 12px;
      height: 12px;
      border-radius: 999px;
      box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
    }

    .function-expression {
      min-width: 0;
      min-height: 32px;
      overflow: hidden;
      padding: 0 8px;
      color: #334155;
      font-size: 0.88rem;
      font-weight: 800;
      text-align: left;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .function-meta {
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 800;
    }

    .function-toggle,
    .function-delete {
      min-height: 32px;
      padding: 0 10px;
      border-radius: 10px;
      box-shadow: none;
      font-size: 0.78rem;
    }

    .function-toggle {
      color: var(--primary);
      background: var(--primary-weak);
    }

    .function-toggle.is-hidden {
      color: var(--muted);
      background: #f1f5f9;
    }

    .function-delete {
      color: var(--danger);
      background: var(--danger-bg);
    }

    .error {
      min-height: 23px;
      margin: 10px 2px 0;
      color: var(--danger);
      font-size: 0.91rem;
      line-height: 1.45;
      opacity: 0;
      transform: translateY(-3px);
      transition: opacity 160ms ease, transform 160ms ease;
    }

    .error.show {
      opacity: 1;
      transform: translateY(0);
      padding: 8px 10px;
      border-radius: 12px;
      background: var(--danger-bg);
    }

    .tabs {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin-top: 14px;
    }

    .tab-option input { position: absolute; opacity: 0; pointer-events: none; }

    .tab-option span {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 46px;
      border: 1px solid var(--line);
      border-radius: 15px;
      color: var(--muted);
      background: #fff;
      font-weight: 800;
      cursor: pointer;
      transition: all 160ms ease;
      user-select: none;
    }

    .tab-option input:checked + span {
      color: var(--primary);
      border-color: rgba(37, 99, 235, 0.42);
      background: var(--primary-weak);
      box-shadow: var(--focus);
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
    }

    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .range-control-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 12px;
    }

    .visual-control-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: end;
    }

    .range-group {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      align-items: end;
    }

    .range-group.is-hidden {
      display: none;
    }

    .control-group-title {
      grid-column: 1 / -1;
      margin: 0 0 -2px;
      color: #334155;
      font-size: 0.82rem;
      font-weight: 900;
      letter-spacing: 0.01em;
    }

    .field label {
      color: var(--muted);
      font-size: 0.82rem;
      font-weight: 800;
    }

    .field input,
    .field select {
      width: 100%;
      min-height: 40px;
      padding: 9px 11px;
      border: 1px solid var(--line);
      border-radius: 13px;
      outline: none;
      background: #fff;
      color: var(--text);
      font: inherit;
      transition: border-color 160ms ease, box-shadow 160ms ease;
    }

    .field input:focus,
    .field select:focus {
      border-color: var(--primary);
      box-shadow: var(--focus);
    }

    .field input::placeholder { color: #a4afbd; }

    .workspace {
      display: grid;
      grid-template-columns: 1fr;
      gap: 18px;
      align-items: start;
    }

    .controls {
      display: grid;
      grid-template-columns: 1fr;
      gap: 18px;
    }

    .subtle-card {
      padding: 13px;
      border: 1px solid rgba(219, 227, 239, 0.82);
      border-radius: 18px;
      background: rgba(248, 250, 252, 0.68);
    }

    .subtle-card h3 {
      margin: 0 0 10px;
      font-size: 0.92rem;
      color: #334155;
    }

    .actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 14px;
    }

    button {
      min-height: 44px;
      padding: 0 16px;
      border: 0;
      border-radius: 14px;
      background: var(--primary);
      color: #fff;
      font-weight: 900;
      cursor: pointer;
      box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
      transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
    }

    button:hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(37, 99, 235, 0.27); }
    button:active { transform: translateY(0); filter: brightness(0.96); }

    .ghost-btn {
      color: var(--primary);
      background: var(--primary-weak);
      box-shadow: none;
    }



    .control-hint {
      margin: 8px 2px 0;
      font-size: 0.78rem;
    }


    .mobile-controls-header {
      display: none;
    }

    .accordion-trigger {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      min-height: auto;
      margin: 0 0 10px;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: #334155;
      box-shadow: none;
      text-align: left;
      cursor: default;
      transform: none;
    }

    .accordion-trigger:hover,
    .accordion-trigger:active {
      transform: none;
      box-shadow: none;
      filter: none;
    }

    .accordion-title {
      min-width: 0;
      color: #334155;
      font-size: 0.92rem;
      font-weight: 900;
      letter-spacing: -0.01em;
    }

    .accordion-summary,
    .accordion-icon {
      display: none;
    }

    .accordion-content {
      display: block;
    }


    .formula-shortcuts {
      display: flex;
      gap: 8px;
      margin: 10px 2px 0;
      overflow-x: auto;
      padding: 0 0 4px;
      scrollbar-width: thin;
    }

    .formula-chip {
      flex: 0 0 auto;
      min-height: 34px;
      padding: 0 11px;
      border: 1px solid var(--line);
      border-radius: 999px;
      color: #334155;
      background: #fff;
      box-shadow: none;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      font-size: 0.78rem;
      font-weight: 900;
      white-space: nowrap;
    }

    .formula-chip:hover {
      color: var(--primary);
      border-color: rgba(37, 99, 235, 0.34);
      background: var(--primary-weak);
      box-shadow: none;
    }

    .mobile-controls-actions,
    .mobile-quick-scroll,
    .status-details-toggle,
    .mobile-bottom-actionbar,
    .mobile-more-sheet {
      display: none;
    }

    .analysis-group-label {
      display: none;
    }

    .plot-card {
      overflow: hidden;
      padding: 16px;
      touch-action: pan-y;
    }

    .plot-card > :not(#plot),
    .plot-header,
    .plot-header * {
      touch-action: pan-y;
    }

    .plot-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .plot-header h2 {
      margin: 0;
      font-size: 1.02rem;
      letter-spacing: -0.015em;
    }

    #plot {
      width: 100%;
      min-height: 430px;
      border-radius: 18px;
      background: #fff;
      touch-action: pan-y;
    }

    #plot.polar-plot {
      aspect-ratio: 1 / 1;
      min-height: 0;
      height: auto;
      max-height: min(72vh, 720px);
    }

    #plot.dark-plot {
      background: #0b1120;
    }

    #plot .plotly,
    #plot .svg-container,
    #plot .main-svg,
    #plot .draglayer {
      touch-action: pan-y;
    }

    #plot.polar-plot,
    #plot.polar-plot .plotly,
    #plot.polar-plot .svg-container,
    #plot.polar-plot .main-svg,
    #plot.polar-plot .draglayer,
    #plot.polar-plot .polar,
    #plot.polar-plot .polarlayer,
    #plot.polar-plot .polarsublayer,
    #plot.polar-plot .angularaxislayer,
    #plot.polar-plot .radialaxislayer,
    #plot.polar-plot .scatterlayer {
      touch-action: none;
    }

    #plot .nsewdrag,
    #plot .gl-container,
    #plot .gl-canvas,
    #plot canvas {
      touch-action: none;
    }

    #plot.empty-plot,
    #plot.empty-plot .plotly,
    #plot.empty-plot .svg-container,
    #plot.empty-plot .main-svg,
    #plot.empty-plot .draglayer,
    #plot.empty-plot .nsewdrag,
    #plot.empty-plot .gl-container,
    #plot.empty-plot .gl-canvas,
    #plot.empty-plot .polar,
    #plot.empty-plot .polarlayer,
    #plot.empty-plot .polarsublayer,
    #plot.empty-plot .angularaxislayer,
    #plot.empty-plot .radialaxislayer,
    #plot.empty-plot .scatterlayer,
    #plot.empty-plot canvas {
      touch-action: pan-y !important;
    }

    .status-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
      color: var(--muted);
      font-size: 0.84rem;
    }

    .status-pill {
      padding: 6px 9px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: #fff;
    }



    .mini-btn,
    .file-btn {
      min-height: 38px;
      padding: 0 12px;
      border-radius: 12px;
      box-shadow: none;
      font-size: 0.82rem;
    }

    .file-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: var(--primary);
      background: var(--primary-weak);
      font-weight: 900;
      cursor: pointer;
      transition: transform 150ms ease, filter 150ms ease;
    }

    .file-btn:hover { transform: translateY(-1px); }
    .hidden-file-input { display: none; }

    .mini-btn:disabled,
    .file-btn.is-disabled {
      cursor: not-allowed;
      opacity: 0.48;
      transform: none;
      filter: grayscale(0.1);
    }

    .preset-card h3 {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .template-toolbar {
      display: grid;
      gap: 10px;
      margin-top: 12px;
    }

    .template-search {
      width: 100%;
      min-height: 40px;
      padding: 9px 12px;
      border: 1px solid var(--line);
      border-radius: 14px;
      outline: none;
      background: #fff;
      color: var(--text);
      font: inherit;
      transition: border-color 160ms ease, box-shadow 160ms ease;
    }

    .template-search:focus {
      border-color: var(--primary);
      box-shadow: var(--focus);
    }

    .template-category-bar {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding-bottom: 2px;
      scrollbar-width: thin;
    }

    .template-category-btn {
      flex: 0 0 auto;
      min-height: 34px;
      padding: 0 11px;
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      background: #fff;
      box-shadow: none;
      font-size: 0.78rem;
      white-space: nowrap;
    }

    .template-category-btn.is-active {
      color: var(--primary);
      border-color: rgba(37, 99, 235, 0.38);
      background: var(--primary-weak);
    }

    .template-count {
      margin-top: 8px;
      color: var(--muted);
      font-size: 0.76rem;
      font-weight: 800;
    }

    .preset-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 10px;
    }

    .preset-button {
      position: relative;
      display: grid;
      gap: 8px;
      min-height: 138px;
      padding: 12px;
      text-align: left;
      color: #334155;
      background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
      border: 1px solid var(--line);
      border-radius: 16px;
      box-shadow: none;
    }

    .preset-button:hover {
      color: var(--primary);
      border-color: rgba(37, 99, 235, 0.34);
      background: var(--primary-weak);
      box-shadow: none;
    }

    .preset-topline {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }

    .preset-name {
      display: block;
      min-width: 0;
      font-size: 0.86rem;
      font-weight: 900;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .preset-kind {
      flex: 0 0 auto;
      padding: 3px 7px;
      border-radius: 999px;
      color: var(--primary);
      background: var(--primary-weak);
      font-size: 0.68rem;
      font-weight: 900;
    }

    .preset-preview {
      display: flex;
      align-items: center;
      min-height: 36px;
      padding: 8px 10px;
      border: 1px dashed rgba(148, 163, 184, 0.52);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.72);
      color: #0f172a;
      font: 900 0.85rem/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
      overflow: hidden;
    }

    .preset-description {
      color: var(--muted);
      font-size: 0.75rem;
      line-height: 1.45;
    }

    .preset-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      color: var(--muted);
      font-size: 0.7rem;
      font-weight: 800;
    }

    .preset-tag {
      padding: 3px 6px;
      border-radius: 999px;
      background: #eef2f7;
    }

    .preset-empty {
      grid-column: 1 / -1;
      padding: 14px;
      border: 1px dashed var(--line);
      border-radius: 16px;
      color: var(--muted);
      background: rgba(248, 250, 252, 0.74);
      font-size: 0.82rem;
      line-height: 1.5;
      text-align: center;
    }

    .parameter-card.is-empty .parameter-list { display: none; }

    .parameter-list {
      display: grid;
      gap: 10px;
      margin-top: 12px;
    }

    .parameter-item {
      display: grid;
      grid-template-columns: minmax(42px, 0.45fr) minmax(110px, 1.2fr) minmax(76px, 0.65fr);
      gap: 8px;
      align-items: center;
      padding: 9px 10px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
    }

    .parameter-name {
      color: #334155;
      font-size: 0.9rem;
      font-weight: 900;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .parameter-item input[type="range"] { width: 100%; }

    .parameter-value {
      min-height: 36px;
      padding: 7px 9px;
      border: 1px solid var(--line);
      border-radius: 11px;
      font: inherit;
      font-size: 0.86rem;
    }

    .analysis-card .analysis-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 12px;
    }

    .analysis-card .analysis-actions button {
      flex: 1 1 112px;
      box-shadow: none;
    }

    .analysis-input-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
      margin-top: 12px;
    }

    .analysis-results {
      display: grid;
      gap: 8px;
      margin-top: 12px;
    }

    .analysis-result {
      padding: 10px 11px;
      border: 1px solid var(--line);
      border-radius: 14px;
      background: #fff;
      color: #334155;
      font-size: 0.84rem;
      line-height: 1.55;
    }

    .analysis-result strong {
      display: block;
      margin-bottom: 4px;
      color: var(--text);
      font-size: 0.88rem;
    }

    .analysis-result code {
      padding: 2px 5px;
      border-radius: 6px;
      background: #f1f5f9;
      color: #0f172a;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 0.78rem;
    }

    .analysis-muted {
      color: var(--muted);
      font-size: 0.8rem;
    }

    .plot-actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 8px;
    }

    .export-select {
      min-height: 38px;
      max-width: 180px;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: #fff;
      color: var(--text);
      font: inherit;
      font-size: 0.82rem;
      font-weight: 800;
      outline: none;
    }

    .export-select:focus {
      border-color: var(--primary);
      box-shadow: var(--focus);
    }

    .plot-actions button:disabled {
      cursor: wait;
      opacity: 0.68;
      transform: none;
      filter: grayscale(0.1);
    }

    .status-pill.is-good {
      border-color: rgba(16, 185, 129, 0.28);
      color: #047857;
      background: #ecfdf5;
    }

    .status-pill.is-warn {
      border-color: rgba(245, 158, 11, 0.32);
      color: #92400e;
      background: #fffbeb;
    }


    @media (max-width: 800px) {
      .controls {
        gap: 10px;
        margin-top: 12px;
        padding: 12px;
      }

      .mobile-controls-header {
        position: sticky;
        top: 8px;
        z-index: 6;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin: -2px 0 2px;
        padding: 12px;
        border: 1px solid rgba(219, 227, 239, 0.88);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 14px 32px rgba(15, 23, 42, 0.09);
        backdrop-filter: blur(14px);
      }

      .mobile-controls-header h2 {
        margin: 2px 0 0;
        color: var(--text);
        font-size: 1rem;
        letter-spacing: -0.02em;
      }

      .mobile-controls-header p {
        margin: 4px 0 0;
        color: var(--muted);
        font-size: 0.76rem;
        line-height: 1.35;
      }

      .mobile-controls-kicker {
        color: var(--primary);
        font-size: 0.72rem;
        font-weight: 900;
        letter-spacing: 0.06em;
      }

      #toggleAllAdvancedBtn {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 0 11px;
        white-space: nowrap;
      }

      .collapsible-card {
        overflow: hidden;
        padding: 0;
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.86);
      }

      .accordion-trigger {
        min-height: 52px;
        margin: 0;
        padding: 12px 13px;
        border-radius: 18px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
      }

      .accordion-trigger:focus-visible {
        outline: none;
        box-shadow: var(--focus);
      }

      .accordion-title {
        font-size: 0.9rem;
      }

      .accordion-summary {
        display: inline-flex;
        flex: 1 1 auto;
        justify-content: flex-end;
        min-width: 0;
        margin-left: 8px;
        overflow: hidden;
        color: var(--muted);
        font-size: 0.74rem;
        font-weight: 800;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .accordion-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 24px;
        height: 24px;
        margin-left: 8px;
        border-radius: 999px;
        color: var(--primary);
        background: var(--primary-weak);
        font-size: 0.9rem;
        font-weight: 900;
        transition: transform 160ms ease;
      }

      .collapsible-card:not(.is-open) .accordion-icon {
        transform: rotate(-90deg);
      }

      .collapsible-card:not(.is-open) .accordion-content {
        display: none;
      }

      .accordion-content {
        padding: 0 13px 13px;
      }

      .accordion-content > .hint:first-child,
      .accordion-content > .range-control-grid:first-child,
      .accordion-content > .grid:first-child {
        margin-top: 0;
      }

      .mobile-controls-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        flex: 0 0 auto;
      }

      .mobile-controls-actions button {
        min-height: 34px;
        padding: 0 10px;
        white-space: nowrap;
      }

      .mobile-quick-scroll {
        display: inline-flex;
      }

      .formula-actions #shareBtn,
      .formula-actions #exportConfigBtn,
      .formula-actions .file-btn,
      .formula-actions #resetProjectBtn {
        display: none;
      }

      .formula-actions #addFunctionBtn {
        flex: 1 1 100%;
      }

      .plot-actions {
        display: none;
      }

      .plot-header {
        margin-bottom: 8px;
      }

      .status-row {
        align-items: center;
        gap: 6px;
      }

      .status-details-toggle {
        display: inline-flex;
        min-height: 30px;
        padding: 0 9px;
        border-radius: 999px;
        font-size: 0.74rem;
      }

      .status-row:not(.is-expanded) .status-pill:not(#computeStatus) {
        display: none;
      }

      .status-row #computeStatus {
        order: -1;
      }

      .analysis-actions {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
      }

      .analysis-group-label {
        display: block;
        grid-column: 1 / -1;
        margin: 3px 0 -2px;
        color: var(--muted);
        font-size: 0.74rem;
        font-weight: 900;
      }

      .analysis-card .analysis-actions button {
        flex-basis: auto;
        width: 100%;
        padding-inline: 8px;
      }

      .analysis-card .analysis-actions #clearAnalysisBtn {
        grid-column: 1 / -1;
      }

      .mobile-bottom-actionbar {
        position: fixed;
        left: max(16px, env(safe-area-inset-left));
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        z-index: 30;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        padding: 10px;
        border: 1px solid rgba(255, 255, 255, 0.4);
        border-top-color: rgba(255, 255, 255, 0.8);
        border-radius: 24px;
        background: rgba(255, 255, 255, 0.85);
        box-shadow: 0 12px 36px rgba(15, 23, 42, 0.2), 0 2px 8px rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
      }

      .mobile-bottom-actionbar button {
        min-height: 44px;
        padding: 0 8px;
        border-radius: 14px;
        font-size: 0.78rem;
        box-shadow: none;
      }

      .mobile-bottom-actionbar .mobile-primary-action {
        background: var(--primary);
        color: #fff;
        box-shadow: 0 12px 26px rgba(37, 99, 235, 0.18);
      }

      .mobile-more-sheet {
        position: fixed;
        inset: 0;
        z-index: 40;
        display: none;
        align-items: flex-end;
        background: rgba(15, 23, 42, 0.34);
        padding: 16px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
      }

      .mobile-more-sheet.is-open {
        display: flex;
      }

      .mobile-more-panel {
        width: 100%;
        max-width: 520px;
        margin: 0 auto;
        padding: 14px;
        border-radius: 24px;
        background: #fff;
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
      }

      .mobile-more-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 10px;
      }

      .mobile-more-header h2 {
        margin: 0;
        font-size: 1rem;
        letter-spacing: -0.02em;
      }

      .mobile-more-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
      }

      .mobile-more-grid button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 44px;
        padding: 0 10px;
        box-shadow: none;
      }

      .mobile-more-grid .mobile-danger-action {
        color: var(--danger);
        background: var(--danger-bg);
      }

      .mobile-more-note {
        margin: 10px 2px 0;
        color: var(--muted);
        font-size: 0.75rem;
        line-height: 1.45;
      }

      body {
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
      }
    }



    @media (max-width: 800px) {
      .preset-grid {
        max-height: 304px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-right: 4px;
        scroll-snap-type: y proximity;
      }

      .preset-grid .preset-button {
        scroll-snap-align: start;
      }

      .preset-grid::-webkit-scrollbar {
        width: 6px;
      }

      .preset-grid::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgba(100, 116, 139, 0.36);
      }
    }

    @media (min-width: 760px) {
      .app { padding: 34px 22px 48px; }
      .panel { padding: 22px; }
      .grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
      #plot { min-height: 560px; }
    }

    @media (min-width: 801px) {
      .app { width: min(100%, 1440px); }
      .workspace {
        grid-template-columns: minmax(320px, 380px) minmax(600px, 1fr);
        gap: 32px;
        margin-top: 24px;
      }
      .workspace > .panel { margin-top: 0; }
      .controls { grid-template-columns: 1fr; }
      .controls .grid,
      .controls .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .plot-card { min-width: 0; }
    }

    @media (max-width: 800px) {
      .plot-card { order: 1; }
      .controls { order: 2; }
    }

    @media (max-width: 520px) {
      .app { padding-inline: 10px; }
      .grid { grid-template-columns: 1fr; }
      .visual-control-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .panel-title { align-items: flex-start; flex-direction: column; }
      .tabs { grid-template-columns: 1fr; }
      .function-item {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        gap: 6px;
        padding: 8px;
      }
      .function-meta { display: none; }

      .preset-grid {
        grid-template-columns: 1fr;
      }

      .parameter-item {
        grid-template-columns: 1fr;
        gap: 6px;
      }
      .analysis-input-grid {
        grid-template-columns: 1fr;
      }
      .analysis-card .analysis-actions button {
        flex-basis: calc(50% - 6px);
      }
      .plot-header {
        align-items: flex-start;
        flex-direction: column;
      }
      .plot-actions { justify-content: flex-start; }

      .function-toggle,
      .function-delete {
        min-height: 30px;
        padding: 0 8px;
      }
      math-field { min-height: 68px; }
      .controls { margin-top: 22px; }
      .plot-card { padding: 8px; }
      #plot {
        min-height: 320px;
        height: 58vh;
        max-height: 480px;
      }
      #plot.mode-complex,
      #plot.mode-fourier {
        min-height: 580px;
        height: 75vh;
        max-height: 680px;
      }
      #plot.polar-plot {
        height: auto;
        max-height: min(70vh, 480px);
      }
    }
}

/* ==========================================================================
   Creative Enhancements - Math Plotter Premium Upgrades
   ========================================================================== */

/* 2D Vector Input Row */
.vector-input-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  width: 100%;
}

.vector-input-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 4px 14px;
}

.vector-prefix {
  font: 900 1.1rem ui-monospace, monospace;
  color: var(--primary);
  user-select: none;
  white-space: nowrap;
}

.vector-sub-input {
  border: none !important;
  box-shadow: none !important;
  padding: 10px 0 !important;
  background: transparent !important;
  min-height: auto !important;
  font-size: 1.15rem !important;
}

/* Parameter Autoplay Button */
.parameter-item {
  grid-template-columns: auto minmax(32px, 0.45fr) minmax(110px, 1.2fr) minmax(76px, 0.65fr) !important;
}

.param-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: auto;
  padding: 0;
  border-radius: 50%;
  background: var(--primary-weak);
  color: var(--primary);
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 900;
  transition: all 150ms ease;
  user-select: none;
  border: none;
  cursor: pointer;
}

.param-play-btn.is-playing {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
  font-size: 0.72rem;
}

.param-play-btn:hover {
  transform: scale(1.08);
}

/* Hover Tangent Slope Popup */
.slope-bubble {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  opacity: 0;
  transform: scale(0.9) translate(-50%, -100%);
  transition: opacity 120ms ease, transform 120ms ease;
  margin-top: -12px;
}

.slope-bubble.is-visible {
  opacity: 1;
  transform: scale(1) translate(-50%, -100%);
}

.slope-bubble-title {
  font-weight: 900;
  color: var(--primary);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.slope-bubble-math {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}

/* Radar scan visual updates */
.analysis-scan-running {
  position: relative;
  overflow: hidden;
}

/* CSS Glassmorphism overrides */
.panel, .subtle-card {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

body.dark-chart .panel {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(51, 65, 85, 0.6);
  color: #f8fafc;
}

body.dark-chart .subtle-card {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(71, 85, 105, 0.5);
  color: #f1f5f9;
}

body.dark-chart .parameter-item {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(51, 65, 85, 0.7);
  color: #f1f5f9;
}

body.dark-chart .parameter-name {
  color: #e2e8f0;
}

body.dark-chart .parameter-value {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(51, 65, 85, 0.8);
  color: #fff;
}

/* TikZ Exporter Modal Styles */
.tikz-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.tikz-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.tikz-modal-container {
  width: min(90vw, 680px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(20px);
  transition: transform 200ms ease;
  backdrop-filter: blur(18px);
}
.tikz-modal-overlay.is-open .tikz-modal-container {
  transform: translateY(0);
}
body.dark-chart .tikz-modal-container {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(51, 65, 85, 0.8);
}
.tikz-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tikz-modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}
body.dark-chart .tikz-modal-header h3 {
  color: #f8fafc;
}
.tikz-modal-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--muted);
}
.tikz-modal-textarea {
  width: 100%;
  height: 280px;
  padding: 12px;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.82rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #334155;
  outline: none;
  resize: none;
}
body.dark-chart .tikz-modal-textarea {
  background: #0a0e17;
  color: #cbd5e1;
  border-color: rgba(51, 65, 85, 0.8);
}
.tikz-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   2D Matrix Transformations UI Layout
   ========================================================================== */
.linalg-matrix-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 20px;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.6), 0 4px 16px rgba(15, 23, 42, 0.03);
}
body.dark-chart .linalg-matrix-row {
  background: rgba(15, 23, 42, 0.35);
  border-color: rgba(51, 65, 85, 0.5);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05), 0 4px 16px rgba(0,0,0,0.2);
}
.matrix-symbol-label {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  letter-spacing: -0.02em;
}
body.dark-chart .matrix-symbol-label {
  color: #f8fafc;
}
.matrix-bracket-container {
  display: flex;
  align-items: center;
}
.matrix-bracket-left, .matrix-bracket-right {
  width: 8px;
  height: 92px;
  border: 2px solid var(--text);
}
body.dark-chart .matrix-bracket-left,
body.dark-chart .matrix-bracket-right {
  border-color: #cbd5e1;
}
.matrix-bracket-left {
  border-right: none;
  border-radius: 6px 0 0 6px;
}
.matrix-bracket-right {
  border-left: none;
  border-radius: 0 6px 6px 0;
}
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(2, 90px);
  grid-gap: 8px;
  padding: 0 10px;
}
.matrix-cell-input {
  width: 90px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
}
body.dark-chart .matrix-cell-input {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(71, 85, 105, 0.7);
  color: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.matrix-cell-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
  outline: none;
  transform: scale(1.03);
}
body.dark-chart .matrix-cell-input:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.25);
}
.linalg-vector-x {
  display: flex;
  align-items: center;
  margin-left: 4px;
}
.vector-grid {
  display: grid;
  grid-template-rows: repeat(2, 40px);
  grid-gap: 8px;
  padding: 0 8px;
  align-items: center;
}
.vector-cell {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}
body.dark-chart .vector-cell {
  color: #94a3b8;
}
.linalg-morph-slider-container {
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.05);
}
body.dark-chart .linalg-morph-slider-container {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.05);
}
.linalg-morph-slider-container input[type="range"] {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  outline: none;
  -webkit-appearance: none;
}
body.dark-chart .linalg-morph-slider-container input[type="range"] {
  background: #334155;
}
.linalg-morph-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  transition: transform 120ms ease;
}
.linalg-morph-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
body.dark-chart .linalg-morph-slider-container input[type="range"]::-webkit-slider-thumb {
  background: #06b6d4;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   Fourier Wave Synthesis Styles
   ========================================================================== */
.fourier-control-row {
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 20px;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.6), 0 4px 16px rgba(15, 23, 42, 0.03);
}
body.dark-chart .fourier-control-row {
  background: rgba(15, 23, 42, 0.35);
  border-color: rgba(51, 65, 85, 0.5);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05), 0 4px 16px rgba(0,0,0,0.2);
}
#fourierWaveType {
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
}
#fourierWaveType:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
  outline: none;
}
body.dark-chart #fourierWaveType:focus {
  border-color: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.25);
}

/* ==========================================================================
   UI/UX Audit Enhancements: Premium Layout, Sliders, and Touch Targets
   ========================================================================== */

/* Button SVG Icons styling */
.btn-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Segmented button toolbar groups */
.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(226, 232, 240, 0.4);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
  width: 100%;
}
body.dark-chart .toolbar-group {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(71, 85, 105, 0.3);
}
.toolbar-group button {
  flex: 1;
  min-width: 76px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 700;
  white-space: nowrap;
}
.font-compact button {
  font-size: 0.8rem;
  padding: 4px 8px;
}

/* Premium Primary Buttons */
.primary-plot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  font-weight: 700;
  border-radius: 10px;
  padding: 8px 16px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: all 180ms ease;
  cursor: pointer;
}
.primary-plot-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.primary-plot-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
body.dark-chart .primary-plot-btn {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}
body.dark-chart .primary-plot-btn:hover {
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.45);
}

.primary-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 18px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 180ms ease;
  cursor: pointer;
  text-decoration: none;
}
.primary-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}
.primary-add-btn:active {
  transform: translateY(1px);
}
body.dark-chart .primary-add-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Tactile touch targets and press feedback */
button, select, input, label.file-btn {
  min-height: 38px;
  transition: all 120ms ease;
}
button:active, label.file-btn:active, .formula-chip:active, .tab-option:active {
  transform: scale(0.96);
  opacity: 0.88;
}

/* Premium Inputs/Sliders Track and Thumb Override */
input[type="range"].neon-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 24px;
}
input[type="range"].neon-slider:focus {
  outline: none;
}
input[type="range"].neon-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: rgba(226, 232, 240, 0.8);
  border-radius: 3px;
  border: none;
}
body.dark-chart input[type="range"].neon-slider::-webkit-slider-runnable-track {
  background: rgba(71, 85, 105, 0.5);
}
input[type="range"].neon-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
  transition: transform 120ms ease, background 120ms ease;
}
input[type="range"].neon-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
body.dark-chart input[type="range"].neon-slider::-webkit-slider-thumb {
  background: #06b6d4;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.5);
}

/* Mobile Quick Navigation Action Bar Stacking and Styling */
@media (max-width: 520px) {
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .parameter-list {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  button, select, input, label.file-btn {
    min-height: 44px; /* Optimal tactile size for mobile */
  }
  
  .mobile-bottom-actionbar {
    padding-bottom: calc(9px + env(safe-area-inset-bottom)) !important;
    min-height: 62px;
  }
  .mobile-bottom-actionbar button {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    height: 52px !important;
    padding: 2px 4px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
  }
  .mobile-bottom-actionbar button .btn-icon {
    width: 20px !important;
    height: 20px !important;
    margin-right: 0 !important;
    margin-bottom: 2px !important;
  }
}

/* Dark Mode Sheet and Bottom Actionbar Overrides */
body.dark-chart .mobile-bottom-actionbar {
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-top-color: rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}
body.dark-chart .mobile-more-panel {
  background: rgba(15, 23, 42, 0.96) !important;
  border-color: rgba(51, 65, 85, 0.8) !important;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6) !important;
}
body.dark-chart .mobile-more-header {
  border-color: rgba(51, 65, 85, 0.6) !important;
}
body.dark-chart .mobile-more-note {
  color: #94a3b8 !important;
}

@keyframes panelFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel, .preset-button {
  opacity: 0;
  animation: panelFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform;
}

.panel:nth-child(1) { animation-delay: 40ms; }
.panel:nth-child(2) { animation-delay: 80ms; }
.panel:nth-child(3) { animation-delay: 120ms; }
.panel:nth-child(4) { animation-delay: 160ms; }
.panel:nth-child(5) { animation-delay: 200ms; }
.panel:nth-child(6) { animation-delay: 240ms; }

.preset-button:nth-child(1) { animation-delay: 60ms; }
.preset-button:nth-child(2) { animation-delay: 90ms; }
.preset-button:nth-child(3) { animation-delay: 120ms; }
.preset-button:nth-child(4) { animation-delay: 150ms; }
.preset-button:nth-child(5) { animation-delay: 180ms; }
.preset-button:nth-child(6) { animation-delay: 210ms; }
.preset-button:nth-child(7) { animation-delay: 240ms; }
.preset-button:nth-child(8) { animation-delay: 270ms; }

@media (prefers-reduced-motion: reduce) {
  .panel, .preset-button { animation: none; opacity: 1; }
}