* { box-sizing: border-box; }
:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --line: #e6e8f0;
  --ink: #1a1f2e;
  --muted: #6b7180;
  --accent: #2768f8;
  --accent-soft: #e7eeff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #2772dd, #8260c8);
  color: white; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
}
.title { font-weight: 600; font-size: 15px; }
.subtitle { color: var(--muted); font-size: 12px; }
.actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-block; cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px;
  transition: background .15s, transform .05s;
  user-select: none;
}
.btn:hover { background: #f0f2f8; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: white; }
.btn.primary:hover { background: #1a52d3; }
.btn.link { background: transparent; border-color: transparent; color: var(--muted); }

main { padding: 24px 20px 60px; max-width: 1280px; margin: 0 auto; position: relative; }

.download-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 32px -8px rgba(20,30,80,0.18);
  min-width: 220px;
  padding: 4px;
  z-index: 20;
}
.dropdown button {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 8px 12px;
  border-radius: 6px; font: inherit; color: var(--ink);
  cursor: pointer;
}
.dropdown button:hover { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty { display: grid; place-items: center; padding: 60px 0; }
.empty-card {
  max-width: 540px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  text-align: left;
  box-shadow: 0 4px 24px -12px rgba(20,30,80,0.08);
}
.empty-logo { font-size: 40px; text-align: center; }
.empty-card h1 { margin: 16px 0 8px; font-size: 22px; }
.empty-card ul { padding-left: 18px; color: var(--muted); margin: 12px 0; }
.empty-card li { margin: 4px 0; }
.empty-card code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; }
.empty-card .hint { color: var(--muted); margin-top: 18px; font-size: 13px; }

.filebar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  border-bottom: 0;
}
.filename { font-weight: 600; font-family: var(--mono); font-size: 13px; }
.stats { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-left: auto; }

.tabs {
  display: flex; gap: 4px;
  padding: 6px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  appearance: none; cursor: pointer;
  background: transparent; border: 0;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  border-top: 0;
  padding: 14px;
  min-height: 420px;
}
.panel.hidden { display: none; }

.pager {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.pager .spacer { flex: 1; }
.pager button {
  appearance: none; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px;
  font: inherit; color: var(--ink);
}
.pager button:hover { background: var(--accent-soft); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

#preview {
  display: block; max-width: 100%; margin: 0 auto;
  background: white;
  box-shadow: 0 4px 18px -8px rgba(20,30,80,0.18);
  border: 1px solid var(--line);
}

table.kv { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
table.kv th, table.kv td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; word-break: break-word; }
table.kv th { font-weight: 600; color: var(--muted); width: 32%; white-space: nowrap; }

.layer-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg);
  margin-bottom: 8px;
}
.layer-row .eye {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px;
  background: var(--accent-soft); color: var(--accent); cursor: pointer;
}
.layer-row.off .eye { background: #f0f2f8; color: var(--muted); }
.layer-row.off .name { color: var(--muted); text-decoration: line-through; }
.layer-row .name { font-weight: 600; font-size: 13px; }
.layer-row .sub { color: var(--muted); font-size: 11px; font-family: var(--mono); }

pre.hex, pre.raw {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre;
  overflow: auto;
  max-height: 70vh;
  margin: 0;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
}

#dragHint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: var(--accent); color: white; font-weight: 600;
  padding: 16px 28px; border-radius: 14px;
  box-shadow: 0 14px 38px -12px rgba(39,104,248,0.45);
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
  z-index: 10;
}
main.dragover #dragHint { opacity: 1; }
main.dragover { outline: 3px dashed var(--accent); outline-offset: -16px; border-radius: 18px; }

footer {
  padding: 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 720px) {
  .actions { flex-wrap: wrap; }
  .filename { max-width: 50vw; overflow: hidden; text-overflow: ellipsis; }
  .empty-card { padding: 22px 18px; }
}
