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

body {
    font-family: 'Georgia', 'Garamond', 'Times New Roman', serif;
    background: linear-gradient(135deg, #2d1810 0%, #4a2511 50%, #2d1810 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: #2c1810;
    position: relative;
}

/* Wood grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.03) 2px,
            rgba(0,0,0,0.03) 4px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0,0,0,0.03) 2px,
            rgba(0,0,0,0.03) 4px
        );
    pointer-events: none;
    opacity: 0.3;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    background: linear-gradient(to bottom, #f4e8d8 0%, #e8dcc8 100%);
    padding: 40px 30px 30px;
    border-radius: 15px 15px 0 0;
    border: 4px solid #5d3a1a;
    border-bottom: none;
    box-shadow: 
        inset 0 2px 0 rgba(255,255,255,0.3),
        0 5px 15px rgba(0,0,0,0.4);
    position: relative;
}

/* Baseball stitching detail */
header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 8px,
        #c44237 8px,
        #c44237 12px
    );
    opacity: 0.3;
}

.header-ornament {
    font-size: 2.5rem;
    margin-bottom: 10px;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.2));
}

header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    color: #2d1810;
    text-shadow: 
        2px 2px 0px rgba(255,255,255,0.5),
        3px 3px 5px rgba(0,0,0,0.2);
    letter-spacing: 2px;
    margin-bottom: 15px;
    font-family: 'Georgia', serif;
}

.header-line {
    width: 200px;
    height: 2px;
    background: linear-gradient(to right, transparent, #8b4513, transparent);
    margin: 15px auto;
}

.tagline {
    font-size: 1.4rem;
    font-style: italic;
    color: #5d3a1a;
    font-weight: 500;
    margin: 10px 0;
}

.est {
    font-size: 0.9rem;
    color: #6d4423;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 10px;
}

main {
    background: linear-gradient(to bottom, #f9f5ed 0%, #f4e8d8 100%);
    border: 4px solid #5d3a1a;
    border-top: none;
    padding: 40px;
    box-shadow: 
        inset 0 3px 10px rgba(0,0,0,0.1),
        0 10px 30px rgba(0,0,0,0.5);
    position: relative;
}

/* Batter's box chalk lines */
main::before,
main::after {
    content: '';
    position: absolute;
    left: 40px;
    right: 40px;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        #d4c5a9,
        #d4c5a9 10px,
        transparent 10px,
        transparent 20px
    );
}

main::before {
    top: 30px;
}

main::after {
    bottom: 30px;
}

.control-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    padding: 20px 0;
}

.card {
    background: #fff9f0;
    border-radius: 8px;
    padding: 28px;
    border: 3px solid #8b6f47;
    box-shadow: 
        0 4px 8px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.5);
    position: relative;
}

/* Baseball stitching on cards */
.card::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 5px,
        rgba(196, 66, 55, 0.3) 5px,
        rgba(196, 66, 55, 0.3) 8px
    );
}

.card h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #2d1810;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #d4c5a9;
    padding-bottom: 10px;
}

.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 28px;
    border: 3px solid #5d3a1a;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Georgia', serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 
        0 4px 0 #3d2410,
        0 5px 10px rgba(0,0,0,0.3);
    position: relative;
    top: 0;
}

.btn:hover:not(:disabled) {
    top: 2px;
    box-shadow: 
        0 2px 0 #3d2410,
        0 3px 8px rgba(0,0,0,0.3);
}

.btn:active:not(:disabled) {
    top: 4px;
    box-shadow: 
        0 0px 0 #3d2410,
        0 1px 5px rgba(0,0,0,0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(to bottom, #c44237 0%, #a83832 100%);
    color: #fff9f0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.btn-secondary {
    background: linear-gradient(to bottom, #8b6f47 0%, #6d5635 100%);
    color: #fff9f0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.btn-outline {
    background: #fff9f0;
    color: #5d3a1a;
    border: 3px solid #8b6f47;
}

.btn-outline:hover:not(:disabled) {
    background: linear-gradient(to bottom, #f4e8d8 0%, #e8dcc8 100%);
}

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

.file-input {
    display: none;
}

.status {
    margin-top: 16px;
    padding: 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    display: none;
    border: 2px solid;
    font-family: 'Georgia', serif;
}

.status.active {
    display: block;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border-color: #4a7c59;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border-color: #a83832;
}

.status.info {
    background: #d1e7f0;
    color: #0c5460;
    border-color: #5a7c8b;
}

.results {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 3px double #8b6f47;
}

.results .card {
    margin-bottom: 25px;
}

canvas {
    display: block;
    width: 100%;
    border-radius: 6px;
    background: #fffef8;
    border: 2px solid #d4c5a9;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

.analysis-output {
    line-height: 2;
}

.processing-flow {
    background: #fffef8;
    border: 3px solid #8b6f47;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.processing-flow h3 {
    color: #2d1810;
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    border-bottom: 2px solid #d4c5a9;
    padding-bottom: 10px;
}

.flow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.flow-step {
    background: linear-gradient(to bottom, #8b6f47 0%, #6d5635 100%);
    color: #fff9f0;
    padding: 12px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    min-width: 140px;
    border: 2px solid #5d3a1a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    line-height: 1.3;
}

.flow-step small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 4px;
}

.flow-arrow {
    color: #8b6f47;
    font-size: 1.5rem;
    font-weight: bold;
}

.result-item {
    padding: 14px 16px;
    margin: 10px 0;
    border-radius: 6px;
    background: #fffef8;
    border-left: 5px solid #8b6f47;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.result-item strong {
    color: #2d1810;
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.result-item .explanation {
    color: #4a3520;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #d4c5a9;
    font-style: italic;
}

.result-item ul {
    margin-left: 20px;
}

.secret-sauce {
    font-size: 0.8rem;
    color: #c44237;
    font-style: italic;
    font-weight: normal;
}

.spurious-visualization {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
}

.spurious-bar {
    display: flex;
    align-items: center;
    margin: 8px 0;
    gap: 10px;
}

.spurious-freq {
    min-width: 80px;
    font-weight: 600;
    color: #5d3a1a;
    font-size: 0.9rem;
}

.bar-container {
    flex: 1;
    position: relative;
    height: 30px;
    background: #e8dcc8;
    border-radius: 4px;
    border: 2px solid #d4c5a9;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(to right, #c44237 0%, #a83832 100%);
    transition: width 0.5s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.bar-label {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    font-size: 0.85rem;
    color: #2d1810;
    text-shadow: 0 0 3px rgba(255,255,255,0.8);
}

.verdict {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    border: 4px solid;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.verdict.good {
    background: linear-gradient(to bottom, #7fb069 0%, #6a9c59 100%);
    color: #fff9f0;
    border-color: #4a7c3d;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.3);
}

.verdict.warning {
    background: linear-gradient(to bottom, #f4a259 0%, #e08c3f 100%);
    color: #2d1810;
    border-color: #c47135;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

.verdict.defect {
    background: linear-gradient(to bottom, #c44237 0%, #a83832 100%);
    color: #fff9f0;
    border-color: #8b2c27;
    text-shadow: 2px 2px 3px rgba(0,0,0,0.3);
}

footer {
    text-align: center;
    color: #f4e8d8;
    margin-top: 30px;
    padding: 30px;
    background: rgba(45, 24, 16, 0.5);
    border-radius: 0 0 15px 15px;
    border: 4px solid #5d3a1a;
    border-top: none;
    box-shadow: 
        inset 0 3px 10px rgba(0,0,0,0.3),
        0 5px 15px rgba(0,0,0,0.4);
}

.footer-ornament {
    font-size: 1.5rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

footer p {
    margin: 8px 0;
    font-size: 0.95rem;
}

.footer-tagline {
    font-style: italic;
    color: #d4c5a9;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    
    main {
        padding: 30px 20px;
    }
    
    .control-panel {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .flow-steps {
        flex-direction: column;
    }
    
    .flow-arrow {
        transform: rotate(90deg);
    }
    
    .flow-step {
        width: 100%;
    }
    
    .spurious-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .spurious-freq {
        min-width: auto;
    }
    
    .bar-container {
        width: 100%;
    }
    
    .demo-controls {
        flex-direction: column;
    }
    
    .btn-demo {
        width: 100%;
    }
}

/* Profile selector */
.profile-select {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Georgia', serif;
    border: 3px solid #8b6f47;
    border-radius: 6px;
    background: #fff9f0;
    color: #2d1810;
    cursor: pointer;
    box-shadow: 
        0 4px 0 #5d3a1a,
        0 5px 10px rgba(0,0,0,0.2);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235d3a1a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.profile-select:focus {
    outline: none;
    border-color: #c44237;
}

/* Card descriptions */
.card-description {
    font-size: 0.9rem;
    color: #6d5635;
    margin: -10px 0 15px 0;
    font-style: italic;
}

/* Demo buttons */
.demo-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-demo {
    flex: 1;
    min-width: 100px;
    padding: 12px 16px;
    font-size: 0.9rem;
}

.demo-icon {
    font-size: 1.1rem;
    margin-right: 6px;
}

.demo-note {
    font-size: 0.85rem;
    color: #8b6f47;
    margin-top: 12px;
    text-align: center;
    font-style: italic;
}

/* Play button */
.btn-play {
    margin-bottom: 20px;
    display: inline-flex;
}

/* Detection method tag */
.detection-method {
    font-size: 0.8rem;
    color: #8b6f47;
    font-style: italic;
    font-weight: normal;
    margin-left: 8px;
}

/* Signal quality colors in results */
.result-item.quality-excellent { border-left-color: #4a7c3d; }
.result-item.quality-good { border-left-color: #6a9c59; }
.result-item.quality-fair { border-left-color: #e08c3f; }
.result-item.quality-poor { border-left-color: #c44237; }

/* Pipeline visualization */
.pipeline-step {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #d4c5a9;
}

.pipeline-step:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pipeline-step h3 {
    font-size: 1.1rem;
    color: #2d1810;
    margin-bottom: 5px;
    font-weight: 700;
}

.step-description {
    font-size: 0.85rem;
    color: #6d5635;
    font-style: italic;
    margin-bottom: 12px;
}

.pipeline-step canvas {
    display: block;
    width: 100%;
    height: 120px;
    border-radius: 4px;
    background: #fffef8;
    border: 2px solid #d4c5a9;
}

.pipeline-step:last-child canvas {
    height: 200px;
}
