  /* ---------- File / Project menu ---------- */
  #filePanel {
    position: fixed; inset: 0; background: rgba(30,20,10,.45);
    display: none; align-items: center; justify-content: center; z-index: 70;
  }
  #filePanel.show { display: flex; }
  #fileSheet {
    width: 88%; max-width: 390px; background: var(--panel);
    border: 1px solid var(--panel-line); border-radius: 14px; padding: 18px;
    box-shadow: 0 14px 40px rgba(0,0,0,.18);
  }
  #fileSheet h3 { margin: 0 0 12px; }
  #fileSheet label { display:block; font-size:12px; color:var(--text-dim); margin:8px 0 5px; }
  #projectName {
    width:100%; padding:10px 11px; border-radius:9px;
    border:1px solid var(--panel-line); background:var(--bg); color:var(--text);
    font-size:13px; user-select:text;
  }
  .file-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px; }
  .file-actions button, #fileCloseBtn {
    padding:10px; border-radius:9px; border:1px solid var(--panel-line);
    background:var(--bg); color:var(--text); cursor:pointer; font-weight:600;
  }
  .file-actions button.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
  #fileCloseBtn { width:100%; margin-top:10px; }
  #fileImportInput { display:none; }


  .download-arrow {
    display: inline-block;
    margin-right: 5px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    vertical-align: -1px;
  }


  #newBlankCanvasBtn {
    width: 100%; margin-top: 12px; padding: 10px;
    border-radius: 9px; border: 1px solid var(--panel-line);
    background: var(--bg); color: var(--text); cursor: pointer;
    font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 7px;
  }
  .file-actions button {
    display: flex; align-items: center; justify-content: center; gap: 6px;
  }
  .file-action-icon {
    width: 17px; height: 17px; flex: 0 0 17px;
  }






/* ===== GRAPH PALETTE: INNER RIGHT BREATHING SPACE ===== */
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  #wfChartWrap {
    padding-right: 24px !important;
  }
}


/* ===== WAVEFORM: DOWNLOAD GRAPH BUTTON LEFT OF SIMULATE ===== */
#wfTopDownloadGraphBtn {
  display: none;
}
body.waveform-page #wfTopDownloadGraphBtn, body.transfer-page #wfTopDownloadGraphBtn {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  body.waveform-page #wfTopDownloadGraphBtn, body.transfer-page #wfTopDownloadGraphBtn {
    width: auto !important;
    min-width: 72px !important;
    height: 34px !important;
    padding: 0 10px !important;
    border-radius: 17px !important;
    flex-direction: row !important;
    gap: 5px !important;
    color: var(--text-dim);
  }
  body.waveform-page #wfTopDownloadGraphBtn svg, body.transfer-page #wfTopDownloadGraphBtn svg {
    width: 15px !important;
    height: 15px !important;
  }
  body.waveform-page #wfTopDownloadGraphBtn span, body.transfer-page #wfTopDownloadGraphBtn span {
    font-size: 9px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }
}


/* ===== DOWNLOAD GRAPH: THEME-ACCENT CIRCLE OUTLINE ===== */
body.waveform-page #wfTopDownloadGraphBtn, body.transfer-page #wfTopDownloadGraphBtn {
  min-width: 34px !important;
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  border: 2px solid var(--accent) !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: var(--accent) !important;
  align-items: center !important;
  justify-content: center !important;
}
body.waveform-page #wfTopDownloadGraphBtn svg, body.transfer-page #wfTopDownloadGraphBtn svg {
  width: 16px !important;
  height: 16px !important;
  color: var(--accent) !important;
}
body.waveform-page #wfTopDownloadGraphBtn span, body.transfer-page #wfTopDownloadGraphBtn span {
  display: none !important;
}


/* ===== DOWNLOAD GRAPH: COMBINED GRAPH + DOWNLOAD ICON, FINER BUTTON ===== */
body.waveform-page #wfTopDownloadGraphBtn, body.transfer-page #wfTopDownloadGraphBtn {
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  border-width: 1.25px !important;
  margin-right: 7px !important;
}
body.waveform-page #wfTopDownloadGraphBtn .download-graph-icon, body.transfer-page #wfTopDownloadGraphBtn .download-graph-icon {
  width: 20px !important;
  height: 20px !important;
  color: var(--accent) !important;
}
body.waveform-page #wfTopSimulateBtn {
  margin-left: 0 !important;
}


/* ===== DOWNLOAD GRAPH: DOWNLOAD SYMBOL + "GRAPH" WORD ===== */
body.waveform-page #wfTopDownloadGraphBtn, body.transfer-page #wfTopDownloadGraphBtn {
  width: auto !important;
  min-width: 74px !important;
  height: 32px !important;
  padding: 0 10px 0 8px !important;
  border-width: 1.25px !important;
  border-radius: 18px !important;
  margin-right: 7px !important;
  gap: 5px !important;
}
body.waveform-page #wfTopDownloadGraphBtn .download-graph-icon, body.transfer-page #wfTopDownloadGraphBtn .download-graph-icon {
  width: 15px !important;
  height: 15px !important;
}
body.waveform-page #wfTopDownloadGraphBtn span, body.transfer-page #wfTopDownloadGraphBtn span {
  display: inline !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  color: var(--accent) !important;
  white-space: nowrap !important;
}



/* ===== TRANSFER CHARACTERISTICS PAGE ===== */
#page-transfer { display:block; padding:0; background:var(--bg); color:var(--text); text-align:left; }
.tc-layout { display:grid; grid-template-columns:minmax(0,27fr) minmax(0,73fr); height:100%; padding:10px; gap:10px; min-width:0; }
#tcControlsPanel, #tcGraphArea { min-width:0; min-height:0; height:100%; }
.tc-card, #tcChartWrap { background:var(--panel); border:1px solid var(--panel-line); border-radius:14px; }
.tc-card { height:100%; padding:12px; overflow:auto; }
.tc-card h3 { margin:0 0 12px; font-size:20px; font-weight:800; }
.tc-field { margin-bottom:12px; }
.tc-field.tc-row { display:flex; align-items:center; gap:7px; }
.tc-field.tc-row > label { flex:0 0 72px; margin:0; }
.tc-field > label { display:block; font-size:12px; font-weight:700; color:var(--text-dim); margin-bottom:5px; }
.tc-inline-controls { display:flex; align-items:center; gap:5px; flex:1; min-width:0; }
.tc-inline-controls .tc-select { flex:1 1 0; width:auto; }
.tc-field.tc-row #tcSweepSource, .tc-field.tc-row #tcStep { flex:1; width:auto; }
.tc-select, #tcStep { width:100%; min-width:0; padding:7px 9px; border-radius:8px; border:1px solid var(--panel-line); background:var(--bg); color:var(--text); font-size:12px; font-weight:600; }
#tcGraphArea { display:flex; }
#tcChartWrap { width:100%; height:100%; padding:14px 24px 14px 14px; overflow:hidden; }
[data-theme="dark"] #tcChartWrap, [data-theme="dark"] .tc-card { background:#090e16; }
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  body.transfer-page #topbarCenter { transform:none !important; overflow:visible !important; justify-content:flex-end !important; }
  body.transfer-page #settingsBtn { display:none !important; }
  body.transfer-page #topbarRight { position:static !important; transform:none !important; }
  .tc-card { padding:10px; }
  .tc-card h3 { font-size:18px; margin-bottom:8px; }
  .tc-field { margin-bottom:8px; }
  .tc-select, #tcStep { padding:6px 8px; }
}


/* ===== TRANSIENT CONTROLS: TWO-LINE AXES + ALIGNED SWEEP/STEP ===== */
.tc-field.tc-axis { display:block; }
.tc-field.tc-axis > label { display:block; margin:0 0 5px 0; }
.tc-field.tc-axis .tc-inline-controls { display:flex; width:100%; gap:5px; }
.tc-field.tc-axis .tc-select { flex:1 1 0; width:0; }
.tc-field.tc-row > label { flex:0 0 72px; }
.tc-field.tc-row #tcSweepSource,
.tc-field.tc-row #tcStep { flex:1 1 0; width:0; min-width:0; margin:0; }


/* ===== TRANSIENT CONTROLS: FINAL SPACING + RUN SWEEP ===== */
.tc-field.tc-sweep-row { margin-top: 16px; }
#tcRunSweepBtn {
  width: 100%;
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
[data-theme="dark"] #tcRunSweepBtn { color:#17130b; border-color:var(--accent-strong); }
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  .tc-field.tc-sweep-row { margin-top: 14px; }
  #tcRunSweepBtn { margin-top: 5px; padding: 7px 10px; font-size: 11px; }
}

/* ===== TRANSFER CONTROLS: FILL PALETTE NEATLY ===== */
.tc-card {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 8px;
}
.tc-card .tc-field { margin: 0 !important; }
.tc-field.tc-sweep-row { margin-top: 0 !important; }
.tc-field.tc-axis > label { margin-bottom: 6px; }
.tc-inline-controls { gap: 7px; }
.tc-select, #tcStep {
  min-height: 36px;
  padding: 8px 9px;
}
.tc-field.tc-row { gap: 9px; }
.tc-field.tc-row > label { flex: 0 0 78px; }
#tcRunSweepBtn {
  margin-top: 0 !important;
  min-height: 38px;
  padding: 8px 12px;
}
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  .tc-card { padding: 12px; gap: 5px; }
  .tc-select, #tcStep { min-height: 32px; padding: 6px 8px; }
  #tcRunSweepBtn { min-height: 34px; margin-top: 0 !important; }
}


/* ===== TRANSFER: COMPACT START / STOP ROW ===== */
.tc-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.tc-range-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
}
.tc-range-item label {
  flex: 0 0 auto;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
#tcStart, #tcStop {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  min-height: 36px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  user-select: text;
}
@media screen and (orientation: landscape), screen and (max-aspect-ratio: 99/100) {
  .tc-range-row { gap: 7px; }
  .tc-range-item { gap: 5px; }
  #tcStart, #tcStop { min-height: 32px; padding: 6px 8px; }
}


