/* === CSS Custom Properties === */
:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-dim: rgba(88, 166, 255, 0.15);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.15);
  --orange: #d2991d;
  --orange-dim: rgba(210, 153, 29, 0.15);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.15);
  --purple: #a371f7;
  --purple-dim: rgba(163, 113, 247, 0.15);
  --cyan: #39d2c0;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 3px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --radius-sm: 4px;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --transition: 150ms ease;
  --max-width: 1280px;
}

/* === Themed Scrollbars === */
* {
  scrollbar-color: var(--border) var(--bg);
  scrollbar-width: thin;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: var(--bg);
}
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
*::-webkit-scrollbar-corner {
  background: var(--bg);
}

/* === Reset === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* === Skip Link === */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #000;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: 8px;
}

/* === Header === */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 32px 16px 24px;
  text-align: center;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.site-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 640px;
  margin: 0 auto;
}

/* === Main === */
main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px clamp(16px, 2vw, 32px) 48px;
}
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* === Upload Section === */
.upload-section {
  margin-bottom: 32px;
}
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--bg-secondary);
}
.drop-zone:hover,
.drop-zone:focus-within,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone-content {
  pointer-events: none;
}
.upload-icon {
  color: var(--text-muted);
  margin-bottom: 12px;
}
.drop-text {
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--text);
}
.drop-text strong {
  color: var(--accent);
}
.drop-or {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.file-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent);
  color: #000;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition);
}
.file-btn:hover {
  background: var(--accent-hover);
}
.drop-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 12px;
}
.file-info {
  margin-top: 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* === Progress Bar === */
.progress-container {
  margin-top: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  height: 6px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 300ms ease;
  border-radius: var(--radius-sm);
}
.progress-text {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Summary Stats === */
.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  min-width: 120px;
  flex: 1;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.stat-card.stat-i .stat-value { color: var(--green); }
.stat-card.stat-idr .stat-value { color: var(--cyan); }
.stat-card.stat-p .stat-value { color: var(--orange); }
.stat-card.stat-b .stat-value { color: var(--purple); }
.stat-card.stat-total .stat-value { color: var(--accent); }
.stat-card.stat-gop .stat-value { color: var(--cyan); }

/* === Tab Navigation === */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  min-height: 58px;
  overflow: visible;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg-secondary);
}
.tab-btn {
  flex: 0 1 auto;
  min-height: 58px;
  padding: 0 24px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* === Tab Panels === */
.tab-panels {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.tab-panel {
  display: none;
  padding: 20px;
}
.tab-panel.active {
  display: block;
}
#panel-nal.active {
  --nal-toolbar-height: 38px;
  --nal-row-gap: 16px;
  --nal-table-height: min(68vh, 680px);
  --inspector-header-height: 56px;
  --field-list-height: 320px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  grid-template-rows: var(--nal-toolbar-height) minmax(0, var(--nal-table-height));
  grid-template-areas:
    "toolbar inspector"
    "table inspector";
  gap: var(--nal-row-gap) 16px;
  align-items: stretch;
}
#panel-nal .nal-inspector {
  grid-area: inspector;
  min-width: 0;
  height: calc(var(--nal-toolbar-height) + var(--nal-row-gap) + var(--nal-table-height));
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 12px;
}
#panel-nal .panel-toolbar {
  grid-area: toolbar;
  min-width: 0;
  height: var(--nal-toolbar-height);
  margin-bottom: 0;
}
#panel-nal .table-wrap {
  grid-area: table;
  min-width: 0;
  height: var(--nal-table-height);
  overflow-y: scroll;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  scrollbar-color: var(--text-muted) var(--bg-secondary);
  scrollbar-gutter: stable;
}

#nal-table {
  table-layout: fixed;
  min-width: 900px;
}
#nal-table th,
#nal-table td {
  padding-inline: 8px;
}
#nal-table th:nth-child(1),
#nal-table td:nth-child(1) {
  width: 48px;
}
#nal-table th:nth-child(2),
#nal-table td:nth-child(2) {
  width: 58px;
}
#nal-table th:nth-child(3),
#nal-table td:nth-child(3) {
  width: 180px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#nal-table th:nth-child(4),
#nal-table td:nth-child(4) {
  width: 118px;
}
#nal-table th:nth-child(5),
#nal-table td:nth-child(5) {
  width: 90px;
}
#nal-table th:nth-child(6),
#nal-table td:nth-child(6) {
  width: 64px;
}
#nal-table th:nth-child(7),
#nal-table td:nth-child(7) {
  width: 116px;
}
#nal-table th:nth-child(8),
#nal-table td:nth-child(8) {
  width: 78px;
}
#nal-table th:nth-child(9),
#nal-table td:nth-child(9) {
  width: 34px;
  text-align: center;
}
#nal-table th.tid-col,
#nal-table td.tid-col {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  padding-inline: 3px;
  text-align: center;
}
#nal-table th.tid-col {
  color: var(--text-secondary);
  letter-spacing: 0;
  padding-inline: 3px;
}
#nal-table .tid-col abbr,
#frames-table .tid-col abbr {
  text-decoration: none;
  cursor: help;
}
#frames-table .tid-col {
  text-align: center;
}

/* === NAL Inspector === */
.inspector-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.inspector-fields {
  flex: 0 0 calc(var(--inspector-header-height) + var(--field-list-height));
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.inspector-binary {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.inspector-header,
.binary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--inspector-header-height);
  flex: 0 0 var(--inspector-header-height);
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}
.inspector-header > div,
.binary-header h3 {
  min-width: 0;
}
.inspector-header h3,
.binary-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inspector-kicker {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.inspector-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.field-list {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 8px;
  scrollbar-color: var(--text-muted) var(--bg);
  scrollbar-gutter: stable;
}
.field-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-tree-node {
  border: 1px solid rgba(139, 148, 158, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(22, 27, 34, 0.38);
  overflow: hidden;
}
.field-tree-node .field-tree-node {
  background: rgba(13, 17, 23, 0.28);
}
.field-tree-toggle {
  cursor: pointer;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto 28px;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
}
.field-tree-toggle::-webkit-details-marker {
  display: none;
}
.field-tree-toggle::before {
  content: "+";
  width: 16px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
}
.field-tree-node[open] > .field-tree-toggle::before {
  content: "-";
}
.field-tree-toggle:hover {
  background: rgba(88, 166, 255, 0.08);
}
.field-tree-toggle.field-clickable {
  box-shadow: inset 2px 0 0 rgba(88, 166, 255, 0.55);
  color: var(--text);
}
.field-tree-toggle.field-clickable .field-node-value,
.field-tree-toggle.field-clickable .field-count {
  color: var(--accent);
}
.field-tree-toggle.active {
  background: var(--accent-dim);
}
.field-node-value {
  min-width: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field-count {
  min-width: 22px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
}
.field-tree-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 7px 14px;
  padding: 3px 7px 0 8px;
  border-left: 1px solid rgba(139, 148, 158, 0.26);
}
.field-section {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 6px 5px;
}
.field-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(72px, 0.8fr);
  gap: 2px 10px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.field-row.field-clickable {
  cursor: pointer;
  border-color: rgba(88, 166, 255, 0.22);
  background: rgba(88, 166, 255, 0.06);
  box-shadow: inset 2px 0 0 rgba(88, 166, 255, 0.65);
}
button.field-row.field-clickable:hover,
.field-row.active {
  border-color: rgba(88, 166, 255, 0.45);
  background: var(--accent-dim);
}
.field-row.field-static {
  opacity: 0.72;
}
.field-row.field-clickable .field-bits {
  color: var(--accent);
}
.field-section {
  cursor: default;
}
.field-name {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}
.field-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: right;
  overflow-wrap: anywhere;
}
.field-bits {
  grid-column: 1 / -1;
  min-height: 1em;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.binary-view {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 10px;
  scrollbar-color: var(--text-muted) var(--bg);
  scrollbar-gutter: stable;
}
.binary-note,
.empty-state {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 6px;
}
.binary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
}
.binary-byte {
  display: grid;
  grid-template-columns: 38px 26px 1fr;
  gap: 6px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}
.binary-byte.active {
  border-color: var(--orange);
  background: var(--orange-dim);
}
.binary-offset {
  color: var(--text-muted);
}
.binary-hex {
  color: var(--accent);
  font-weight: 700;
}
.binary-bits {
  display: flex;
  gap: 1px;
}
.binary-bit {
  color: var(--text-secondary);
  line-height: 1;
}
.binary-bit.active {
  color: #000;
  background: var(--orange);
  border-radius: 2px;
}

/* === Panel Toolbar === */
.panel-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.filter-input:focus {
  border-color: var(--accent);
}
.filter-input::placeholder {
  color: var(--text-muted);
}
.panel-count {
  min-width: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Data Table === */
.table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th,
.data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table tbody tr:hover {
  background: var(--accent-dim);
}
.data-table tbody tr.nal-row {
  cursor: pointer;
}
.data-table tbody tr.nal-row.selected {
  background: rgba(88, 166, 255, 0.22);
  box-shadow: inset 3px 0 0 var(--accent);
}
.data-table tbody tr.nal-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.data-table .nal-type-num {
  font-family: var(--font-mono);
  color: var(--accent);
}
.data-table .nal-vcl {
  color: var(--green);
  font-weight: 600;
}
.data-table .nal-non-vcl {
  color: var(--text-secondary);
}
.data-table .nal-sei {
  color: var(--cyan);
}
.data-table .nal-bad {
  color: var(--red);
}
.data-table .offset-col {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.frame-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding-inline: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}
.frame-pill.frame-idr {
  color: var(--cyan);
  border-color: rgba(57, 210, 192, 0.45);
  background: rgba(57, 210, 192, 0.14);
}
.frame-pill.frame-i {
  color: var(--green);
  border-color: rgba(63, 185, 80, 0.45);
  background: var(--green-dim);
}
.frame-pill.frame-p {
  color: var(--orange);
  border-color: rgba(210, 153, 29, 0.45);
  background: var(--orange-dim);
}
.frame-pill.frame-b {
  color: var(--purple);
  border-color: rgba(163, 113, 247, 0.45);
  background: var(--purple-dim);
}
.data-table .slice-idr { color: var(--cyan); font-weight: 700; }
.data-table .slice-i { color: var(--green); font-weight: 600; }
.data-table .slice-p { color: var(--orange); font-weight: 600; }
.data-table .slice-b { color: var(--purple); font-weight: 600; }

/* === Parameter Cards === */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.param-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.param-card-header {
  background: var(--bg-tertiary);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.param-card-header .badge {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.badge-sps { background: var(--accent-dim); color: var(--accent); }
.badge-pps { background: var(--green-dim); color: var(--green); }
.badge-vps { background: var(--orange-dim); color: var(--orange); }
.param-card-body {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 16px;
}
.param-card-body .param-item {
  display: contents;
}
.param-card-body .param-key {
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
.param-card-body .param-val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: right;
  min-width: 0;
  justify-self: stretch;
  overflow-wrap: anywhere;
  word-break: normal;
}
.param-card-body .param-full {
  grid-column: 1 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* === Frame Stats === */
.frames-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.frame-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  text-align: center;
  min-width: 80px;
}
.frame-stat .fs-val {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.frame-stat .fs-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* GOP Bar Chart (pure CSS) */
.gop-chart {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 60px;
  margin-bottom: 20px;
  padding: 4px 0;
}
.gop-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 2px 2px 0 0;
  transition: height 200ms ease;
}
.gop-bar.idr { background: var(--cyan); }
.gop-bar.i { background: var(--green); }
.gop-bar.p { background: var(--orange); }
.gop-bar.b { background: var(--purple); }

/* === SEI List === */
.sei-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sei-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.sei-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sei-item-header .sei-type {
  font-weight: 600;
  font-size: 0.95rem;
}
.sei-item-body {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: var(--radius-sm);
}

/* === Error Section === */
.error-section {
  margin-top: 24px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 20px;
}
.error-title {
  color: var(--red);
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.error-content {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text);
  white-space: pre-wrap;
}

/* === Technical Article === */
.tech-intro {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.tech-article h3 {
  font-size: 1.1rem;
  margin: 24px 0 8px;
  color: var(--text);
}
.tech-article h3:first-child {
  margin-top: 0;
}
.tech-article p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 12px;
}
.tech-article code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--accent);
}
.tech-article strong {
  color: var(--text);
}

/* === Footer === */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 24px 16px;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.footer-inner p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.footer-inner p:last-child {
  margin-bottom: 0;
}
.security-notice {
  color: var(--green) !important;
}
.security-notice strong {
  color: var(--green);
}

/* === Responsive === */
@media (max-width: 768px) {
  .site-header {
    padding: 24px 16px 16px;
  }
  .drop-zone {
    padding: 28px 16px;
  }
  .params-grid {
    grid-template-columns: 1fr;
  }
  .tab-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  .tab-panel {
    padding: 12px;
  }
  .summary-stats {
    gap: 8px;
  }
  .stat-card {
    min-width: 90px;
    padding: 10px 14px;
  }
  .stat-card .stat-value {
    font-size: 1.2rem;
  }
  .param-card-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  #panel-nal.active {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "toolbar"
      "table"
      "inspector";
  }
  #panel-nal .nal-inspector,
  #panel-nal .panel-toolbar,
  #panel-nal .table-wrap {
    min-width: 0;
  }
  #panel-nal .nal-inspector {
    position: static;
    height: auto;
  }
  .field-list,
  .binary-view {
    height: 260px;
  }
}

@media (max-width: 480px) {
  .data-table th,
  .data-table td {
    padding: 6px 8px;
    font-size: 0.78rem;
  }
  .tab-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  .param-card-body {
    grid-template-columns: 1fr;
  }
  .param-card-body .param-val {
    text-align: left;
  }
}

/* === Print === */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .tab-nav,
  .upload-section,
  .site-footer,
  .skip-link {
    display: none;
  }
  .tab-panel {
    display: block !important;
    break-inside: avoid;
  }
  .data-table th {
    background: #eee;
    color: #000;
  }
}
