* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f8fafc;
    color: #1e293b;
    line-height: 1.5;
    padding: 1.5rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    font-size: 1.7rem;
    font-weight: 700;
    background: linear-gradient(135deg, #1e293b, #2d3a4e);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    margin-bottom: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.8rem;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 0 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    transition: 0.2s;
}

.tab-btn.active {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.05);
    position: relative;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #2563eb;
    border-radius: 2px;
}

.tab-pane {
    display: none;
    animation: fade 0.2s ease;
}

.tab-pane.active-pane {
    display: block;
}

@keyframes fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background: #ffffff;
    border: 1px solid #eef2f6;
    border-radius: 24px;
    padding: 1.8rem;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.04);
    margin-bottom: 2rem;
}

.resistor-svg {
    background: #eef2f6;
    border-radius: 20px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

svg {
    max-width: 100%;
    height: auto;
}

.result-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 18px;
    margin-bottom: 1.8rem;
    text-align: center;
}

.result-item label {
    font-size: 0.75rem;
    color: #64748b;
    letter-spacing: 0.5px;
    display: block;
}

.result-item span {
    font-size: 1.4rem;
    font-weight: 800;
    color: #2563eb;
    word-break: break-word;
}

.mode-switch {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: #f8fafc;
    padding: 0.5rem 1rem;
    border-radius: 40px;
    margin-bottom: 1.5rem;
}

.ring-selectors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.ring-item {
    flex: 1;
    min-width: 85px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.6rem 0.3rem;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.ring-item label {
    font-size: 0.7rem;
    font-weight: 700;
    display: block;
    color: #475569;
}

.ring-item select {
    width: 100%;
    padding: 0.3rem;
    font-size: 0.8rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: white;
    text-align: center;
}

.color-preview {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin: 6px auto 0;
    border: 1px solid #ddd;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

input, select, button {
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: white;
}

button {
    background: #2563eb;
    color: white;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

.tutorial {
    background: #fefce8;
    border-left: 5px solid #eab308;
    border-radius: 18px;
    padding: 1rem 1.2rem;
    margin-top: 1.5rem;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.color-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border-radius: 40px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #ccc;
}

.cls-1 { fill: #2c3e50; font-size: 12px; font-weight: 600; }
.cls-2 { fill: none; stroke: #5a6e7c; stroke-width: 3px; }

@media (max-width: 680px) {
    .card { padding: 1rem; }
    .ring-item { min-width: 70px; }
}