:root {
  color-scheme: dark;
  --bg: #08080b;
  --surface: #111116;
  --surface-raised: #17171e;
  --surface-deep: #09090d;
  --line: #292931;
  --text: #f4f4f7;
  --muted: #8b8b9a;
  --red: #ff2028;
  --red-bright: #ff171f;
  --green: #51d69a;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(900px 480px at 50% -220px, #251011 0%, transparent 72%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a,
.link {
  color: #ff555b;
}

.topbar,
.tabs,
main,
footer {
  width: min(1240px, calc(100% - 48px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 4px 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.logo {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #ff30384d;
  border-radius: 12px;
  background: #1a0c0e;
  color: var(--red);
  font-size: 23px;
}

.logo img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 1.5px;
}

.brand-sub,
.engine {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

.engine {
  text-align: right;
  line-height: 1.8;
}

#engineStatus {
  color: var(--green);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 15px 0 17px;
  scrollbar-width: thin;
}

.tab,
.seg-btn,
.ptab,
.ptab2 {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #111116;
  color: #aaaab5;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .35px;
  white-space: nowrap;
}

.tab {
  padding: 10px 13px;
}

.tab:hover,
.seg-btn:hover,
.ptab:hover,
.ptab2:hover {
  border-color: #ff454b88;
  color: var(--text);
}

.tab.active,
.seg-btn.active,
.ptab.active,
.ptab2.active {
  border-color: #ff303866;
  background: #241012;
  color: #ff6268;
}

main {
  min-height: 55vh;
  padding: 5px 0 34px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.upload-card,
.hex-card,
.filebar,
.viewbar,
.toolbar,
.bulk-box,
.side-box {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: linear-gradient(155deg, #131318, #0e0e13 78%);
  box-shadow: 0 14px 38px #0003;
}

.upload-card {
  margin: 0 0 16px;
  padding: 32px;
}

#uploadCard {
  min-height: 345px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-icon {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto 13px;
  place-items: center;
  border: 1px solid #ff343b33;
  border-radius: 19px;
  background: #210e10;
  box-shadow: 0 0 28px #ff202822;
  color: var(--red);
  font-size: 28px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.25;
}

h2 {
  font-size: 21px;
}

h3 {
  margin-bottom: 10px;
  font-size: 17px;
}

p {
  color: #a1a1ae;
}

#uploadCard > p {
  margin-bottom: 18px;
  max-width: 650px;
}

.red {
  color: var(--red);
}

.green {
  color: var(--green);
}

.muted,
.small {
  color: var(--muted);
}

.small {
  font-size: 11px;
}

.upload-meta {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  color: #ff5b61;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}

.hint {
  margin-top: 6px;
  color: #b0b0bb;
  text-align: center;
}

.btn-red,
.btn-ghost,
.link,
.x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.btn-red {
  padding: 10px 16px;
  border: 1px solid #ff3038;
  background: linear-gradient(135deg, #ff3038, #ed111a);
  box-shadow: 0 5px 20px #ff1c2638;
  color: white;
  font-size: 12px;
  letter-spacing: .45px;
}

.btn-red:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #ff4a50, #f21a23);
}

.btn-red:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.btn-red.full {
  width: 100%;
}

.btn-red.big {
  min-height: 48px;
  font-size: 13px;
}

.btn-ghost {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #191920;
  color: #d0d0d8;
  font-size: 11px;
}

.btn-ghost:hover {
  border-color: #ff444b77;
  background: #211416;
}

.btn-ghost.danger {
  border-color: #ff30384d;
  color: #ff6268;
}

.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #ff6268;
  font-size: inherit;
}

.link:hover {
  color: #ff969a;
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.progress {
  width: min(460px, 100%);
  height: 8px;
  margin: 20px auto 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #25252d;
}

.progress > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
  transition: width .25s ease;
}

.scan-status {
  display: flex;
  justify-content: space-between;
  width: min(460px, 100%);
  margin: 0 auto 15px;
  color: #ff6268;
  font-size: 11px;
  font-weight: 800;
}

.spinner {
  width: 35px;
  height: 35px;
  margin: 0 auto 17px;
  border: 3px solid #37373f;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.filebar,
.viewbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
}

.file-left,
.file-right,
.row,
.seg {
  display: flex;
  align-items: center;
  gap: 9px;
}

.file-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-ico {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: #211012;
  color: var(--red);
  font-size: 21px;
}

.file-name {
  font-weight: 800;
}

.viewbar input {
  flex: 1 1 260px;
}

.toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.toolbar.thin {
  padding: 10px 12px;
}

.stats {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.stats > span:first-child {
  color: var(--red);
}

input:not([type="checkbox"]):not([type="file"]),
select,
textarea {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #2a2a34;
  border-radius: 10px;
  outline: none;
  background: #0a0a0f;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #ff434b99;
  box-shadow: 0 0 0 3px #ff202814;
}

input::placeholder,
textarea::placeholder {
  color: #696976;
}

select {
  max-width: 100%;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #ff3a4280;
}

.card.missing {
  opacity: .65;
}

.card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.sub {
  color: var(--muted);
  font-size: 10px;
}

.rva {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: #ff7277;
  font-family: Consolas, monospace;
}

.badge,
.pill-green {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid #ff41484d;
  border-radius: 99px;
  background: #241012;
  color: #ff7277;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .55px;
}

.badge.INT { color: #f8c66b; border-color: #f8c66b44; background: #211b10; }
.badge.FLOAT { color: #77baff; border-color: #77baff44; background: #101a25; }
.badge.VOID { color: #c394ff; border-color: #c394ff44; background: #1b1225; }
.badge.MISSING { color: var(--muted); }

.bulk-box,
.side-box {
  margin: 12px 0;
  padding: 16px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.between {
  justify-content: space-between;
}

.bulk-box label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #bdbdc7;
  font-size: 11px;
}

.bulk-box select {
  min-height: 34px;
  max-width: 210px;
  padding: 6px 8px;
  font-size: 11px;
}

.bulk-box input[type="checkbox"] {
  accent-color: var(--red);
}

.table-wrap {
  max-width: 100%;
  margin: 10px 0 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #191920;
  color: #ff656b;
  font-size: 10px;
  letter-spacing: .6px;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: #ffffff05;
}

.code,
.terminal,
pre {
  max-width: 100%;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-deep);
  color: #d4d4df;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.viewer-search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.viewer-search input {
  flex: 1 1 190px;
}

.hex-head {
  margin-bottom: 14px !important;
  padding: 30px 32px !important;
}

.hex-head-left p {
  margin-bottom: 0;
}

.hex-head-right {
  display: flex;
  gap: 8px;
}

.hex-ico {
  display: inline-block;
  color: var(--red);
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: .95;
}

.hex-top {
  margin-bottom: 14px;
}

.hex-card {
  min-width: 0;
  padding: 22px;
}

.hex-top .hex-card {
  min-height: 215px;
}

.hex-top .hex-card > p {
  margin: 8px 0;
}

.hex-top .upload-icon {
  width: 64px;
  height: 64px;
}

.hex-top .btn-red,
.hex-top .btn-ghost {
  margin-top: 8px;
}

.jump-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-deep);
  color: var(--red);
  font-weight: 800;
}

.jump-input input {
  flex: 1;
  border: 0 !important;
  box-shadow: none !important;
  font-family: Consolas, monospace;
  letter-spacing: 1px;
}

.hex-out {
  padding: 22px;
}

.hex-out .row {
  margin-bottom: 12px;
}

.hex-bytes {
  display: grid;
  grid-template-columns: repeat(16, minmax(24px, 1fr));
  gap: 5px;
  min-height: 45px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #08080b;
  font-family: Consolas, monospace;
}

.hex-byte,
.byte {
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #c8c8d2;
  text-align: center;
  cursor: pointer;
}

.hex-byte:hover,
.byte:hover,
.hex-byte.selected,
.byte.selected {
  border-color: #ff414866;
  background: #351317;
  color: #ff747a;
}

.check-box {
  display: grid;
  width: 48px;
  height: 48px;
  margin: auto auto 10px;
  place-items: center;
  border-radius: 14px;
  background: #10251b;
  color: var(--green);
  font-size: 24px;
}

.pill-green {
  border-color: #51d69a55;
  background: #10251b;
  color: var(--green);
}

.so-name {
  margin: 9px 0 3px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #000b;
  backdrop-filter: blur(5px);
}

.modal-box {
  width: min(1000px, 100%);
  max-height: min(90vh, 950px);
  overflow: auto;
  padding: 22px;
  border: 1px solid #393941;
  border-radius: 17px;
  background: #111116;
  box-shadow: 0 24px 80px #000a;
}

.modal-head,
.patch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
}

.x {
  width: 36px;
  border: 1px solid var(--line);
  background: #1a1a21;
}

.patch-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.ptab,
.ptab2 {
  padding: 8px 11px;
}

.patch-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  max-height: 250px;
  margin: 10px 0;
  overflow: auto;
}

.patch-item,
.preset-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0c0c11;
  color: #ddd;
  cursor: pointer;
}

.patch-item:hover,
.preset-item:hover {
  border-color: #ff434b88;
}

.aob-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr);
  gap: 14px;
  margin: 14px 0;
}

.aob-grid .side-box {
  margin-top: 0;
}

#toast {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: none;
  padding: 11px 16px;
  border: 1px solid #ff414866;
  border-radius: 10px;
  background: #1b1012;
  color: white;
  box-shadow: 0 8px 30px #0008;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 24px;
  border-top: 1px solid var(--line);
  color: #666672;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .7px;
}

footer .right {
  text-align: right;
}

.login-wrap {
  min-height: 100vh;
}

.login-box .logo {
  margin-inline: auto;
}

.login-box .btn-red {
  margin-top: 8px;
}

.login-logo {
  max-width: 140px;
  max-height: 60px;
  object-fit: contain;
}

@media (max-width: 760px) {
  .topbar,
  .tabs,
  main,
  footer {
    width: min(100% - 28px, 1240px);
  }

  .topbar {
    padding-top: 16px;
  }

  .upload-card {
    padding: 24px 18px;
  }

  #uploadCard {
    min-height: 300px;
  }

  .filebar,
  .viewbar {
    align-items: stretch;
    flex-direction: column;
  }

  .file-right {
    justify-content: flex-start;
  }

  .seg {
    max-width: 100%;
    overflow-x: auto;
  }

  .hex-card,
  .hex-out {
    padding: 18px;
  }

  .hex-bytes {
    grid-template-columns: repeat(8, minmax(24px, 1fr));
  }

  .aob-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  footer {
    flex-direction: column;
  }

  footer .right {
    text-align: left;
  }
}

@media (max-width: 420px) {
  .brand-title {
    font-size: 13px;
  }

  .brand-sub {
    font-size: 9px;
  }

  .engine {
    font-size: 9px;
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .hex-bytes {
    grid-template-columns: repeat(4, minmax(24px, 1fr));
  }

  .modal {
    padding: 10px;
  }

  .modal-box {
    padding: 15px;
  }
}
