/*--------------------------------------------------------------
# File format pages (formats/): ELF, PE/COFF, Mach-O
--------------------------------------------------------------*/

/* Region colors: --c background, --s strong (swatches, borders) */
.r-none  { --c: transparent; --s: #c9d2dc; }
.r-pad   { --c: #f3f4f6; --s: #b8c0ca; }
.r-hdr   { --c: #dbeafe; --s: #3b82f6; }
.r-ph    { --c: #ede9fe; --s: #8b5cf6; }
.r-sh    { --c: #ffedd5; --s: #f97316; }
.r-code  { --c: #dcfce7; --s: #22c55e; }
.r-rodata{ --c: #fef9c3; --s: #eab308; }
.r-data  { --c: #ccfbf1; --s: #14b8a6; }
.r-sym   { --c: #fce7f3; --s: #ec4899; }
.r-str   { --c: #fef3c7; --s: #d97706; }
.r-dos   { --c: #dbeafe; --s: #3b82f6; }
.r-stub  { --c: #e0e7ff; --s: #6366f1; }
.r-pe    { --c: #cffafe; --s: #06b6d4; }
.r-opt   { --c: #ede9fe; --s: #8b5cf6; }
.r-dir   { --c: #fae8ff; --s: #d946ef; }
.r-sec   { --c: #ffedd5; --s: #f97316; }
.r-iat   { --c: #fee2e2; --s: #ef4444; }
.r-imp   { --c: #fce7f3; --s: #ec4899; }
.r-rel   { --c: #e7e5e4; --s: #78716c; }
.r-lc    { --c: #ede9fe; --s: #8b5cf6; }
.r-sect  { --c: #ffedd5; --s: #f97316; }
.r-fix   { --c: #fee2e2; --s: #ef4444; }
.r-exp   { --c: #e0e7ff; --s: #6366f1; }
.r-sig   { --c: #e5e7eb; --s: #4b5563; }

.fmt-size {
  font-size: 13px;
  font-weight: 400;
  color: var(--ref-muted);
}

/* Hub */
.fmt-card {
  display: block;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fmt-card:hover {
  border-color: var(--ref-accent);
  box-shadow: 0 4px 14px rgba(5, 99, 187, 0.1);
  color: inherit;
}

.fmt-card h5 {
  font-size: 20px;
}

.fmt-magic code {
  font-size: 13px;
}

.fmt-go {
  font-weight: 600;
  color: var(--ref-accent);
}

.fmt-compare th[scope], .fmt-compare tbody th {
  white-space: nowrap;
  background: #f8f9fa;
  color: #173b6c;
  font-weight: 600;
  width: 1%;
}

/* Linker view / loader view diagrams */
.fmt-views {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 10px 0 18px;
}

.fmt-view {
  border: 1px solid var(--ref-line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.fmt-view h5 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ref-accent);
  margin-bottom: 10px;
}

.fmt-view p {
  font-size: 13.5px;
  margin: 10px 0 0;
  color: #3d4852;
}

.fv-blk, .fv-seg {
  background: var(--c);
  border-left: 4px solid var(--s);
  border-radius: 4px;
  padding: 5px 10px;
  margin-bottom: 4px;
  font-family: var(--ref-mono);
  font-size: 12.5px;
}

.fv-blk small, .fv-seg span {
  color: var(--ref-muted);
  font-family: "Open Sans", sans-serif;
}

.fv-seg {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.fv-seg code {
  background: rgba(255, 255, 255, 0.7);
}

.fv-seg.r-none {
  border: 1px dashed #c9d2dc;
  border-left: 4px dashed #c9d2dc;
}

.fv-opt {
  border-left-style: dashed;
}

.fv-dim {
  opacity: 0.55;
}

/* File map */
.fmt-sample {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.fm {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fm-blk {
  background: var(--c);
  border-left: 4px solid var(--s);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 6px;
  transition: transform 0.1s;
}

.fm-blk:hover {
  transform: translateX(3px);
}

.fm-off, .fm-sz {
  font-family: var(--ref-mono);
  font-size: 10.5px;
  color: var(--ref-muted);
}

.fm-sz {
  text-align: right;
}

.fm-l {
  grid-column: 1 / -1;
  font-weight: 700;
  color: #173b6c;
}

.fm-s {
  grid-column: 1 / -1;
  color: #4a5562;
  font-size: 11.5px;
}

/* Hex dump */
.hx-wrap {
  min-width: 0;
}

.hx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.hx-lg {
  border: 1px solid var(--ref-line);
  background: #fff;
  border-radius: 14px;
  padding: 2px 10px 2px 6px;
  font-size: 12px;
  color: #3d4852;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hx-lg.active {
  border-color: var(--ref-accent);
  background: var(--ref-accent-soft);
}

.hx-sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--s);
  flex: none;
}

.hx-main {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.hx-dump {
  position: relative;
  font-family: var(--ref-mono);
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid var(--ref-line);
  border-radius: 6px;
  padding: 6px 8px;
  max-height: 640px;
  overflow: auto;
  background: #fff;
}

.hx-row {
  display: flex;
  white-space: pre;
}

.hx-off {
  color: #9aa5b1;
  margin-right: 12px;
  user-select: none;
}

.hx-hex {
  margin-right: 12px;
}

.hx-hex .hx-b {
  display: inline-block;
  width: 2.6ch;
  text-align: center;
  margin-right: 1px;
}

.hx-hex .hx-b:nth-child(8) {
  margin-right: 0.8ch;
}

.hx-b {
  background: var(--c);
  cursor: default;
  border-radius: 2px;
  transition: background 0.08s;
}

.hx-b.r-none, .hx-pad {
  background: transparent;
}

.hx-b.r-pad {
  color: #9aa5b1;
}

.hx-b.on {
  background: var(--s);
  color: #fff;
}

.hx-b.pin {
  background: #173b6c;
  color: #fff;
}

.hx-b.dim {
  opacity: 0.25;
}

.hx-asc .hx-b {
  display: inline-block;
  width: 1ch;
}

.hx-gap .hx-gapl {
  color: #9aa5b1;
  font-style: italic;
}

.hx-side {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.hx-info {
  border: 1px solid var(--ref-line);
  border-left: 4px solid var(--s, var(--ref-accent));
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  font-size: 13px;
  min-height: 132px;
}

.hx-info .hx-ig {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ref-muted);
}

.hx-info .hx-in {
  font-family: var(--ref-mono);
  font-weight: 700;
  font-size: 15px;
  color: #173b6c;
  margin: 2px 0 4px;
  word-break: break-word;
}

.hx-info .hx-iv {
  font-family: var(--ref-mono);
  background: var(--c, var(--ref-fixed));
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin: 2px 0 6px;
  word-break: break-all;
}

.hx-info .hx-io {
  font-family: var(--ref-mono);
  font-size: 11.5px;
  color: var(--ref-muted);
}

.hx-info .hx-ir {
  font-family: var(--ref-mono);
  font-size: 11.5px;
  color: #4a5562;
  word-break: break-all;
  margin-top: 4px;
}

.hx-info .hx-id {
  margin: 6px 0 0;
  color: #272829;
}

.hx-hint {
  color: var(--ref-muted);
  margin: 0;
}

.hx-tree {
  border: 1px solid var(--ref-line);
  border-radius: 6px;
  max-height: 440px;
  overflow: auto;
  font-size: 12.5px;
  background: #fff;
}

.hx-g summary {
  padding: 5px 10px;
  cursor: pointer;
  font-weight: 600;
  color: #173b6c;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #eef1f4;
  position: sticky;
  top: 0;
  background: #fff;
}

.hx-g summary small {
  font-family: var(--ref-mono);
  color: var(--ref-muted);
  font-weight: 400;
  margin-left: auto;
}

.hx-g ul {
  list-style: none;
  margin: 0;
  padding: 2px 0 6px;
}

.hx-g li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 10px 1px 26px;
  cursor: pointer;
}

.hx-g li:hover, .hx-g li.on {
  background: var(--ref-accent-soft);
}

.hx-g li.pin {
  background: #173b6c;
  color: #fff;
}

.hx-g li.pin .hx-tv {
  color: #dbe7f5;
}

.hx-tn {
  font-family: var(--ref-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hx-tv {
  font-family: var(--ref-mono);
  color: var(--ref-muted);
  white-space: nowrap;
}

/* Import diagram */
.fmt-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0 18px;
}

.ff-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ff-box {
  background: var(--c);
  border-left: 4px solid var(--s);
  border-radius: 4px;
  padding: 7px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

.ff-box b {
  font-family: var(--ref-mono);
  color: #173b6c;
}

.ff-box span {
  font-size: 12px;
  color: #4a5562;
}

.ff-arrows {
  display: flex;
  flex-direction: column;
  gap: 22px;
  font-family: var(--ref-mono);
  font-size: 12px;
  color: var(--ref-muted);
}

/* Bit fields */
.bf-wrap {
  margin: 10px 0 14px;
}

.bf-t {
  font-family: var(--ref-mono);
  font-weight: 700;
  font-size: 13px;
  color: #173b6c;
  margin-bottom: 4px;
}

.bf {
  display: grid;
  border: 1px solid #c9d2dc;
  border-radius: 6px;
  overflow: hidden;
  font-family: var(--ref-mono);
  font-size: 12px;
}

.bf-64 {
  grid-template-columns: repeat(64, minmax(0, 1fr));
}

.bf-32 {
  grid-template-columns: repeat(32, minmax(0, 1fr));
  max-width: 640px;
}

.bf-f {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-right: 1px solid #c9d2dc;
  padding: 2px 1px 4px;
  background: var(--ref-accent-soft);
  min-width: 0;
}

.bf-f:last-child {
  border-right: none;
}

.bf-flag {
  background: #fde68a;
}

.bf-r, .bf-w {
  font-size: 10px;
  color: var(--ref-muted);
  white-space: nowrap;
}

.bf-n {
  font-weight: 600;
  color: #173b6c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 1199px) {
  .fmt-sample {
    grid-template-columns: 1fr;
  }
  .fm {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}

@media (max-width: 991px) {
  .fmt-views, .hx-main {
    grid-template-columns: 1fr;
  }
  .hx-side {
    position: static;
  }
}

@media (max-width: 768px) {
  .hx-dump {
    font-size: 11px;
  }
  .hx-asc {
    display: none;
  }
}
