[hidden] { display: none !important; }

/* ── Page bits that used to be inline styles ─────── */
.nav-actions { display: flex; gap: .5rem; }
.gh-icon { vertical-align: middle; }
.desktop-note { color: #999; margin-bottom: 1.2rem; font-size: .92rem; }
.src-note { font-size: .8rem; font-weight: 400; color: #666; }
.trouble-box .mt { margin-top: .6rem; }
.trouble-box details + details { margin-top: .6rem; border-top: 1px solid #2a2a2a; padding-top: .6rem; }
.noscript { background: #3b1d1d; color: #fca5a5; text-align: center; padding: 1rem; }
.container .dl-btns { justify-content: flex-start; margin-bottom: .8rem; }
.container .dl-warn { margin-bottom: 1rem; }
.container .run-box { margin-top: 1rem; margin-bottom: 3rem; }
body.busy, body.busy * { cursor: progress !important; }

/* ── Upload section (top of page) ────────────────── */
.upload { background: #0f0f0f; border-bottom: 1px solid #1a1a1a; padding: 1.25rem 1.5rem 1rem; }
.upload-inner { max-width: 1400px; margin: 0 auto; }
.dropzone {
  border: 2px dashed #3b6ea8; border-radius: 12px; background: #141a22;
  text-align: center; padding: 1.6rem 1rem; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: #4f9cf9; background: #17202c; outline: none; }
.dz-icon { font-size: 2rem; line-height: 1; margin-bottom: .4rem; }
.dz-title { font-size: 1.1rem; color: #e8e8e8; }
.dz-title code, .dz-sub code { background: #1a1a1a; color: #4f9cf9; padding: 1px 6px; border-radius: 4px; }
.dz-sub { color: #8a97a8; font-size: .84rem; margin-top: .35rem; }
.dz-sub strong { color: #cbd5e1; }

.filebar {
  display: none; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-top: .75rem; padding: .55rem .9rem;
  background: #161616; border: 1px solid #2a2a2a; border-radius: 8px; font-size: .88rem;
}
.upload.with-demo .filebar, .upload.compact .filebar { display: flex; }
.upload.compact .dropzone { display: none; }
.upload.with-demo .dropzone { padding: .8rem 1rem; }
.upload.with-demo .dz-icon { display: none; }
.upload.compact .filebar { margin-top: 0; }
.fb-name { color: #e8e8e8; word-break: break-all; }
.fb-meta { color: #8a97a8; }
.fb-spacer { flex: 1; }
.fb-hint { color: #667; font-size: .8rem; }
.fb-spec { color: #9aa; display: flex; align-items: center; gap: .4rem; }
.fb-spec select { background: #0f0f0f; color: #e8e8e8; border: 1px solid #333; border-radius: 4px; padding: .2rem .4rem; max-width: 260px; }
.badge-demo { background: rgba(251,191,36,.12); color: #fbbf24; border: 1px solid rgba(251,191,36,.35); border-radius: 20px; padding: 0 .6rem; font-size: .75rem; font-weight: 600; }
.btn-upload {
  background: #4f9cf9; color: #0f0f0f; border: 0; border-radius: 6px; cursor: pointer;
  padding: .4rem 1rem; font-weight: 700; font-size: .85rem; font-family: inherit;
}
.btn-upload:hover { background: #3b8de0; }
.upload-err { margin-top: .6rem; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; border-radius: 8px; padding: .5rem .9rem; font-size: .86rem; }

/* ── Drag overlay ────────────────────────────────── */
.drop-overlay {
  position: fixed; inset: 0; z-index: 500; pointer-events: none;
  background: rgba(15,15,15,.88); display: flex; align-items: center; justify-content: center;
  border: 4px dashed #4f9cf9; font-size: 1.6rem; font-weight: 700; color: #e8e8e8;
}
.drop-overlay code { color: #4f9cf9; }

/* ── Viewer: looks like the desktop program ──────── */
.app {
  --ui-bg: #f0f0f0; --ui-border: #c8c8c8; --ui-accent: #005a9e; --ui-text: #1a1a1a;
  display: flex; flex-direction: column;
  height: clamp(520px, 82vh, 920px);
  margin: 0 auto 0; max-width: 1400px; width: calc(100% - 3rem);
  background: var(--ui-bg); color: var(--ui-text); border: 1px solid #333; border-radius: 8px;
  overflow: hidden; font: 13px/1.4 'Segoe UI', system-ui, sans-serif;
}
.app button, .app input, .app select { font: inherit; }
.app-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  padding: 4px 6px; background: #e9e9e9; border-bottom: 1px solid var(--ui-border);
}
.app .sep { width: 1px; align-self: stretch; background: #bbb; margin: 3px 5px; }
.app .btn {
  background: #fdfdfd; color: var(--ui-text); border: 1px solid #adadad; border-radius: 3px;
  padding: 3px 10px; cursor: pointer;
}
.app .btn:hover { background: #e5f1fb; border-color: #0078d4; }
.app .btn:focus-visible, .app .tabs button:focus-visible, .tbl-list li:focus-visible,
.seg button:focus-visible { outline: 2px solid #0078d4; outline-offset: 1px; }
.app .btn-sq { padding: 3px 7px; min-width: 26px; }
.app .btn-primary { background: var(--ui-accent); color: #fff; border-color: var(--ui-accent); }
.app .btn-primary:hover { background: #004578; }
.app .chk { display: flex; align-items: center; gap: 5px; color: #333; }
.app .inp { background: #fff; color: var(--ui-text); border: 1px solid #adadad; border-radius: 3px; padding: 3px 6px; }
.app .inp:focus { outline: 2px solid #0078d4; outline-offset: -1px; }
.app .inp-search { width: 220px; max-width: 40vw; }
.app .muted { color: #666; }

.app-body { flex: 1; min-height: 0; display: flex; gap: 4px; padding: 4px; }
.app-left { width: 220px; flex: none; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.left-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0; }
.seg { display: flex; }
.seg button {
  flex: 1; background: #e0e0e0; color: #333; border: 0; padding: 3px 8px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ui-accent); color: #fff; }
.tbl-list {
  list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow: auto;
  background: #fff; border: 1px solid #adadad; font: 12px Consolas, 'Cascadia Mono', monospace;
}
.tbl-list li { padding: 2px 6px; cursor: pointer; white-space: nowrap; }
.tbl-list li:hover { background: #eef5fc; }
.tbl-list li[aria-selected="true"] { background: #cce5ff; }

.app-right { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ui-border); }
.tabs button {
  background: #e4e4e4; color: #333; border: 1px solid var(--ui-border); border-bottom: 0;
  border-radius: 3px 3px 0 0; padding: 4px 14px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #fff; color: #000; font-weight: 600; margin-bottom: -1px; }
.tabpanel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--ui-border); border-top: 0; }
.data-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 5px 6px; background: var(--ui-bg); }
.tbl-name { color: var(--ui-accent); margin-right: 8px; }
.lbl { text-align: right; color: #666; padding: 1px 8px; background: var(--ui-bg); border-top: 1px solid #ddd; }
.app-status { padding: 2px 8px; background: #f7f7f7; border-top: 1px solid var(--ui-border); color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid-host { flex: 1; min-height: 0; position: relative; }
.grid-wrap { position: absolute; inset: 0; overflow: auto; background: #fff; }
.grid-wrap:focus-visible { outline: 2px solid #0078d4; outline-offset: -2px; }
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 100%; }
.grid th {
  position: sticky; top: 0; z-index: 2; background: #f1f1f1; color: #111;
  font: 600 12px 'Segoe UI', system-ui, sans-serif; text-align: left; height: 26px;
  padding: 0 14px 0 6px; border-right: 1px solid #d4d4d4; border-bottom: 1px solid #b5b5b5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; user-select: none;
}
.grid th:hover { background: #e3eefa; }
.grid th.drop-target { box-shadow: inset 3px 0 0 var(--ui-accent); }
.th-resize { position: absolute; right: 0; top: 0; width: 6px; height: 100%; cursor: col-resize; }
.th-resize:hover { background: rgba(0,90,158,.35); }
.grid td {
  box-sizing: border-box; height: 24px; line-height: 22px; padding: 0 6px;
  font: 12px Consolas, 'Cascadia Mono', monospace; color: #111;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid #f0f0f0;
}
.grid td.sp { padding: 0; border: 0; }
.grid tr.even { background: #fff; }
.grid tr.odd  { background: #f8f9fa; }
.grid tr.s1   { background: #d4edda; }
.grid tr.sel td { background: #cce5ff; }
.grid tbody tr:not(.sp-row):hover td { background: #eef5fc; }
.grid tr.sel:hover td { background: #cce5ff; }

.port-panel { border-top: 1px solid #aaa; background: var(--ui-bg); padding: 4px; display: flex; flex-direction: column; height: 200px; flex: none; }
.port-title { font-size: 12px; color: #333; padding: 0 2px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-host-small { border: 1px solid #adadad; }
.port-panel .grid tr.odd { background: #e8f4f8; }

/* ── Context menu ────────────────────────────────── */
.ctx-menu {
  position: fixed; z-index: 1000; min-width: 220px; background: #fff; color: #111;
  border: 1px solid #999; box-shadow: 0 4px 14px rgba(0,0,0,.35); padding: 3px 0; font: 13px 'Segoe UI', system-ui, sans-serif;
}
.ctx-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 14px; cursor: pointer; font: inherit; color: inherit; }
.ctx-menu button:hover, .ctx-menu button:focus { background: #cce5ff; outline: none; }
.ctx-menu hr { border: 0; border-top: 1px solid #ddd; margin: 3px 0; }

/* ── Dialogs ─────────────────────────────────────── */
dialog.dlg {
  padding: 0; border: 1px solid #888; border-radius: 6px; background: #f0f0f0; color: #1a1a1a;
  width: min(580px, 94vw); font: 13px/1.45 'Segoe UI', system-ui, sans-serif;
}
dialog.dlg[open] { display: flex; flex-direction: column; max-height: 88vh; }
dialog.dlg::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #e4e4e4; border-bottom: 1px solid #c8c8c8; }
.btn-x { background: none; border: 0; cursor: pointer; font-size: 14px; color: #444; padding: 2px 6px; }
.btn-x:hover { color: #000; background: #ddd; }
.dlg-body { padding: 10px 14px; overflow: auto; flex: 1; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid #c8c8c8; background: #e9e9e9; }
.dlg .btn { background: #fdfdfd; color: #1a1a1a; border: 1px solid #adadad; border-radius: 3px; padding: 4px 14px; cursor: pointer; font: inherit; }
.dlg .btn:hover { background: #e5f1fb; border-color: #0078d4; }
.dlg .btn-primary { background: #005a9e; color: #fff; border-color: #005a9e; }
.dlg .btn-primary:hover { background: #004578; }
.dlg .muted { color: #666; margin-bottom: 8px; }
.checklist { background: #fff; border: 1px solid #adadad; padding: 4px 8px; max-height: 48vh; overflow: auto; font: 12px Consolas, monospace; }
.checklist label { display: block; padding: 1px 0; cursor: pointer; }
.checklist label.dim { color: #aaa; }
.colgrid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; }
.colsel { width: 100%; font: 12px Consolas, monospace; margin-top: 3px; }
.colmid { display: flex; flex-direction: column; gap: 4px; padding-top: 22px; }
.colmid hr { border: 0; border-top: 1px solid #ccc; width: 100%; }
.howto h3 { margin: 10px 0 2px; font-size: 13px; color: #005a9e; }
.howto p { margin: 0 0 4px; }

/* ── Small screens ───────────────────────────────── */
@media (max-width: 800px) {
  .btn-nav-gh { display: none; }
  .navbar { padding: 0 1rem; }
  .app { width: calc(100% - 1.5rem); height: 86vh; }
  .app-body { flex-direction: column; }
  .app-left { width: auto; height: 170px; }
  .upload { padding: 1rem .75rem .75rem; }
  .fb-spacer { display: none; }
  .port-panel { height: 160px; }
}
