body {
    font-family: courier, monospace;
    max-width: 820px;
    margin: 0 auto;
    padding: 0 16px 60px;
    line-height: 1.55;
    color: #222;
    background: #fff;
}

.top_link {
    float: right;
    margin-top: 12px;
}

header {
    text-align: center;
    padding-top: 30px;
    clear: both;
}

h1 {
    margin-bottom: 4px;
}

.subtitle {
    margin-top: 0;
    color: #666;
}

h2 {
    margin-top: 60px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 6px;
}

h3 {
    margin-bottom: 4px;
}

.contents ol {
    padding-left: 24px;
    columns: 2;
}

.contents a {
    color: #222;
}

.math {
    white-space: nowrap;
}

.equation {
    text-align: center;
    font-size: 1.3em;
    margin: 20px 0;
}

.equation.small {
    font-size: 1em;
    margin: 6px 0;
    color: #555;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 20px auto 10px;
    border: 2px solid grey;
    background: #fff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
}

.controls label {
    display: block;
    min-width: 200px;
    flex: 1 1 200px;
    max-width: 320px;
}

.controls input[type="range"] {
    display: block;
    width: 100%;
    margin-top: 4px;
}

.controls label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: none;
}

button {
    font-family: inherit;
    font-size: 1em;
    padding: 6px 14px;
    border: 2px solid #888;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background: #e8e8e8;
}

button:active {
    background: #ddd;
}

.readout {
    text-align: center;
    color: #444;
    min-height: 1.5em;
    margin: 8px 0;
}

.readout .nw {
    white-space: nowrap;
    display: inline-block;
    margin: 0 8px;
}

.note {
    background: #f4f4f4;
    border-left: 4px solid #bbb;
    padding: 12px 16px;
    margin: 24px 0;
}

.note p:first-child {
    margin-top: 0;
}

.note p:last-child {
    margin-bottom: 0;
}

.steps li {
    margin-bottom: 6px;
}

ul.plain {
    padding-left: 20px;
}

ul.plain li {
    margin-bottom: 10px;
}

.p { color: #1f77b4; font-weight: bold; }
.q { color: #e07b00; font-weight: bold; }
.s { color: #2ca02c; font-weight: bold; }
.alice { color: #1f77b4; font-weight: bold; }
.bob { color: #e07b00; font-weight: bold; }

.ok {
    color: #2ca02c;
    font-weight: bold;
}

.scale {
    text-align: center;
    margin: 24px 0;
}

.bignum {
    font-size: 0.85em;
    word-break: break-all;
    background: #f4f4f4;
    padding: 10px;
    border-radius: 4px;
}

.dh-table {
    display: flex;
    gap: 12px;
    margin: 20px 0;
}

.dh-table .col {
    flex: 1 1 0;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.9em;
    min-width: 0;
}

.dh-table .col p {
    margin: 0;
    white-space: pre-line;
}

.alice-col { background: #e5f0f8; }
.eve-col   { background: #f4f4f4; }
.bob-col   { background: #fbeedb; }

footer {
    margin-top: 60px;
    text-align: center;
}

@media (max-width: 600px) {
    .contents ol {
        columns: 1;
    }

    .dh-table {
        flex-direction: column;
    }

    h2 {
        font-size: 1.2em;
    }

    .equation {
        font-size: 1.1em;
    }
}
