* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Brand tokens mirror shared/brand/tokens.css (the canonical SoT for
   mmeet brand colors). The clean-circuit greens here ARE the source the
   wider brand picked up; keep them and shared/brand/tokens.css in lockstep.
   Orange is intentional anti-pattern contrast (typical-market AC) and is
   not a brand color. */
:root {
    --bg: #F4F9F4;
    --fg: #1F1410;
    --muted: #6B5A52;
    --green: #1F7A4F;
    --green-light: #2ECC71;
    --green-dark: #155235;
    --orange: #d96d2e;
    --orange-light: #e8884a;
    --border: #D9E6D9;
    --panel-bg: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============ Language toggle ============ */
.lang-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    display: inline-flex;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.lang-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.lang-btn:hover {
    color: var(--fg);
}

.lang-btn.is-active {
    background: var(--green);
    color: #fff;
}

/* ============ Header ============ */
header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 56px 24px 24px;
    text-align: center;
}

header h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 18px;
}

.lead {
    font-size: 17px;
    max-width: 720px;
    margin: 0 auto;
    color: var(--muted);
}

.hint {
    font-size: 13px;
    color: var(--muted);
    margin-top: 16px;
    opacity: 0.7;
    font-style: italic;
}

/* ============ Circuits grid ============ */
main.circuits {
    max-width: 1100px;
    margin: 20px auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.circuit {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}

.circuit.ac-attempt {
    border-top: 4px solid var(--orange);
}

.circuit.clean {
    border-top: 4px solid var(--green);
}

.circuit h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.ac-attempt h2 {
    color: var(--orange);
}

.clean h2 {
    color: var(--green-dark);
}

.subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 16px;
}

.circuit-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ============ SVG components ============ */
.component {
    cursor: help;
    transition: opacity 0.15s ease;
}

.component:hover {
    opacity: 0.75;
}

.comp-label {
    font-size: 12px;
    fill: var(--fg);
    font-family: inherit;
}

.dim-label-ac {
    fill: #b08566;
}

.bright-label {
    fill: var(--green);
    font-weight: 600;
}

.lbl {
    font-size: 11px;
    fill: var(--muted);
    font-family: inherit;
}

.ac-e {
    filter: drop-shadow(0 0 4px #e8884a);
}

.clean-e {
    filter: drop-shadow(0 0 4px #2ecc71);
}

/* ============ Legend ============ */
.legend {
    max-width: 1100px;
    margin: 56px auto;
    padding: 0 24px;
}

.legend h2 {
    font-size: 24px;
    margin-bottom: 16px;
}

.legend-group {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.legend-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.legend-group > summary::-webkit-details-marker {
    display: none;
}

.legend-group > summary::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 7px;
    border-color: transparent transparent transparent currentColor;
    transition: transform 0.2s ease;
    transform-origin: 2px center;
}

.legend-group[open] > summary::before {
    transform: rotate(90deg);
}

.legend-group.ac > summary { color: var(--orange); }
.legend-group.clean > summary { color: var(--green-dark); }

.legend-group table {
    width: 100%;
    border-collapse: collapse;
    border-top: 1px solid var(--border);
}

.legend-group th,
.legend-group td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: top;
}

.legend-group th {
    background: #E7F2E7;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.legend-group.ac th { color: var(--orange); background: rgba(217, 109, 46, 0.08); }
.legend-group.clean th { color: var(--green); background: #E7F2E7; }

.legend-group tr:last-child td {
    border-bottom: none;
}

/* ============ Tooltip ============ */
.tooltip {
    position: absolute;
    display: none;
    background: rgba(20, 20, 20, 0.97);
    color: #fff;
    padding: 14px 16px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    pointer-events: none;
    width: 320px;
    max-width: calc(100vw - 32px);
    z-index: 1000;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

.tooltip-title {
    color: #ffd270;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.tooltip-section + .tooltip-section {
    margin-top: 12px;
}

.tooltip-chip {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.tooltip-chip.dating {
    background: rgba(46, 204, 113, 0.18);
    color: #6fe39d;
    border: 1px solid rgba(46, 204, 113, 0.35);
}

.tooltip-chip.circuit {
    background: rgba(180, 180, 180, 0.15);
    color: #cfcfcf;
    border: 1px solid rgba(180, 180, 180, 0.3);
}

.tooltip-text {
    color: #e8e8e8;
}

/* ============ Responsive ============ */
@media (max-width: 880px) {
    main.circuits {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 24px;
    }

    .lead {
        font-size: 15px;
    }

    .lang-toggle {
        top: 8px;
        right: 8px;
    }
}
