:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1e222d;
  --border: #2a2f3c;
  --text: #e6e8ee;
  --muted: #9aa1b1;
  --accent: #6ea8fe;
  --good: #4ade80;
  --mid: #facc15;
  --bad: #f87171;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  padding-right: max(20px, calc((100% - 1200px) / 2 + 20px));
}
.topbar-inner h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; white-space: nowrap; }
.topbar-inner form.upload { margin: 0 0 0 auto; flex-wrap: nowrap; }
.upload-filename {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  display: inline-block;
  max-width: 48ch;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
}
.upload-filename > bdi { direction: ltr; unicode-bidi: isolate; }

main { padding: 32px 0 64px; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  margin: 0 0 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 14px; }

.hero h1 { font-size: 30px; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0; }

form.upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.browse-button {
  display: inline-block;
  background: var(--accent);
  color: #0b1020;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.browse-button:hover { filter: brightness(1.08); }
button {
  background: var(--accent);
  color: #0b1020;
  border: 0;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 650;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }

.disclosure { color: var(--muted); font-size: 13px; margin-top: 14px; }

.error {
  border: 1px solid #5a2a2a;
  background: #2a1616;
  color: #fca5a5;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.badge.high { background: rgba(74,222,128,0.15); color: var(--good); border: 1px solid rgba(74,222,128,0.4); }
.badge.medium { background: rgba(250,204,21,0.15); color: var(--mid); border: 1px solid rgba(250,204,21,0.4); }
.badge.low { background: rgba(248,113,113,0.15); color: var(--bad); border: 1px solid rgba(248,113,113,0.4); }

.answer { font-size: 24px; font-weight: 700; margin: 6px 0; }
.answer .sub { display: block; font-size: 14px; font-weight: 400; color: var(--muted); margin-top: 4px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .evidence-grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; padding: 8px 20px 10px; }
  .topbar-inner form.upload { flex-wrap: wrap; }
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }

.score { font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

ul.devices { list-style: none; padding: 0; margin: 0; }
.device { padding: 10px 0; border-bottom: 1px solid var(--border); }
.device:last-child { border-bottom: 0; }
.device-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.device-name { font-weight: 600; margin-right: 8px; }
.device .bar { margin: 6px 0 8px; }
details.evidence > summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.evidence-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.evidence-title { font-size: 13px; font-weight: 700; margin: 0 0 6px; }

.diff-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.diff-controls select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 8px; font-size: 13px; max-width: 100%;
}
.diff-controls .diff-download { font-size: 12px; white-space: nowrap; }
.diff-controls .diff-download:first-of-type { margin-left: auto; }

.dts-diff { margin-top: 10px; overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: 10px; }
.diff-head { display: flex; position: sticky; top: 0; z-index: 1; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.diff-head .diff-label { flex: 1; padding: 6px 10px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-head .diff-label + .diff-label { border-left: 1px solid var(--border); }
.dts-diff .d2h-wrapper { font-family: var(--mono); font-size: 12px; }
.dts-diff .d2h-file-header { display: none; }
.dts-diff .d2h-file-side-diff { overflow-x: auto; }
.dts-diff .d2h-diff-table { font-size: inherit; }
.dts-diff .d2h-diff-table td,
.dts-diff .d2h-diff-table th {
  padding: 0;
  border-bottom: 0;
  vertical-align: baseline;
  line-height: 1.4;
}
.dts-diff .d2h-code-side-linenumber {
  display: table-cell;
  position: static;
  width: auto;
  min-width: 3em;
  padding: 0 0.6em;
  white-space: nowrap;
  line-height: 1.4;
}
.dts-diff .d2h-code-side-line {
  display: block;
  padding: 0;
  width: auto;
  line-height: 1.4;
}
.dts-diff .d2h-code-line-prefix,
.dts-diff .d2h-code-line-ctn {
  vertical-align: baseline;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 13px; }

.match { color: var(--good); }
.diff { color: var(--mid); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li { padding: 4px 0; border-bottom: 1px solid var(--border); }

footer.site { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 20px 0; }
footer.site p { margin: 0 0 6px; }
footer.site p:last-child { margin-bottom: 0; }

pre.dts {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  max-height: 560px;
  white-space: pre-wrap;
  word-break: break-word;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

pre.dts .t-comment { color: #6b7280; font-style: italic; }
pre.dts .t-directive { color: #c084fc; }
pre.dts .t-string { color: #86efac; }
pre.dts .t-ref { color: var(--accent); }
pre.dts .t-number { color: #f0b072; }
pre.dts .t-const { color: var(--mid); }
pre.dts .t-label { color: #7dd3fc; }
pre.dts .t-name { color: var(--text); }

.dts-toolbar { display: flex; align-items: center; gap: 14px; margin: 14px 0 10px; flex-wrap: wrap; }
.dts-meta { margin: 10px 0 0; }
.dts-stats { margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.dts-base-label { margin-right: -8px; }
.dts-base {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; max-width: 100%;
}
.dts-base:disabled { opacity: 0.6; }
.dts-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
}
.dts-loading[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
a.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
a.icon-button:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
a.download { font-size: 13px; }

.page-loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 17, 23, 0.72);
  backdrop-filter: blur(2px);
}
.page-loading[hidden] { display: none; }
.page-loading .spinner { width: 40px; height: 40px; border-width: 4px; }

.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.overlay-head h2 { margin: 0; }
.guide-toggle {
  background: var(--mid); color: #2a2200;
  border: 0; border-radius: 10px;
  padding: 6px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer;
}
.guide-toggle:hover { filter: brightness(1.06); }

.install-guide {
  margin: 14px 0 18px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg);
}
.install-guide[hidden] { display: none; }
.install-guide code {
  font-family: var(--mono); font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 4px;
}
.install-steps { margin: 8px 0; padding-left: 22px; }
.install-steps li { margin: 4px 0; }
.install-tree, .install-code {
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin: 10px 0;
  overflow-x: auto; white-space: pre;
}
.install-method { margin: 8px 0; }
.install-method > summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.install-method ul.clean li:last-child { border-bottom: 0; }
