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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #d2504a;
    --accent-color: #4a7c99;
    --background-color: #faf8f3;
    --text-color: #2c2c2c;
    --border-color: #d4cfc4;
    --shadow-light: rgba(0, 0, 0, 0.12);
    --shadow-medium: rgba(0, 0, 0, 0.25);
    --font-main: 'Roboto Slab', Georgia, serif;
    --font-mono: 'Courier Prime', 'Courier New', monospace;
    --font-serif: 'Merriweather', Georgia, serif;
    
    /* Component colors */
    --panel-bg: #fffefa;
    --panel-hover: #f8f6f0;
    --input-bg: #f0ebe0;
    --input-hover: #e8dfd0;
    --code-bg: #f5f0e8;
    --slide-rule-bg: #f8f5ed;
    --slide-bg: #fffef9;
    --wood-grain-base: #e8d4b0;
    --wood-grain-accent: #d4c19a;
    --wood-border: #8b7355;
    --scale-marks: #2c2c2c;
    --cursor-color: #c74238;
    
    /* Text colors */
    --text-secondary: #666;
    --text-muted: #999;
    
    /* Tip box colors */
    --tip-bg: #e8f4f8;
    --tip-text: inherit;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ecf0f1;
        --secondary-color: #e74c3c;
        --accent-color: #5dade2;
        --background-color: #1a1a1a;
        --text-color: #e0e0e0;
        --border-color: #333;
        --shadow-light: rgba(0, 0, 0, 0.3);
        --shadow-medium: rgba(0, 0, 0, 0.5);
        
        /* Component colors */
        --panel-bg: #2d2d2d;
        --panel-hover: #3a3a3a;
        --input-bg: #3a3a3a;
        --input-hover: #484848;
        --code-bg: #2a2a2a;
        --slide-rule-bg: #252525;
        --slide-bg: #3a3a3a;
        --wood-grain-base: #3e3426;
        --wood-grain-accent: #4a3d2a;
        --wood-border: #5a4d3a;
        --scale-marks: #e0e0e0;
        --cursor-color: #ff6b6b;
        
        /* Text colors */
        --text-secondary: #aaa;
        --text-muted: #777;
        
        /* Tip box colors */
        --tip-bg: #1a3a4a;
        --tip-text: #e0e0e0;
    }
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

header {
    text-align: center;
    padding: 2rem;
    background: var(--panel-bg);
    margin-top: 1.25rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-light);
}

h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    box-sizing: border-box;
}

.slide-rule-container {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px var(--shadow-light);
}

.slide-rule {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 2rem;
    background: var(--slide-rule-bg);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: inset 0 2px 4px var(--shadow-light);
}

#slideRuleSvg {
    width: 100%;
    height: auto;
    display: block;
    cursor: grab;
}

#slideRuleSvg:active {
    cursor: grabbing;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.calculation-display {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cursor-positions {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.display-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.display-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.display-group .value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--primary-color);
}

.display-group.result .value {
    color: var(--secondary-color);
    font-size: 1.75rem;
}

.operations-display {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--input-bg);
    padding: 1rem;
    border-radius: 6px;
}

.operation-line {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.operation-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 120px;
}

.operation-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    color: var(--primary-color);
}

.button-group {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

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

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.btn-secondary {
    background-color: var(--input-bg);
    color: var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--input-hover);
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.info-panel {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px var(--shadow-light);
    overflow: hidden;
}

.tabs {
    display: flex;
    gap: 1rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.tab:hover {
    color: var(--primary-color);
}

.tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.tab-content {
    min-height: 300px;
    width: 100%;
    overflow-x: auto;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.tab-pane.active {
    display: block;
}

.tab-pane h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.tab-pane h3 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--primary-color);
}

.tab-pane p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.tab-pane ol, .tab-pane ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.tab-pane li {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.tip {
    background-color: var(--tip-bg, #e8f4f8);
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    border-radius: 4px;
    margin: 1.5rem 0;
    color: var(--tip-text, inherit);
}

.example {
    background-color: var(--panel-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.example h3 {
    margin-top: 0;
}

footer {
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 1.25rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.7;
}

footer p {
    margin: 0.5rem 0;
}

.analytics-notice {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.toggle-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.toggle-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* AWS Logo Styling */
.aws-logo-link {
    display: inline-block;
    margin-top: 0.5rem;
}

.aws-logo {
    height: 30px;
    width: auto;
}

/* Show light logo by default, hide dark logo */
.aws-logo-light {
    display: inline;
}

.aws-logo-dark {
    display: none;
}

/* In dark mode, hide light logo and show dark logo */
@media (prefers-color-scheme: dark) {
    .aws-logo-light {
        display: none;
    }
    
    .aws-logo-dark {
        display: inline;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* iPad specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 2rem;
    }
    
    .slide-rule-container {
        padding: 1.5rem;
    }
    
    .info-panel {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .slide-rule-container {
        padding: 1rem;
    }
    
    .cursor-positions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .operations-display {
        padding: 0.75rem;
    }
    
    .operation-label {
        min-width: auto;
        font-size: 0.875rem;
    }
    
    .operation-value {
        font-size: 1rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .button-group {
        justify-content: center;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        white-space: nowrap;
        padding: 0.5rem 1rem;
    }
    
    .info-panel {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .display-group .value {
        font-size: 1.25rem;
    }
    
    .display-group.result .value {
        font-size: 1.5rem;
    }
    
    footer {
        margin-top: 1rem;
    }
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background-color: var(--panel-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-medium);
    text-align: center;
    max-width: 90%;
    width: 400px;
}

.modal-content h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.modal-content .btn {
    min-width: 100px;
}