:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d68;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --pre: #eb6834;
  --burst: #2a78d6;
  --warn-bg: #fff6e0;
  --warn-border: #f0d48a;
  --error: #b42323;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #222220;
    --text-1: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a988f;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --pre: #d95926;
    --burst: #3987e5;
    --warn-bg: #2b2414;
    --warn-border: #5c4a1c;
    --error: #ff8a80;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --raised: #222220;
  --text-1: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a988f;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --pre: #d95926;
  --burst: #3987e5;
  --warn-bg: #2b2414;
  --warn-border: #5c4a1c;
  --error: #ff8a80;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--page);
  color: var(--text-1);
  font: 15px/1.5 var(--font);
}
a {
  color: var(--accent-ink);
}
code {
  font-size: 0.9em;
  background: var(--hairline);
  padding: 0 0.3em;
  border-radius: 4px;
}
h1,
h2 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
}
h1 {
  font-size: 1.35rem;
  font-weight: 650;
}
h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.top-inner {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-top: 18px;
  padding-bottom: 18px;
}
.lede {
  margin: 2px 0 0;
  color: var(--text-2);
}
main {
  padding-top: 20px;
  padding-bottom: 48px;
  display: grid;
  gap: 16px;
}
#results {
  display: grid;
  gap: 16px;
}
#results[hidden] {
  display: none;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.panel-title {
  margin-bottom: 10px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}
.controls {
  display: grid;
  gap: 14px;
}
.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.field > span {
  font-size: 0.8rem;
  color: var(--text-2);
  font-weight: 500;
}
.field.grow {
  flex: 1 1 260px;
}
.field.narrow input {
  width: 9.5em;
}
input,
select,
button {
  font: inherit;
  color: inherit;
}
input[type='number'],
select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--raised);
  min-width: 0;
  max-width: 100%;
}
input[type='number'] {
  width: 10em;
}
input[type='file'] {
  max-width: 100%;
}
select {
  padding-right: 6px;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--raised);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.9rem;
}
.btn:hover {
  border-color: var(--muted);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.icon {
  width: 36px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--raised);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  height: 30px;
  padding: 0 12px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.88rem;
}
.seg button[aria-checked='true'] {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.files {
  margin-top: 12px;
}
.files summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.9rem;
}
.files-row {
  margin-top: 10px;
}
.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 10px 0 0;
}
.status {
  margin: 10px 0 0;
  min-height: 1.5em;
  color: var(--text-2);
  font-size: 0.9rem;
}
.status.error {
  color: var(--error);
}

.site {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  color: var(--text-2);
}
.chip b {
  color: var(--text-1);
  font-weight: 600;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 0;
}
.tile .label {
  font-size: 0.8rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile .value {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 2px;
}
.tile .value small {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
}
.tile .meta {
  font-size: 0.78rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex: none;
}
.dot.pre {
  background: var(--pre);
}
.dot.burst {
  background: var(--burst);
}

.notes {
  display: grid;
  gap: 8px;
}
.notes:empty {
  display: none;
}
.note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.88rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.sub {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: 0.88rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.stepper {
  display: inline-flex;
  gap: 4px;
}
.stepper select {
  max-width: 14em;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 0.85rem;
  color: var(--text-2);
  margin: 4px 0 6px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .line {
  width: 16px;
  height: 2px;
  display: inline-block;
}
.legend .line.thin {
  height: 2px;
  opacity: 0.45;
}

.chart-wrap {
  position: relative;
}
canvas {
  display: block;
  width: 100%;
}
.guide {
  position: absolute;
  width: 1px;
  background: var(--muted);
  pointer-events: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 8px 2px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.cell:hover {
  border-color: var(--muted);
}
.cell[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.cell-title {
  font-size: 0.82rem;
  color: var(--text-2);
  padding: 0 4px 2px;
}
.cell-title b {
  color: var(--text-1);
  font-weight: 600;
}

.table-view {
  margin-top: 10px;
}
.table-view summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.9rem;
}
.table-scroll {
  max-height: 360px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
th,
td {
  padding: 4px 10px;
  text-align: right;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-weight: 600;
  color: var(--text-2);
}
td:first-child,
th:first-child {
  text-align: left;
}

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--raised);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-width: 260px;
}
.tip .k {
  color: var(--text-2);
}

.about ol {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
  color: var(--text-2);
}
.about strong {
  color: var(--text-1);
}

@media (max-width: 640px) {
  .card-head .actions {
    width: 100%;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  input[type='number'] {
    width: 100%;
  }
  .row > .field,
  .row > .btn {
    flex: 1 1 140px;
  }
  .row > .field:has(.seg) {
    flex-basis: 100%;
  }
  .seg {
    display: flex;
  }
  .seg button {
    flex: 1 1 auto;
    padding: 0 8px;
  }
}
