
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansregular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansbold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansitalic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Sana Sans";
  src: url("fonts/sansbolditalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --accent: #1f7a3e;
  --warn: #a36500;
  --fail: #b3261e;
  --rule: #e5e5e5;
  --muted: #6a6a6a;
  --text: #1f2328;
  --brand: #FFC72C;
  --font-body: "Sana Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.55;
  background: #fafafa;
}
main { max-width: 64rem; margin: 0 auto; padding: 2.5rem 1.25rem; }

header { margin-bottom: 2rem; }
h1 { font-size: 1.8rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0; max-width: 44rem; }
.lede strong { color: var(--text); }

.alpha {
  margin: 1.25rem 0 0;
  padding: .65rem .9rem;
  border-left: 4px solid var(--accent);
  background: #f0f7f3;
  color: var(--text);
  font-size: .92rem;
  border-radius: 0 4px 4px 0;
}
.alpha strong { color: var(--text); }
.alpha a { color: var(--accent); }

.scope {
  font-size: .92rem;
  color: var(--muted);
}
.scope h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.25rem 0 .35rem; font-weight: 600; }
.scope h3:first-child { margin-top: 0; }
.scope ul { margin: 0 0 .5rem 1.2rem; padding: 0; }
.scope li { margin: .15rem 0; }
.scope .note { font-style: italic; }
table.rules { width: 100%; border-collapse: collapse; font-size: .82rem; margin: 0 0 .75rem; }
table.rules th, table.rules td { text-align: left; padding: .25rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.rules th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
table.rules td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
table.rules td.sev-error { color: var(--fail); }
table.rules td.sev-warning { color: var(--warn); }
table.rules td.sev-info { color: var(--muted); }

/* Expandable rule rows: click a row to reveal its explanation. */
.rule-row { cursor: pointer; }
.rule-row:hover td { background: #f5f8f6; }
.rule-toggle {
  font: inherit; color: inherit; cursor: pointer;
  background: none; border: 0; padding: 0; margin: 0;
  display: inline-flex; align-items: baseline; gap: .35rem; text-align: left;
}
.rule-toggle::before {
  content: "\25B8"; color: var(--muted); font-size: .8em;
  transition: transform .12s ease;
}
.rule-row.open .rule-toggle::before { transform: rotate(90deg); }
.rule-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
/* The detail cell is the row's only <td>, so it also matches the
   first-column rule (monospace + nowrap) -- override both, or the long
   description never wraps and forces the table past the viewport edge. */
table.rules tr.rule-detail td {
  background: #f5f8f6;
  color: var(--text);
  padding: .1rem .5rem .6rem 1.6rem;
  font-family: var(--font-body);
  white-space: normal;
  overflow-wrap: anywhere;
}
.rule-detail .rule-desc { margin: 0; }
.rule-detail .rule-meta { margin: .35rem 0 0; font-size: .78rem; color: var(--muted); }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 1.5rem 0 1rem;
  padding: 2.5rem 1.5rem;
  border: 2px dashed #ccc;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s, padding .2s;
}
.drop.drag    { border-color: var(--accent); background: #f0f7f3; }
.drop.busy    { border-color: var(--warn);   background: #fcf6e8; cursor: wait; }
.drop.ready   { border-color: #ccc; }
.drop strong  { color: var(--text); font-size: 1.05rem; display: block; }
.drop .sub    { color: var(--muted); font-size: .9rem; margin-top: .5rem; display: block; }
.drop input[type=file] { display: none; }

/* Compact mode kicks in once a report is on screen: the drop zone
   shrinks to a single line so the iframe gets most of the viewport,
   but stays clickable for the next document. */
.drop.compact {
  flex-direction: row;
  justify-content: center;
  gap: .6rem;
  padding: .55rem .9rem;
  margin: 1rem 0 .5rem;
}
.drop.compact strong { font-size: .92rem; font-weight: 600; }
.drop.compact .sub   { margin-top: 0; font-size: .85rem; }

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  min-height: 1.3rem;
}
.status { color: var(--muted); font-size: .9rem; flex: 1; min-width: 0; }
.status.err { color: var(--fail); }

.print-btn {
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1px solid #c8c8c8;
  border-radius: 6px;
  padding: .4rem .85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.print-btn:hover { border-color: var(--accent); color: var(--accent); }
.print-btn:disabled { opacity: .55; cursor: wait; }
.print-btn[hidden] { display: none; }

/* View panels: report (host of a shadow root), structure tree, scope.
   Visibility is driven by the [hidden] attribute via the view tabs. */
.view-panel[hidden] { display: none; }

/* The report flows inline: the shadow root's own <body> supplies the
   card's width, centring and background, so the host needs no frame. */
.result { min-height: 12rem; }
.result .empty { color: var(--muted); padding: 2rem 0; }

.view-tabs { display: flex; gap: .4rem; margin-bottom: .75rem; }
.view-tab {
  font: inherit;
  font-size: .85rem;
  padding: .35rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.view-tab:hover { border-color: var(--accent); color: var(--accent); }
.view-tab.active { border-color: var(--accent); color: var(--accent); background: #f0f7f3; font-weight: 600; }

.structure-view {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  min-height: 12rem;
  max-height: 75vh;
  overflow: auto;
  padding: 1rem 1.25rem;
  font-size: .9rem;
}
.structure-view .empty { color: var(--muted); }

/* The structure tree itself: nested <ul> with disclosure markers. */
.struct-tree, .struct-tree ul { list-style: none; margin: 0; padding: 0; }
.struct-tree ul { margin-left: 1.1rem; border-left: 1px solid var(--rule); padding-left: .6rem; }
.struct-tree li { margin: .12rem 0; }
.struct-node {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  flex-wrap: wrap;
}
.struct-toggle {
  cursor: pointer;
  color: var(--muted);
  width: 1em;
  flex: none;
  user-select: none;
}
.struct-toggle.leaf { visibility: hidden; }
.struct-type {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--text);
}
.struct-type.math { color: var(--accent); }
.struct-page { color: var(--muted); font-size: .78rem; }
.struct-attr {
  font-size: .78rem;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0 .35rem;
}
.struct-attr b { font-weight: 600; color: #444; }
.struct-text {
  margin: .1rem 0 .2rem 1.6rem;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.4;
  max-width: 70ch;
}
/* A text run interleaved among sibling element rows: align it with their
   type labels (past the toggle column) instead of the deeper flat-text
   indent, so reading order reads as one column. */
.struct-run { margin-left: 1.45rem; }
.struct-children.collapsed { display: none; }

/* MathML associated-file rendering: source + native render side by side. */
.struct-math {
  margin: .35rem 0 .35rem 1.6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.struct-math figcaption {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .3rem .6rem;
  background: #fafafa;
  border-bottom: 1px solid var(--rule);
}
.struct-math .math-render { padding: .6rem .8rem; font-size: 1.15rem; overflow-x: auto; }
.struct-math .math-source {
  margin: 0;
  padding: .6rem .8rem;
  background: #fbfbfb;
  border-top: 1px solid var(--rule);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
}

footer { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .85rem; text-align: center; }
footer a { color: #444; text-decoration: none; border-bottom: 1px solid #ccc; }
footer a:hover { color: var(--text); border-bottom-color: #888; }
footer .brand { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; color: #444; }
footer .brand svg { width: 1.3em; height: 1.3em; }
footer .version { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8em; color: var(--muted); }
footer .version:empty { display: none; }
footer .constellation { margin-top: .6rem; font-size: .82rem; }
footer .constellation .star { color: #FFC72C; margin-right: .15rem; }
