:root {
  --bg: #f7f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-600: #1d4ed8;
  --accent-700: #1e40af;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.25);
  --accent-rail: rgba(37, 99, 235, 0.28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  padding-top: 60px;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }

.container { max-width: 980px; margin: 0 auto; padding: 28px 16px 72px; }

#initial-section h1 {
  font-size: clamp(18px, 3.2vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 6px 0;
}
#initial-section h2 {
  font-size: clamp(16px, 2.6vw, 22px);
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted);
  max-width: 840px;
  margin: 6px 0 18px 0;
}

header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  background: var(--bg);
  backdrop-filter: saturate(180%) blur(10px);
}


.header-inner { max-width: 980px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.brand { display: flex; gap: 10px; align-items: center; }
.brand svg { width: 22px; height: 22px; color: var(--accent-600); }
h1 { margin: 0; font-size: clamp(18px, 3vw, 20px); font-weight: 600; letter-spacing: -0.01em; }
.tagline { display: none; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.search { display: none; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; min-height: 48px; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { width: 100%; border: none; outline: none; background: transparent; color: var(--text); font-size: 14px; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow);
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus), var(--shadow); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn.primary { border-color: transparent; background: linear-gradient(180deg, var(--accent), var(--accent-600)); color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, var(--accent-600), var(--accent-700)); }

#exportBtn {
  background: linear-gradient(180deg, #83a598, #458588);
  color: #fff;
}
#exportBtn:hover {
  background: linear-gradient(180deg, #458588, #076678);
}

.btn.icon { padding: 8px; border-radius: 999px; width: 36px; height: 36px; justify-content: center; }

.drop { display: grid; gap: 10px; }
.sample-link { color: var(--text); text-decoration: underline; font-size: 14px; }
.dropzone {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .06s ease;
  box-shadow: var(--shadow);
}

.dropzone .dz-icon { width: 28px; height: 28px; color: #458588; margin-bottom: 6px; opacity: .9; }
.dropzone .hint { color: var(--muted); font-size: 14px; }
.dropzone.is-dragover { background: color-mix(in srgb, var(--accent) 6%, transparent); border-color: var(--accent); }
.dropzone:hover .drop-text { text-decoration: underline dotted; }

input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.results { margin-top: 24px; display: grid; gap: 14px; }

details.file-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
summary.file-summary {
  list-style: none; cursor: pointer; padding: 14px 16px; margin: 0;
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; font-weight: 600;
  color: #f2f2f2; background: #0b0b0b;
}
summary.file-summary:hover .file-title {
  text-decoration: underline;
}
summary.file-summary::-webkit-details-marker { display: none; }
.file-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-title { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.file-summary .file-title { color: #ffffff; }
.file-stats { display: flex; gap: 8px; align-items: center; }
.stat { font-size: 12px; color: var(--text); background: rgba(99,102,241,0.08); border: 1px solid var(--border); padding: 4px 8px; border-radius: 999px; }

details.group { border: none; border-radius: 0; background: var(--panel); overflow: hidden; }
summary.group-summary {
  list-style: none; cursor: pointer; padding: 10px 12px 10px 50px; margin: 0;
  display: grid; grid-template-columns: 180px 1fr auto; align-items: center; gap: 12px; font-weight: 600;
  background: linear-gradient(to right, color-mix(in srgb, var(--accent) 10%, transparent) 0% var(--fill-percentage), transparent var(--fill-percentage) 100%);
  position: relative;
}
summary.group-summary:hover .desc-muted,
summary.group-summary:hover .group-amt,
summary.group-summary:hover .badge {
  text-decoration: underline;
}
summary.group-summary::-webkit-details-marker { display: none; }
.group-amt { font-weight: 600; }
.badge { font-size: 12px; color: var(--muted); background: rgba(37, 99, 235, 0.1); padding: 4px 8px; border-radius: 999px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }


.desc-muted { color: var(--muted); font-size: 14px; font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tx-list { padding: 8px 12px 12px; display: grid; gap: 4px; }
.tx { display: grid; grid-template-columns: 180px 1fr; gap: 12px; border-radius: 8px; background: transparent; border: none; }
.tx small { color: var(--muted); }

.note { color: var(--muted); font-size: 14px; padding: 0 16px 16px; }

details > summary:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 0; }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 28px 16px 48px; }

details.group[open] .group-summary {
  background: linear-gradient(to right, color-mix(in srgb, var(--accent) 14%, transparent) 0% var(--fill-percentage), transparent var(--fill-percentage) 100%);
  box-shadow: inset 0 -1px 0 var(--border);
}

details.group[open] .tx-list {
  border-left: 2px solid var(--accent-rail);
  margin-left: 6px;
  padding-left: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 2%, transparent), transparent);
}

.remove-group {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  color: #ef4444;
  padding: 4px;
  border-radius: 4px;
}
.group-summary:hover .remove-group {
  opacity: 1;
}
.remove-group:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

@media (max-width: 640px) {
  .search input { width: 100%; }
  .tx { grid-template-columns: 120px 1fr; }
  summary.group-summary { grid-template-columns: 120px 1fr auto; }
}
