* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Main layout ---- */
.hex-main {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}

/* ---- Hex view ---- */
.hex-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sz-color-window);
  color: var(--sz-color-window-text);
  border-top: 1px solid var(--sz-color-button-shadow);
  min-width: 0;
}

.hex-header {
  display: flex;
  flex-shrink: 0;
  font-family: 'Consolas', 'Lucida Console', 'Courier New', monospace;
  font-size: 13px;
  line-height: 18px;
  background: var(--sz-color-button-face);
  border-bottom: 1px solid var(--sz-color-button-shadow);
  color: var(--sz-color-button-text);
  user-select: none;
  padding: 2px 0;
}

.hex-header .offset-col {
  color: var(--sz-color-gray-text);
  font-weight: bold;
}

.hex-header .hex-col {
  font-weight: bold;
}

.hex-header .ascii-col {
  font-weight: bold;
}

.hex-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  outline: none;
}

.hex-scroll-content {
  position: relative;
}

.hex-rows {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.hex-row {
  display: flex;
  font-family: 'Consolas', 'Lucida Console', 'Courier New', monospace;
  font-size: 13px;
  line-height: 18px;
  height: 18px;
  user-select: none;
  cursor: default;
}

.hex-row:hover {
  background: rgba(0,0,0,0.03);
}

.offset-col {
  flex-shrink: 0;
  color: #336699;
  padding: 0 8px 0 4px;
  text-align: right;
}

.hex-col {
  flex: 1;
  padding: 0 8px;
  display: flex;
  gap: 0;
  letter-spacing: 0;
}

.hex-byte {
  display: inline-block;
  width: 22px;
  text-align: center;
  cursor: default;
}

.hex-byte.group-space {
  margin-right: 6px;
}

.hex-byte.cursor {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
}

.hex-byte.modified {
  color: #cc0000;
}

.hex-byte.modified.cursor {
  background: #cc0000;
  color: #fff;
}

.hex-byte.selected {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
  opacity: 0.6;
}

.hex-byte.found {
  background: #ffff00;
  color: #000;
}

.hex-byte.struct-field {
  color: #000;
}

.hex-byte.struct-field.cursor {
  outline: 2px solid var(--sz-color-highlight);
  outline-offset: -2px;
}

.ascii-sep {
  width: 1px;
  background: var(--sz-color-button-shadow);
  flex-shrink: 0;
  align-self: stretch;
}

.ascii-col {
  flex-shrink: 0;
  padding: 0 4px;
  display: flex;
  gap: 0;
}

.ascii-byte {
  display: inline-block;
  width: 8px;
  text-align: center;
  cursor: default;
}

.ascii-byte.non-printable {
  color: var(--sz-color-gray-text);
}

.ascii-byte.cursor {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
}

.ascii-byte.modified {
  color: #cc0000;
}

.ascii-byte.modified.cursor {
  background: #cc0000;
  color: #fff;
}

.ascii-byte.selected {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
  opacity: 0.6;
}

.ascii-byte.found {
  background: #ffff00;
  color: #000;
}

/* ---- Status bar ---- */
.status-bar {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--sz-color-button-face);
  border-top: 1px solid var(--sz-color-button-shadow);
  font-size: 11px;
  color: var(--sz-color-button-text);
  flex-shrink: 0;
  user-select: none;
  gap: 16px;
}

.status-bar .status-section {
  white-space: nowrap;
}

.status-bar .status-section.mode {
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

/* App-specific dialog overrides */
.dialog-body label {
  display: block;
  margin-bottom: 4px;
}

.dialog-body input[type="text"] {
  font-family: 'Consolas', 'Lucida Console', monospace;
  border: 1px inset var(--sz-color-button-shadow);
}

.dialog-body .radio-group {
  margin: 8px 0;
}

.dialog-body .radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  cursor: default;
}

/* Empty state */
.hex-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--sz-color-gray-text);
  font-size: 13px;
  font-style: italic;
}

/* Active column indicator */
.hex-col.active-column {
  outline: 1px dotted rgba(0,0,0,0.1);
}

.ascii-col.active-column {
  outline: 1px dotted rgba(0,0,0,0.1);
}

/* ---- Struct Panel ---- */
.struct-panel {
  width: 300px;
  min-width: 220px;
  border-left: 1px solid var(--sz-color-button-shadow);
  background: var(--sz-color-window);
  color: var(--sz-color-window-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.struct-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--sz-color-button-face);
  border-bottom: 1px solid var(--sz-color-button-shadow);
  flex-shrink: 0;
}

.struct-panel-title {
  font-size: 11px;
  font-weight: bold;
  color: var(--sz-color-button-text);
}

.struct-panel-close {
  border: none;
  background: transparent;
  font-size: 14px;
  cursor: default;
  color: var(--sz-color-button-text);
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 2px;
  padding: 0;
}

.struct-panel-close:hover {
  background: var(--sz-color-button-highlight);
}

/* ---- Scroll wrapper (single scrollbar for the whole panel) ---- */
.struct-panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.struct-panel-scroll::-webkit-scrollbar {
  width: 8px;
}

.struct-panel-scroll::-webkit-scrollbar-thumb {
  background: var(--sz-color-button-shadow);
  border-radius: 4px;
}

/* ---- Accordion ---- */
.struct-accordion-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--sz-color-button-face);
  border-bottom: 1px solid var(--sz-color-button-shadow);
  font-size: 11px;
  font-weight: bold;
  color: var(--sz-color-button-text);
  cursor: default;
  user-select: none;
}

.struct-accordion-header:hover {
  background: var(--sz-color-button-highlight, rgba(0,0,0,0.05));
}

.struct-accordion-toggle {
  font-size: 8px;
  color: var(--sz-color-gray-text);
  width: 10px;
  text-align: center;
  flex-shrink: 0;
}

.struct-accordion-body {
  font-family: 'Consolas', 'Lucida Console', 'Courier New', monospace;
  font-size: 11px;
  line-height: 16px;
  padding: 2px 0;
}

.struct-accordion-body.collapsed {
  display: none;
}

/* Inspector endian toggle */
.inspector-endian-toggle {
  margin-left: auto;
  font-weight: normal;
  font-size: 10px;
}

.inspector-endian-select {
  font-size: 10px;
  padding: 0 2px;
  border: 1px solid var(--sz-color-button-shadow);
  background: var(--sz-color-window);
  color: var(--sz-color-window-text);
  cursor: default;
}

/* ---- Data Inspector ---- */
.inspector-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 1px;
  font-size: 10px;
  font-weight: bold;
  color: var(--sz-color-gray-text);
  border-left: 3px solid var(--sz-color-highlight);
  margin: 2px 0 0;
  font-family: sans-serif;
  cursor: default;
  user-select: none;
}

.inspector-group-header:hover {
  color: var(--sz-color-button-text);
}

.inspector-group-toggle {
  font-size: 7px;
  width: 8px;
  text-align: center;
  flex-shrink: 0;
}

.inspector-group-body.collapsed {
  display: none;
}

.inspector-row {
  display: flex;
  align-items: center;
  padding: 1px 6px 1px 14px;
  gap: 4px;
  min-height: 16px;
  cursor: default;
}

.inspector-row:hover {
  background: var(--sz-color-button-highlight, rgba(0,0,0,0.05));
}

.inspector-type {
  flex-shrink: 0;
  width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--sz-color-gray-text);
  font-size: 10px;
}

.inspector-value {
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #336699;
}

.inspector-value.na {
  color: var(--sz-color-gray-text);
  opacity: 0.5;
}

.inspector-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 1px;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}

.inspector-empty {
  padding: 12px;
  color: var(--sz-color-gray-text);
  font-size: 11px;
  font-style: italic;
  text-align: center;
  font-family: sans-serif;
}

/* Template section in struct panel */
.struct-template-section {
  margin-bottom: 2px;
}

.struct-template-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: var(--sz-color-button-face);
  border-bottom: 1px solid var(--sz-color-button-shadow);
  font-size: 10px;
  font-weight: bold;
  color: var(--sz-color-button-text);
  cursor: default;
  user-select: none;
}

.struct-template-header .struct-tmpl-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.struct-template-header .struct-tmpl-offset {
  color: var(--sz-color-gray-text);
  font-weight: normal;
}

.struct-template-header .struct-tmpl-remove {
  border: none;
  background: transparent;
  font-size: 12px;
  cursor: default;
  color: var(--sz-color-button-text);
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 2px;
  padding: 0;
  flex-shrink: 0;
}

.struct-template-header .struct-tmpl-remove:hover {
  background: #c42b1c;
  color: #fff;
}

/* Tree nodes */
.struct-node {
  user-select: none;
}

.struct-node-row {
  display: flex;
  align-items: center;
  padding: 1px 4px 1px 0;
  cursor: default;
  gap: 3px;
  min-height: 16px;
}

.struct-node-row:hover {
  background: var(--sz-color-button-highlight, rgba(0,0,0,0.05));
}

.struct-node-row.active {
  background: var(--sz-color-highlight);
  color: var(--sz-color-highlight-text);
}

.struct-node-toggle {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  font-size: 8px;
  color: var(--sz-color-gray-text);
}

.struct-node-swatch {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}

.struct-node-name {
  flex-shrink: 0;
  white-space: nowrap;
}

.struct-node-type {
  color: var(--sz-color-gray-text);
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 10px;
}

.struct-node-value {
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #336699;
  padding-left: 4px;
}

.struct-node-row.active .struct-node-value {
  color: var(--sz-color-highlight-text);
}

.struct-node-bits {
  font-size: 9px;
  color: var(--sz-color-gray-text);
}

.struct-node-children {
  padding-left: 16px;
}

.struct-node-edit {
  width: 80px;
  font-family: inherit;
  font-size: inherit;
  border: 1px solid var(--sz-color-highlight);
  padding: 0 2px;
  text-align: right;
  background: var(--sz-color-window);
  color: var(--sz-color-window-text);
}

/* Empty struct panel state */
.struct-panel-empty {
  padding: 12px;
  color: var(--sz-color-gray-text);
  font-size: 11px;
  font-style: italic;
  text-align: center;
  font-family: sans-serif;
}
