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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
    overflow-x: hidden;
}

nav {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 1rem 2rem;
    border-bottom: 1px solid #404040;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: #c0c0c0;
    text-decoration: none;
    font-weight: 600;
}

nav a:hover {
    color: #ffffff;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    margin-right: auto;
}

.logo a {
    color: #ffffff;
    text-decoration: none;
}

.logo a:hover {
    color: #ffffff;
}

.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.builder-layout {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
}

.section {
    background: linear-gradient(135deg, #2a2a2a 0%, #232323 100%);
    padding: 2rem;
    border-radius: 3px;
    margin-bottom: 2rem;
    border: 1px solid #404040;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    position: relative;
}

.section::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background:
        repeating-linear-gradient(
            0deg,
            #808080,
            #808080 5px,
            #606060 5px,
            #606060 10px
        );
}

.section h2 {
    color: #c0c0c0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.preset-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.preset-card {
    background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
    padding: 1.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #303030;
}

.preset-card:hover {
    border-color: #505050;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.preset-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #e0e0e0;
}

.preset-desc {
    color: #909090;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.preset-price {
    color: #c0c0c0;
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.preset-loading {
    color: #808080;
    font-style: italic;
    font-size: 0.9rem;
}

.part-grid {
    max-height: 400px;
    overflow-y: auto;
    display: grid;
    gap: 1rem;
    padding-right: 0.5rem;
}

.part-grid::-webkit-scrollbar {
    width: 8px;
}

.part-grid::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

.part-grid::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 3px;
}

.part-grid::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

.part-card {
    background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
    padding: 1.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid #303030;
}

.part-card:hover {
    border-color: #505050;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.part-card.selected {
    border-color: #606060;
    background: linear-gradient(135deg, #2a2a2a 0%, #252525 100%);
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}

.part-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: #e0e0e0;
}

.part-specs {
    color: #909090;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.part-price {
    color: #c0c0c0;
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.summary {
    position: sticky;
    top: 6rem;
    max-height: calc(100vh - 8rem);
    min-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Apply mesh as background that scrolls with content */
.summary.section {
    background-image:
        repeating-linear-gradient(
            0deg,
            #808080,
            #808080 5px,
            #606060 5px,
            #606060 10px
        ),
        linear-gradient(135deg, #2a2a2a 0%, #232323 100%);
    background-size: 20px 100%, 100% 100%;
    background-position: 0 0, 0 0;
    background-repeat: repeat-y, no-repeat;
}

/* Remove the pseudo-element for summary since we're using background instead */
.summary.section::before {
    display: none;
}

.summary::-webkit-scrollbar {
    width: 8px;
}

.summary::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 3px;
}

.summary::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 3px;
}

.summary::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

.summary-item {
    padding: 1rem;
    background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
    border-radius: 3px;
    margin-bottom: 1rem;
    border: 1px solid #303030;
}

.summary-item-link {
    display: block;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.summary-item-link:hover {
    background: linear-gradient(135deg, #252525 0%, #1f1f1f 100%);
    border-color: #404040;
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.summary-label {
    color: #909090;
    font-size: 0.9rem;
}

.summary-value {
    font-weight: 600;
    margin-top: 0.3rem;
    color: #e0e0e0;
}

.total-price {
    background: linear-gradient(135deg, #3a3a3a 0%, #2d2d2d 100%);
    padding: 1.5rem;
    border-radius: 3px;
    text-align: center;
    margin: 2rem 0;
    color: white;
    border: 1px solid #505050;
}

.total-price .label {
    font-size: 1rem;
}

.total-price .amount {
    font-size: 2.5rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.warning {
    background: linear-gradient(135deg, #4a2525 0%, #3d1f1f 100%);
    color: #ffb3b3;
    padding: 1rem;
    border-radius: 3px;
    margin: 1rem 0;
    border: 1px solid #5a3030;
}

.success {
    background: linear-gradient(135deg, #254a25 0%, #1f3d1f 100%);
    color: #b3ffb3;
    padding: 1rem;
    border-radius: 3px;
    margin: 1rem 0;
    border: 1px solid #305a30;
}

.buy-links-container {
    margin-top: 0;
}

.buy-links-header {
    color: #c0c0c0;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0;
    border-bottom: 2px solid #404040;
}

.buy-links {
    display: grid;
    gap: 1.5rem;
}

.buy-link-section {
    border-top: 1px solid #404040;
    padding-top: 1rem;
}

.buy-link-section:first-child {
    border-top: none;
    padding-top: 0;
}

.buy-section-header {
    color: #c0c0c0;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.listing-selector {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.listing-selector label {
    display: block;
    color: #909090;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.listing-dropdown {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem;
    background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
    border: 1px solid #404040;
    border-radius: 3px;
    color: #e0e0e0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.listing-dropdown:hover {
    border-color: #505050;
    background: linear-gradient(135deg, #252525 0%, #1f1f1f 100%);
}

.listing-dropdown:focus {
    outline: none;
    border-color: #606060;
    box-shadow: 0 0 0 2px rgba(96, 96, 96, 0.2);
}

.current-listing {
    margin-bottom: 0.75rem;
}

.search-fallback {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #303030;
}

.buy-link-item {
    position: relative;
}

.buy-btn {
    display: block;
    background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
    padding: 1rem;
    border-radius: 3px;
    border: 2px solid #303030;
    text-decoration: none;
    color: #e0e0e0;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.buy-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #808080;
}

.buy-btn:hover {
    background: linear-gradient(135deg, #2a2a2a 0%, #252525 100%);
    border-color: #505050;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Non-linked buy button - shows tooltip on hover */
.buy-btn.no-link {
    cursor: default;
    opacity: 0.95;
}

.buy-link-item { position: relative; }

.buy-btn.no-link::after {
    content: attr(data-tooltip);
    position: absolute;
    top: -2.5rem;
    left: 0;
    white-space: nowrap;
    background: rgba(0,0,0,0.9);
    color: #fff;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
    z-index: 30;
}

.buy-btn.no-link:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.buy-btn .part-label {
    display: block;
    color: #909090;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    margin-left: 1rem;
}

.buy-btn .part-name {
    display: block;
    color: #e0e0e0;
    font-weight: 600;
    margin-left: 1rem;
}


select, input {
    width: 100%;
    padding: 0.8rem;
    background: #1f1f1f;
    border: 1px solid #404040;
    border-radius: 3px;
    color: #e0e0e0;
    margin-bottom: 1rem;
}

footer {
    background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
    color: #909090;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
    border-top: 1px solid #404040;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Medium screens - merge Purchase Parts with Build Summary (1024px and below) */
@media (max-width: 1024px) {
    .builder-layout {
        grid-template-columns: 2fr 1fr;
    }
}

/* Tablets and smaller (768px and below) */
@media (max-width: 768px) {
    nav {
        padding: 1rem 1rem;
    }

    nav ul {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .logo {
        font-size: 1.2rem;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 0.3rem;
        margin: 1rem auto;
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
    }

    .builder-layout {
        display: grid !important;
        grid-template-columns: 1.2fr 0.9fr 0.9fr !important;
        gap: 0.3rem;
        width: 100%;
        box-sizing: border-box;
    }

    .builder-layout > div {
        min-width: 0;
        overflow: hidden;
    }

    .section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        box-sizing: border-box;
        width: 100%;
    }

    .section h2 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
        word-wrap: break-word;
    }

    .section::before {
        width: 6px;
    }

    .summary {
        position: static;
        max-height: 80vh;
        overflow-y: auto;
    }

    .summary.section {
        background-size: 6px 100%, 100% 100%;
    }

    .total-price .amount {
        font-size: 1.5rem;
    }

    .total-price {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }

    .total-price .label {
        font-size: 0.8rem;
    }

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

    .part-grid {
        max-height: 300px;
    }

    .buy-section-header {
        font-size: 0.8rem;
        word-wrap: break-word;
    }

    .listing-dropdown {
        max-width: 100%;
        font-size: 0.75rem;
        padding: 0.4rem;
    }

    .part-card, .preset-card {
        padding: 0.6rem;
    }

    .part-name, .preset-name {
        font-size: 0.85rem;
        word-wrap: break-word;
    }

    .part-specs, .preset-desc {
        font-size: 0.7rem;
        word-wrap: break-word;
    }

    .part-price, .preset-price {
        font-size: 0.9rem;
    }

    .buy-links-header {
        font-size: 0.95rem;
        margin-bottom: 0.6rem;
    }

    .buy-btn {
        padding: 0.5rem;
    }

    .buy-btn .part-label {
        font-size: 0.65rem;
        margin-left: 0.4rem;
    }

    .buy-btn .part-name {
        font-size: 0.75rem;
        margin-left: 0.4rem;
        word-wrap: break-word;
    }

    .buy-btn::before {
        width: 3px;
    }

    .summary-item {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .summary-label {
        font-size: 0.7rem;
    }

    .summary-value {
        font-size: 0.8rem;
        word-wrap: break-word;
    }

    .warning, .success {
        padding: 0.5rem;
        font-size: 0.75rem;
        margin: 0.5rem 0;
    }

    select, input {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
}

/* Mobile devices (480px and below) */
@media (max-width: 480px) {
    nav {
        padding: 0.6rem 0.4rem;
    }

    nav ul {
        gap: 0.4rem;
        font-size: 0.75rem;
    }

    .logo {
        font-size: 0.85rem;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 0.25rem;
        margin: 0.5rem auto;
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
    }

    .builder-layout {
        display: grid !important;
        grid-template-columns: 1.1fr 0.95fr 0.95fr !important;
        gap: 0.25rem;
        width: 100%;
        box-sizing: border-box;
    }

    .builder-layout > div {
        min-width: 0;
        overflow: hidden;
    }

    .section {
        padding: 0.4rem;
        margin-bottom: 0.4rem;
        box-sizing: border-box;
        width: 100%;
    }

    .section h2 {
        font-size: 0.75rem;
        margin-bottom: 0.4rem;
        word-wrap: break-word;
    }

    .section::before {
        width: 4px;
    }

    .summary {
        position: static;
        max-height: 75vh;
        overflow-y: auto;
    }

    .summary.section {
        background-size: 4px 100%, 100% 100%;
    }

    .preset-card {
        padding: 0.5rem;
    }

    .preset-name {
        font-size: 0.75rem;
        word-wrap: break-word;
    }

    .preset-desc {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .preset-price {
        font-size: 0.8rem;
    }

    .part-card {
        padding: 0.5rem;
    }

    .part-name {
        font-size: 0.75rem;
        word-wrap: break-word;
    }

    .part-specs {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .part-price {
        font-size: 0.8rem;
    }

    .part-grid {
        max-height: 250px;
        gap: 0.4rem;
    }

    .summary-item {
        padding: 0.4rem;
        margin-bottom: 0.4rem;
    }

    .summary-label {
        font-size: 0.65rem;
    }

    .summary-value {
        font-size: 0.7rem;
        word-wrap: break-word;
    }

    .total-price {
        padding: 0.5rem;
        margin: 0.5rem 0;
    }

    .total-price .label {
        font-size: 0.7rem;
    }

    .total-price .amount {
        font-size: 1.2rem;
    }

    .warning,
    .success {
        padding: 0.4rem;
        font-size: 0.7rem;
        margin: 0.4rem 0;
    }

    .buy-links-header {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .buy-section-header {
        font-size: 0.7rem;
        margin-bottom: 0.4rem;
        word-wrap: break-word;
    }

    .listing-selector {
        margin-bottom: 0.4rem;
    }

    .listing-selector label {
        font-size: 0.65rem;
    }

    .listing-dropdown {
        padding: 0.3rem;
        font-size: 0.65rem;
    }

    .buy-btn {
        padding: 0.4rem;
    }

    .buy-btn .part-label {
        font-size: 0.6rem;
        margin-left: 0.3rem;
    }

    .buy-btn .part-name {
        font-size: 0.65rem;
        margin-left: 0.3rem;
        word-wrap: break-word;
    }

    .buy-btn::before {
        width: 2px;
    }

    select, input {
        padding: 0.3rem;
        font-size: 0.7rem;
    }

    #formFactorFilter {
        font-size: 0.7rem;
    }

    footer {
        padding: 0.8rem 0.4rem;
        font-size: 0.75rem;
        margin-top: 1rem;
    }
}

/* Very small mobile devices (360px and below) */
@media (max-width: 360px) {
    nav {
        padding: 0.4rem 0.3rem;
    }

    nav ul {
        gap: 0.3rem;
        font-size: 0.65rem;
    }

    .logo {
        font-size: 0.75rem;
    }

    body {
        overflow-x: hidden;
    }

    .container {
        padding: 0 0.2rem;
        max-width: 100%;
        overflow: visible;
        box-sizing: border-box;
    }

    .builder-layout {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 0.2rem;
        width: 100%;
        box-sizing: border-box;
    }

    .builder-layout > div {
        min-width: 0;
        overflow: hidden;
    }

    .section {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
        box-sizing: border-box;
        width: 100%;
    }

    .section h2 {
        font-size: 0.65rem;
        margin-bottom: 0.3rem;
        word-wrap: break-word;
    }

    .section::before {
        width: 3px;
    }

    .summary {
        max-height: 70vh;
    }

    .summary.section {
        background-size: 3px 100%, 100% 100%;
    }

    .part-card,
    .preset-card {
        padding: 0.4rem;
    }

    .part-name,
    .preset-name {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .part-specs,
    .preset-desc {
        font-size: 0.6rem;
        word-wrap: break-word;
    }

    .part-price,
    .preset-price {
        font-size: 0.7rem;
    }

    .part-grid {
        max-height: 200px;
        gap: 0.3rem;
    }

    .summary-item {
        padding: 0.3rem;
        margin-bottom: 0.3rem;
    }

    .summary-label {
        font-size: 0.6rem;
    }

    .summary-value {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .total-price {
        padding: 0.4rem;
        margin: 0.4rem 0;
    }

    .total-price .label {
        font-size: 0.65rem;
    }

    .total-price .amount {
        font-size: 1.1rem;
    }

    .warning,
    .success {
        padding: 0.3rem;
        font-size: 0.65rem;
    }

    .buy-links-header {
        font-size: 0.7rem;
        margin-bottom: 0.3rem;
    }

    .buy-section-header {
        font-size: 0.65rem;
        word-wrap: break-word;
    }

    .listing-selector {
        margin-bottom: 0.3rem;
    }

    .listing-selector label {
        font-size: 0.6rem;
    }

    .listing-dropdown {
        padding: 0.3rem;
        font-size: 0.6rem;
    }

    .buy-btn {
        padding: 0.3rem;
    }

    .buy-btn .part-label {
        font-size: 0.55rem;
        margin-left: 0.2rem;
    }

    .buy-btn .part-name {
        font-size: 0.6rem;
        margin-left: 0.2rem;
        word-wrap: break-word;
    }

    .buy-btn::before {
        width: 2px;
    }

    select, input {
        padding: 0.3rem;
        font-size: 0.65rem;
    }

    footer {
        padding: 0.6rem 0.3rem;
        font-size: 0.65rem;
        margin-top: 0.8rem;
    }
}