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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #FFFFFF;
    color: #000000;
    line-height: 1.6;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

main {
    max-width: 1200px;
    width: 100%;
}

footer {
    text-align: center;
    opacity: 0.7;
    font-size: 0.9em;
}

a {
    color: inherit;
    text-decoration: underline;
}

h1 {
    font-size: 48px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 16px;
    border-bottom: 4px solid #000000;
    padding-bottom: 24px;
    text-align: center;
}

.subtitle {
    text-align: center;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666666;
    margin-bottom: 48px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.8;
}

section {
    margin-bottom: 32px;
}

h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.mode-toggle-section {
    text-align: center;
}

.mode-toggle {
    display: inline-flex;
    gap: 0;
    border: 2px solid #000000;
}

.mode-toggle button {
    background: #FFFFFF;
    color: #000000;
    border: none;
    padding: 16px 48px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 150ms ease;
    border-right: 2px solid #000000;
}

.mode-toggle button:last-child {
    border-right: none;
}

.mode-toggle button.active {
    background: #000000;
    color: #FFFFFF;
}

.mode-toggle button:hover:not(.active) {
    background: #F0F0F0;
}

.resistor-display {
    padding: 48px;
    border: 2px solid #000000;
    background: #F5F5DC;
}

.resistor-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.resistor-body {
    position: relative;
    height: 70px;
    background: #D4A574;
    border: 2px solid #000000;
}

.resistor-leads {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: #666666;
    width: 60px;
}

.resistor-leads.left {
    left: -60px;
}

.resistor-leads.right {
    right: -60px;
}

.resistor-bands {
    display: flex;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: stretch;
    gap: 12px;
}

.band {
    flex: 0 0 20px;
    border-left: 2px solid #000000;
    border-right: 2px solid #000000;
    transition: background-color 200ms ease;
}

.band:first-child {
    margin-left: 80px;
}

.band.spacing {
    flex: 1;
    border: none;
    background: transparent;
    min-width: 80px;
}

.controls-wrapper {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    padding: 32px;
    border: 2px solid #000000;
    background: #FFFFFF;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
}

.value-display {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
    border-left: 2px solid #000000;
    min-width: 320px;
}

.value-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.composite-input {
    height: 64px;
    border: 2px solid #000000;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 8px;
}

.composite-input:focus-within {
    box-shadow: inset 0 0 0 2px #000000;
}

.composite-input input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 24px;
    font-family: "Courier New", monospace;
    font-weight: 700;
    text-align: right;
    padding: 0;
    min-width: 0;
}

.composite-input .input-suffix {
    font-size: 24px;
    font-family: "Courier New", monospace;
    font-weight: 700;
    color: #000000;
    user-select: none;
    white-space: nowrap;
}

.composite-input .input-suffix.tolerance {
    color: #666666;
    margin-left: 8px;
}

.value-input-wrapper button {
    height: 48px;
    padding: 0 24px;
    background: #000000;
    color: #FFFFFF;
    border: 2px solid #000000;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 150ms ease;
}

.value-input-wrapper button:hover {
    background: #FFFFFF;
    color: #000000;
}

.warning {
    margin-top: 12px;
    font-size: 13px;
    color: #000000;
    font-weight: 700;
    text-align: center;
}

.band-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.band-control label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.color-selector {
    position: relative;
}

.color-current {
    width: 100%;
    height: 56px;
    border: 2px solid #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    transition: transform 100ms ease;
}

.color-current:hover {
    transform: scale(1.02);
}

.color-current.light-bg {
    color: #000000;
}

.color-current.dark-bg {
    color: #FFFFFF;
}

.color-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border: 2px solid #000000;
    border-top: none;
    z-index: 10;
    max-height: 300px;
    overflow-y: auto;
}

.color-options.show {
    display: block;
}

.color-option {
    height: 44px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    border-bottom: 1px solid #CCCCCC;
    transition: opacity 100ms ease;
    position: relative;
}

.color-option .color-name {
    position: relative;
    z-index: 1;
}

.color-option .color-value {
    font-size: 9px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.color-option:last-child {
    border-bottom: none;
}

.color-option:hover {
    opacity: 0.8;
}


@media (max-width: 1024px) {
    main {
        max-width: 900px;
    }

    h1 {
        font-size: 36px;
    }

    .controls-wrapper {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .value-display {
        border-left: none;
        border-top: 2px solid #000000;
        padding-top: 24px;
        min-width: auto;
    }

    .resistor-container {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 28px;
        letter-spacing: 2px;
    }

    .controls {
        grid-template-columns: repeat(2, 1fr);
    }

    .resistor-display {
        padding: 32px 24px;
    }

    .resistor-container {
        max-width: 400px;
    }

    .resistor-body {
        height: 60px;
    }

    .band {
        flex: 0 0 16px;
    }

    .band:first-child {
        margin-left: 60px;
    }

    .band.spacing {
        min-width: 40px;
    }

    .composite-input {
        height: 56px;
        padding: 0 16px;
    }

    .composite-input input,
    .composite-input .input-suffix {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .controls {
        grid-template-columns: 1fr;
    }
}
