:root {
    /* Premium Color Palette */
    --bg-dark: #0f1115;
    --bg-panel: #181b21;
    --bg-input: #232730;

    --accent-primary: #00f0ff;
    /* Cyber Cyan */
    --accent-secondary: #7000ff;
    /* Electric Purple */
    --accent-glow: rgba(0, 240, 255, 0.4);

    --accent-gap: #ffbb00;
    /* Bright Orange for Visibility */

    --text-main: #ffffff;
    --text-muted: #8b9bb4;

    --border-color: #2f3640;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-led {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    box-shadow: 0 0 15px var(--accent-glow);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout */
.calculator-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    flex: 1;
    height: calc(100% - 100px);
}

/* Controls Panel */
.controls-panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-header h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Inputs */
#calcForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.premium-select,
input[type="number"] {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    transition: all 0.2s;
}

.premium-select:focus,
input[type="number"]:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

/* Custom Number Input */
.custom-number-input {
    position: relative;
    display: flex;
    align-items: center;
}

/* Hide native spin buttons */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
    /* Firefox */
    padding-right: 30px;
    /* Make space for spinners */
}

.spinner-controls {
    position: absolute;
    right: 2px;
    top: 2px;
    bottom: 2px;
    display: flex;
    flex-direction: column;
    width: 24px;
    gap: 1px;
}

.spinner-btn {
    flex: 1;
    border: none;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 2px;
}

.spinner-btn.up {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.spinner-btn:hover {
    background: var(--bg-panel);
    color: var(--accent-primary);
}

.spinner-btn:active {
    color: var(--text-main);
}

.product-info-mini {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: none;
    /* Shown by JS */
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border-color);
}

.toggle-group input {
    display: none;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.toggle-group input:checked+.toggle-btn {
    background: var(--bg-panel);
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input-section {
    display: none;
}

.input-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.dual-input {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    margin-top: auto;
}

.action-btn:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(1px);
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.visualizer-container {
    flex: 1;
    background: transparent;
    /* Transparent background */
    border-radius: var(--radius-lg);
    border: none;
    /* No outer border */
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    margin: 20px;
}

/* Gap Labels */
.gap-label {
    position: absolute;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 20;
    display: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    /* Shown by JS */
}

.gap-top {
    top: 5px;
    left: 0;
    width: 100%;
    text-align: center;
}

.gap-bottom {
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
}

.gap-left {
    top: 0;
    left: 10px;
    height: 100%;
    display: flex;
    align-items: center;
}

.gap-right {
    top: 0;
    right: 10px;
    height: 100%;
    display: flex;
    align-items: center;
}

.screen-frame {
    position: relative;
    padding: 0;
    /* Removing padding to allow precise calc */
    background: transparent;
    /* transition: all 0.5s ease; removed for immediate snap on resize */
    border: 1px solid var(--accent-gap);
    /* Target Frame style */
    /* border-radius: 4px; removed per user request */
    box-sizing: content-box;
    /* Ensure border is outside content so grid doesn't cover it */
    display: flex;
    /* Centers if we wanted, but we want top-left for gap? Actually top-left is better for standard gap vis */
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

/* Label for Target if needed, or maybe just styling the gap area */
.screen-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.03) 50%, rgba(255, 255, 255, 0.03) 75%, transparent 75%, transparent);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
}

.led-grid {
    display: grid;
    gap: 1px;
    background: #111;
    border: 1px solid #444;
    /* Box shadow to separate from gap background */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    /* Dimensions set by JS */
}

.led-cell {
    background: #2a2a2a;
    /* Brighter cell */
    border: 1px solid #444;
    position: relative;
    transition: background 0.3s;
}

.led-cell:hover {
    background: #333;
    border-color: var(--accent-primary);
}

.led-cell::after {
    content: '';
    position: absolute;
    inset: 2px;
    /* Lines instead of dots */
    background: linear-gradient(to bottom, transparent 50%, rgba(255, 255, 255, 0.1) 50%);
    background-size: 100% 4px;
    opacity: 0.5;
}

.dimension-label {
    position: absolute;
    color: var(--accent-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* Center Lines */
.center-line {
    position: absolute;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.center-line span {
    background: rgba(0, 0, 0, 0.9);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--accent-primary);
    white-space: nowrap;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.center-line.horizontal {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--accent-primary);
    transform: translateY(-50%);
}

/* Horizontal Ticks */
.center-line.horizontal::before,
.center-line.horizontal::after {
    content: '';
    position: absolute;
    height: 12px;
    width: 2px;
    background: var(--accent-primary);
    top: 50%;
    transform: translateY(-50%);
}

.center-line.horizontal::before {
    left: 0;
}

.center-line.horizontal::after {
    right: 0;
}

.center-line.vertical {
    left: 50%;
    top: 0;
    height: 100%;
    width: 1px;
    background: var(--accent-primary);
    transform: translateX(-50%);
}

/* Vertical Ticks */
.center-line.vertical::before,
.center-line.vertical::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 2px;
    background: var(--accent-primary);
    left: 50%;
    transform: translateX(-50%);
}

.center-line.vertical::before {
    top: 0;
}

.center-line.vertical::after {
    bottom: 0;
}

.width-label {
    position: absolute;
    top: calc(100% + 10px);
    /* Below frame with gap */
    left: 0;
    width: 100%;
    text-align: center;
    padding-top: 5px;
    border-top: 1px solid var(--accent-primary);
}

.width-label::before,
.width-label::after {
    content: '';
    position: absolute;
    top: -4px;
    /* Align centered on line */
    height: 9px;
    width: 1px;
    background: var(--accent-primary);
}

.width-label::before {
    left: 0;
}

.width-label::after {
    right: 0;
}

.height-label {
    position: absolute;
    right: calc(100% + 10px);
    /* Left of frame with gap */
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--accent-primary);
    padding-right: 10px;
    white-space: nowrap;
}

.height-label::before,
.height-label::after {
    content: '';
    position: absolute;
    right: -1px;
    /* Align on line */
    width: 9px;
    height: 1px;
    background: var(--accent-primary);
}

.height-label::before {
    top: 0;
    right: -4px;
    /* Center tick on line */
}

.height-label::after {
    bottom: 0;
    right: -4px;
    /* Center tick on line */
}


/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.metric-card {
    background: var(--bg-panel);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-card.highlight {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(112, 0, 255, 0.1));
    border-color: rgba(0, 240, 255, 0.3);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.metric-unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .calculator-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .controls-panel {
        max-width: 100%;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}