:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 4px 16px rgb(16 24 40 / 0.06);
  --topbar-height: 3.25rem;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #121826;
    --surface-muted: #0f1520;
    --border: #232b3a;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-soft: #172036;
    --danger: #fca5a5;
    --danger-soft: #2a1414;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar-height);
  padding: 0 clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand svg { width: 22px; height: 22px; color: var(--accent); }

.tagline { color: var(--text-muted); font-size: 0.85rem; }

main { padding: clamp(1rem, 3vw, 2rem); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 150ms ease;
}

.button:hover { background: var(--accent-hover); }
.button:focus-visible, :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button svg { width: 17px; height: 17px; }

.button.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.button.secondary:hover { background: var(--surface-muted); }

.error {
  padding: 0.75rem 1rem;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 10px;
  font-size: 0.9rem;
}

/* Intro */

.dropzone {
  max-width: 620px;
  margin: clamp(2rem, 10vh, 6rem) auto 0;
  padding: clamp(2rem, 6vw, 3.5rem);
  text-align: center;
}

.dropzone-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 1.25rem;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}

.dropzone-icon svg { width: 28px; height: 28px; }

.dropzone h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dropzone p { margin: 0 auto 1.5rem; max-width: 42ch; color: var(--text-muted); }
.dropzone .hint { margin: 1.25rem auto 0; font-size: 0.82rem; }
.dropzone .error { margin-top: 1.25rem; text-align: left; }

/* Results */

.result {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
}

.summary {
  position: sticky;
  top: calc(var(--topbar-height) + 1.5rem);
  overflow: hidden;
}

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 260px;
  padding: 1rem;
  background:
    repeating-conic-gradient(var(--surface-muted) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px;
  border-bottom: 1px solid var(--border);
}

.preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.15);
}

.summary-body { padding: 1.25rem; }

.summary h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.file-meta { margin: 0.2rem 0 0; color: var(--text-muted); font-size: 0.85rem; }

.highlights {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1rem;
  margin: 1.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}

.highlights dt { color: var(--text-muted); }
.highlights dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.highlights a { color: var(--accent); text-decoration: none; }
.highlights a:hover { text-decoration: underline; }

.summary .button { width: 100%; margin-top: 1.25rem; }

.tags { display: grid; gap: 1rem; min-width: 0; }

.table-card { overflow: clip; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th, td { padding: 0.6rem 1.1rem; text-align: left; vertical-align: top; }

tbody tr + tr td { border-top: 1px solid var(--border); }
tbody tr:hover td { background: var(--surface-muted); }

.group th {
  position: sticky;
  top: calc(var(--topbar-height) - 1px);
  z-index: 1;
  padding: 0.7rem 1.1rem;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

tbody:first-child .group th { border-top: none; }

.count {
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--border);
  font-weight: 600;
  letter-spacing: 0;
}

td.name { width: 34%; font-weight: 550; overflow-wrap: break-word; }

td.name .id {
  display: inline-block;
  margin-left: 0.5rem;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

td.value {
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

td.value .raw {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

td.value summary { cursor: pointer; color: var(--accent); font-family: inherit; }

td.value pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  max-height: 320px;
  overflow: auto;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
}

/* Drag overlay */

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(4px);
}

.drag-overlay.visible { display: grid; }

.drag-box {
  display: grid;
  place-items: center;
  gap: 0.75rem;
  width: min(100%, 960px);
  height: min(100%, 560px);
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent-soft) 60%, transparent);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.drag-box svg { width: 56px; height: 56px; }

@media (max-width: 900px) {
  .tagline { display: none; }
  .result { grid-template-columns: 1fr; }
  .summary { position: static; }
  .preview { height: 200px; }
  th, td, .group th { padding-left: 0.85rem; padding-right: 0.85rem; }
  td.name { width: 42%; }
}
