:root {
    --bg-color: #0d0f14;
    --card-bg: rgba(22, 27, 34, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --accent-color: #5865F2;
    --accent-gradient: linear-gradient(135deg, #5865F2 0%, #2D9CDB 100%);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --input-bg: rgba(0, 0, 0, 0.2);
    --font-family: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    line-height: 1.5;
}

.background-gradients {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 40vw;
    height: 40vw;
    background: #5865F2;
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 35vw;
    height: 35vw;
    background: #9b59b6;
    bottom: -5%;
    right: -5%;
    animation-delay: -5s;
}

.orb-3 {
    width: 30vw;
    height: 30vw;
    background: #2D9CDB;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(30px, -30px) scale(1.1);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.05em;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* Card Styles */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Form Elements */
.input-group,
.dimensions-inputs,
.mat-section {
    width: 100%;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
}

.input-wrapper label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="number"],
select {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    width: 100%;
    appearance: none;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #5865F2;
    background-color: rgba(88, 101, 242, 0.1);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.7;
}

.dimensions-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.dimensions-inputs .input-wrapper:last-child {
    grid-column: span 2;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
    width: 100%;
}

/* Toggle & Radio */
.toggle-container {
    display: flex;
    background: var(--input-bg);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
    border: 1px solid var(--border-color);
}

.toggle-container input[type="radio"] {
    display: none;
}

.toggle-container label {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
}

.toggle-container input[type="radio"]:checked+label {
    background: var(--border-color);
    color: white;
    font-weight: 600;
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: #5865F2;
    border-color: #5865F2;
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkbox-wrapper label {
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
}

/* Buttons */
.btn-small {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 500;
}

.btn-small:hover {
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.2) 0%, rgba(45, 156, 219, 0.2) 100%);
    border-color: #5865F2;
}

.btn-small.hidden {
    display: none;
}

/* Mat Section */
.mat-dimensions {
    transition: all 0.4s ease;
    overflow: hidden;
    max-height: 500px;
    opacity: 1;
}

.mat-dimensions.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: -1rem;
    /* Collapse visual gap */
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.mat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Result Card */
.result-card {
    min-height: 480px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.badge {
    background: var(--accent-gradient);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.4);
}

.main-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dimension-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dimension-box .label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.dimension-box .value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(to bottom, #fff, #dadada);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.unit-label {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.x-separator {
    font-size: 2rem;
    color: var(--text-secondary);
    opacity: 0.5;
    padding-top: 1.5rem;
}

/* Specs Table */
.specs-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.specs-container.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.specs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.specs-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 500;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.specs-table td {
    padding: 0.75rem 0;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.specs-table tr:last-child td {
    border-bottom: none;
}

.highlight-row {
    color: #5865F2 !important;
    font-weight: 600;
}

.result-details {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#recommendation-text {
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Frame Preview */
.visualizer {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.frame-preview {
    background: #1a1a1a;
    border: 8px solid #4a4a4a;
    /* Frame Color */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 100px;
    height: 120px;
    position: relative;
}

.mat-preview {
    background: #f0f0f0;
    /* Mat Color */
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    /* Simulating mat */
}

.art-preview {
    background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mode Switcher */
.mode-switcher-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.mode-switch {
    position: relative;
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 30px;
    padding: 4px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 350px;
}

.mode-switch input {
    display: none;
    /* Hide default radio */
}

.mode-switch label {
    flex: 1;
    text-align: center;
    padding: 10px 15px;
    z-index: 2;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s ease;
    border-radius: 25px;
}

.mode-switch .slide-bg {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    width: calc(50% - 4px);
    background: var(--accent-gradient);
    border-radius: 25px;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(88, 101, 242, 0.3);
}

/* Toggle Logic */
#mode-find-frame:checked~label[for="mode-find-frame"] {
    color: white;
    font-weight: 600;
}

#mode-fixed-frame:checked~label[for="mode-fixed-frame"] {
    color: white;
    font-weight: 600;
}

#mode-fixed-frame:checked~.slide-bg {
    transform: translateX(100%);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .app-header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }
}

/* Global Utility */
.hidden {
    display: none !important;
}

/* DIY Guide */
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
}

.diy-guide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1b26;
    border-radius: 20px;
    padding: 1.5rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

.diy-guide.hidden {
    display: none;
}

.diy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.diy-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.diy-content h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5865F2;
    /* Accent color */
    margin-bottom: 1rem;
}

.diy-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}

.diy-table td {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}

.diy-table tr:last-child td {
    border-bottom: none;
}

.diy-table td:first-child {
    width: 45%;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.diy-table td:last-child {
    text-align: right;
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.sub-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: normal;
}

.overlap-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
    text-align: right;
}

.rec-list {
    list-style: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

.rec-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    padding-left: 1rem;
    position: relative;
    line-height: 1.4;
}

.rec-list li::before {
    content: "•";
    color: #5865F2;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.rec-list strong {
    color: var(--text-primary);
}

.pro-tip {
    background: rgba(88, 101, 242, 0.1);
    border-left: 3px solid #5865F2;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #cad1f7;
    line-height: 1.4;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}