:root {
  /* Dark theme — Catppuccin Macchiato */
  --bg: #24273a; /* Base */
  --bg-secondary: #1e2030; /* Mantle */
  --bg-tertiary: #2b2f47; /* between Base and Surface 0 */
  --border: #494d64; /* Surface 1 */
  --text: #b8c0e0; /* Subtext 1 */
  --text-muted: #8087a2; /* Overlay 1 */
  --accent: #8aadf4; /* Blue */
  --success: #a6da95; /* Green */
  --error: #ed8796; /* Red */
  --peach: #f5a97f; /* Peach */
  --mauve: #c6a0f6; /* Mauve */
  --font-mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  --font-sans: "Source Sans 3", "Microsoft Yahei", sans-serif;
  --font-heading: "Lato", "Microsoft Yahei", sans-serif;
  --radius: 6px;
}

@media (prefers-color-scheme: light) {
  :root {
    /* Light theme — Catppuccin Latte */
    --bg: #eff1f5; /* Base */
    --bg-secondary: #e6e9ef; /* Mantle */
    --bg-tertiary: #e6e9ef; /* Mantle */
    --border: #bcc0cc; /* Surface 1 */
    --text: #5c5f77; /* Subtext 1 */
    --text-muted: #8c8fa1; /* Overlay 1 */
    --accent: #1e66f5; /* Blue */
    --success: #40a02b; /* Green */
    --error: #d20f39; /* Red */
    --peach: #fe640b; /* Peach */
    --mauve: #8839ef; /* Mauve */
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
  border-radius: 6px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
}

header h1 span {
  color: var(--accent);
}

main {
  flex: 1;
  padding: 16px 20px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.intro {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 18px;
  max-width: 78ch;
}
.intro code {
  color: var(--text);
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side .section-label {
  margin-bottom: 0;
}

select,
input[type="text"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

select:focus,
input:focus {
  border-color: var(--accent);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23656d76' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

input[type="text"] {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.err {
  font-size: 12px;
  color: var(--error);
  min-height: 1em;
}

.capsh-out {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px;
  min-height: 6.5em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 10px;
}

.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font-size: 13px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  white-space: nowrap;
}
.chip-a {
  border-color: var(--peach);
  color: var(--peach);
}
.chip-b {
  border-color: var(--mauve);
  color: var(--mauve);
}
.chip-both {
  border-color: var(--success);
  color: var(--success);
}
.chip-danger {
  border-color: var(--error);
  color: var(--error);
}

.toggle {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

.cap-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
}

.cap-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
}

.cap-table td {
  padding: 9px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  vertical-align: baseline;
}

.cap-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.col-bit {
  width: 3.5em;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
}
.col-name {
  width: 16em;
  white-space: nowrap;
}
.col-name code {
  font-size: 14px;
}
.cap-table th.col-mark {
  text-align: center;
}

.col-mark {
  width: 3.2em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 15px;
}
/* Frame the two mark columns so the eye can run down the pair. */
.cap-table tr > :nth-child(3) {
  border-left: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.cap-table tr > :nth-child(4) {
  border-right: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.col-desc {
  color: var(--text-muted);
}

.cap-table tbody tr.both td.col-mark {
  color: var(--success);
}
/* Dim absent rows with colour, not opacity: opacity would create a stacking
   context that paints over the sticky header. */
.cap-table tbody tr.neither td,
.cap-table tbody tr.neither .col-name code {
  color: color-mix(in srgb, var(--text-muted) 65%, transparent);
}
.cap-table tbody tr.neither .danger {
  color: color-mix(in srgb, var(--error) 40%, transparent);
}
.cap-table tbody tr.neither td.col-mark {
  color: var(--border);
}

.cap-table tbody tr.only-a td {
  background: color-mix(in srgb, var(--peach) 14%, transparent);
}
.cap-table tbody tr.only-a td.col-bit {
  box-shadow: inset 3px 0 var(--peach);
}
.cap-table tbody tr.only-a td.col-mark:nth-child(3) {
  color: var(--peach);
  font-weight: 700;
}
.cap-table tbody tr.only-b td {
  background: color-mix(in srgb, var(--mauve) 14%, transparent);
}
.cap-table tbody tr.only-b td.col-bit {
  box-shadow: inset 3px 0 var(--mauve);
}
.cap-table tbody tr.only-b td.col-mark:nth-child(4) {
  color: var(--mauve);
  font-weight: 700;
}

.danger {
  color: var(--error);
  cursor: help;
}

footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: var(--text-muted);
  gap: 12px;
  flex-wrap: wrap;
}

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

@media (max-width: 760px) {
  .sides {
    grid-template-columns: 1fr;
  }
  .col-desc {
    display: none;
  }
  .col-name {
    width: auto;
    white-space: normal;
  }
}
