:root {
    --primary-color: #ea8400;
    --primary-hover: #d67300;
    --primary-light: rgba(234, 132, 0, 0.1);
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --surface-color: #ffffff;
    --surface-elevated: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

.dark-mode {
    --primary-color: #ff9d1a;
    --primary-hover: #ea8400;
    --primary-light: rgba(255, 157, 26, 0.15);
    --surface-color: #1e293b;
    --surface-elevated: #334155;
    --border-color: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
}

.tool-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.tool-header {
    text-align: center;
    padding: 40px 20px 30px;
    margin-bottom: 20px;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.header-icon {
    margin-bottom: 16px;
}

.icon-wave {
    font-size: 3rem;
    display: inline-block;
    animation: wave-motion 2s ease-in-out infinite;
}

@keyframes wave-motion {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-5px) rotate(-5deg);
    }

    50% {
        transform: translateY(0) rotate(0deg);
    }

    75% {
        transform: translateY(-5px) rotate(5deg);
    }
}

.tool-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.tool-header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.keyboard-hint {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

kbd {
    display: inline-block;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px 24px;
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tool-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}

.options-sidebar {
    position: sticky;
    top: 20px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.option-card {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.option-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px 0;
}

.card-icon {
    font-size: 1.1rem;
}

.preset-card {
    background: var(--surface-elevated);
}

.preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.preset-option {
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    text-align: center;
}

.preset-option:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.preset-option.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.control-group {
    margin-bottom: 16px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.control-label span:first-child {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.control-label span:last-child {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px var(--primary-light);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    transition: var(--transition-fast);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: var(--transition-fast);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary-color);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 0 3px var(--primary-light);
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.option-item:last-child {
    margin-bottom: 0;
}

.option-label {
    font-size: 0.9rem;
    color: var(--text-primary);
    flex: 1;
}

.canvas-container {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    padding: 20px;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.canvas-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

canvas {
    display: block;
    margin: 0 auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: white;
}

.dark-mode canvas {
    background: #2d3748;
}

.action-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--surface-elevated);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.action-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.action-btn.secondary {
    background: var(--surface-elevated);
}

.help-box {
    margin-top: 30px;
    padding: 20px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary-color);
}

.help-box strong {
    display: block;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.help-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-box li {
    padding: 6px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-box li:before {
    content: "→ ";
    color: var(--primary-color);
    font-weight: bold;
    margin-right: 8px;
}

@media (max-width: 1024px) {
    .tool-content {
        grid-template-columns: 1fr;
    }

    .options-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 1.8rem;
    }

    .tool-header .subtitle {
        font-size: 1rem;
    }

    .stats-bar {
        gap: 16px;
        padding: 12px 16px;
    }

    .stat-item {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .action-bar {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }

    .preset-buttons {
        grid-template-columns: 1fr;
    }
}


.explanation-section {
    margin-top: 40px;
    padding: 30px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 12px;
}

.explanation-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.explanation-card {
    padding: 24px;
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.explanation-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.explanation-card h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 16px 0 10px 0;
}

.explanation-card p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.explanation-card ul {
    list-style: none;
    padding-left: 0;
    margin: 12px 0;
}

.explanation-card li {
    padding: 8px 0;
    padding-left: 24px;
    color: var(--text-secondary);
    line-height: 1.6;
    position: relative;
}

.explanation-card li:before {
    content: "▸";
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.formula-box {
    padding: 16px 20px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-sm);
    margin: 16px 0;
    font-family: 'Courier New', monospace;
}

.dark-mode .formula-box {
    background: #2d3748;
    border-color: var(--primary-color);
}

.formula-box p {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 8px 0;
    text-align: center;
}

.parameter-explanation {
    margin: 16px 0;
    padding: 16px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.dark-mode .parameter-explanation {
    background: #2d3748;
}

.polarization-type {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    transition: all var(--transition-normal);
}

.dark-mode .polarization-type {
    background: #2d3748;
}

.polarization-type:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.polarization-type h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 12px;
    font-weight: 700;
}

.polarization-type p:first-of-type {
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .tool-header {
        padding: 24px 16px;
    }

    .tool-header h1 {
        font-size: 1.5rem;
    }

    .tool-main {
        padding: 0 12px 32px;
    }

    canvas {
        max-width: 100%;
        height: auto;
    }

    .explanation-section {
        padding: 20px 16px;
        margin-top: 24px;
    }

    .section-header h2 {
        font-size: 1.4rem;
    }

    .explanation-card {
        padding: 16px;
    }

    .explanation-card h3 {
        font-size: 1.1rem;
    }

    .formula-box {
        padding: 12px;
        font-size: 0.9rem;
    }

    .polarization-type {
        padding: 16px;
    }
}