main { max-width: 900px; margin: 0 auto; padding: 20px 24px 80px 24px; width: 100%; }

.segmented { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; min-width: 0; }
.segmented button {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    border: none;
    background: var(--surface);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    border-right: 1px solid var(--border-strong);
    color: var(--text);
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--primary); color: #fff; }
#mode-toggle { flex: 0 0 auto; max-width: 900px; margin: 20px auto 0 auto; padding: 0 24px; }

/* Bit comparison (distance mode) */
.bit-row-label { font-size: 12px; color: var(--muted); margin: 10px 0 4px 0; font-weight: 600; }
.bit-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.bit-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-family: ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
}
.bit-chip.diff { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); border-color: var(--danger); color: var(--danger); }
.bit-chip.clickable { cursor: pointer; user-select: none; }
.bit-chip.clickable:hover { border-color: var(--primary); }
.bit-chip.check-pos { border-style: dashed; border-color: var(--primary); }

.stat-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); gap: 10px; }
.stat-row:last-child { border-bottom: none; }
.stat-row .stat-value { font-weight: 700; }
.stat-row .stat-value.good { color: var(--success); }
.stat-row .stat-value.mono { font-family: ui-monospace, monospace; font-weight: 600; word-break: break-all; text-align: right; }

.prefix-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; line-height: 1.5; }
.prefix-check.ok { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
.prefix-check.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* Hamming grid table (encode/decode) */
#encode-step-nav, #hamming-grid-wrap { text-align: center; }
#encode-step-position { font-weight: 700; font-size: 14px; }
#encode-step-description { margin: 4px 0 14px 0; min-height: 20px; }
#encode-step-controls { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.hgrid-scroll { overflow-x: auto; padding-bottom: 4px; }
table.hgrid { border-collapse: collapse; margin: 0 auto; font-size: 12px; }
table.hgrid th, table.hgrid td {
    width: 28px;
    min-width: 28px;
    height: 28px;
    text-align: center;
    border: 1px solid var(--border);
    font-family: ui-monospace, monospace;
}
table.hgrid th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.hgrid td:first-child, table.hgrid th:first-child {
    width: auto;
    min-width: 70px;
    text-align: right;
    padding-right: 8px;
    font-family: "Inter", sans-serif;
    font-size: 11.5px;
    color: var(--muted);
    border: none;
    background: transparent;
}
.hgrid-value-row td { font-weight: 700; }
.hgrid-check-cell { background: color-mix(in srgb, #f2994a 20%, var(--surface)); }
.hgrid-check-row.active td { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.hgrid-check-row.active td:first-child { background: transparent; color: var(--primary); font-weight: 700; }
.hgrid-check-row.mismatch td:first-child { color: var(--danger); font-weight: 700; }
.hgrid-error-col { background: color-mix(in srgb, var(--danger) 22%, var(--surface)) !important; }
.hgrid-clickable { cursor: pointer; }
.hgrid-clickable:hover { outline: 2px solid var(--primary); outline-offset: -2px; }

#received-bits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
#decode-grid-wrap { text-align: center; }
