:root {
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --header: #1e293b;
    --head-bg: #f8fafc;
    --text: #1f2937;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #eff6ff;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --warning: #b45309;
    --warning-soft: #fffbeb;

    --radius: 10px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 62rem;
    margin-inline: auto;
    padding-inline: 1.25rem;
}

/* Header */
.site-header {
    background: var(--header);
    border-bottom: 3px solid var(--accent);
    color: #fff;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.brand span {
    color: #93c5fd;
}

.subtitle {
    color: #cbd5e1;
    margin: 0.25rem 0 0;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.75rem;
    padding: 1.5rem;
}

.card h2 {
    font-size: 1.2rem;
    margin: 0 0 1rem;
}

/* Form */
.input-form {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.75rem 1rem;
    align-items: center;
    max-width: 36rem;
}

.input-form label {
    font-weight: 500;
}

input[type="number"],
input[type="text"] {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    padding: 0.45rem 0.6rem;
    width: 100%;
}

input[type="number"] {
    max-width: 8rem;
}

input:focus-visible {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[type="checkbox"] {
    accent-color: var(--accent);
    height: 1rem;
    width: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    grid-column: 1 / -1;
}

.form-actions {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

/* Read-only summary of the committed selection */
.current-selection {
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.75rem 1rem;
    align-items: center;
    margin-top: 1.25rem;
    max-width: 36rem;
    padding-top: 1rem;
}

.current-selection label {
    color: var(--text-muted);
    font-weight: 500;
}

input[readonly] {
    background: var(--head-bg);
}

/* Buttons */
.btn {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.3);
    outline-offset: 1px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Step controls and notes */
.step-controls {
    align-items: center;
    display: flex;
    gap: 1rem;
    margin: 1.25rem 0 0;
}

.done-note {
    color: var(--success);
    font-weight: 600;
}

.hint {
    color: var(--text-muted);
}

.reason {
    background: var(--head-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0.75rem 0;
    padding: 0.6rem 0.9rem;
}

.result {
    background: var(--success-soft);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    padding: 0.6rem 0.9rem;
}

.error-note {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #b91c1c;
    padding: 0.6rem 0.9rem;
}

.chip {
    background: var(--accent-soft);
    border-radius: 999px;
    color: var(--accent-strong);
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 600;
    margin: 0 0.15rem;
    padding: 0.05rem 0.55rem;
}

/* Tables */
.table-wrap {
    margin: 0.75rem 0;
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    font-size: 0.95rem;
}

caption {
    caption-side: top;
    font-weight: 600;
    padding-bottom: 0.5rem;
    text-align: left;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.3rem 0.65rem;
    text-align: center;
}

thead th,
tbody th {
    background: var(--head-bg);
    font-weight: 600;
}

.bits {
    font-family: var(--font-mono);
    letter-spacing: 0.08em;
}

/* Truth table */
.row-one {
    background: var(--success-soft);
}

.row-dontcare {
    background: var(--warning-soft);
}

.value {
    font-family: var(--font-mono);
    font-weight: 700;
}

.value-one {
    color: var(--success);
}

.value-dontcare {
    color: var(--warning);
}

.value-zero {
    color: var(--text-muted);
}

/* Prime implicant table */
.step-table td {
    min-width: 6.5rem;
    vertical-align: top;
}

.implicant {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-mono);
    padding: 0.1rem 0.15rem;
    white-space: nowrap;
}

.implicant-used {
    color: var(--text-muted);
}

.implicant-prime {
    font-weight: 700;
}

.implicant-prime .mark {
    color: var(--warning);
}

/* Covering matrix */
.matrix-table td:not(:empty) {
    color: var(--accent-strong);
    font-weight: 700;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2rem;
    padding: 1.25rem 0 2rem;
    text-align: center;
}

.site-footer a {
    color: var(--accent);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}
