:root {
    --primary: #10B981;
    --secondary: #34D399;
    --accent: #6366F1;
    --bg-color: #0A1A14;
    --panel-bg: rgba(16, 26, 20, 0.7);
    --panel-border: rgba(16, 185, 129, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --good-color: #10B981;
    --ni-color: #F59E0B;
    --poor-color: #EF4444;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    background-image: radial-gradient(circle at top right, rgba(16, 185, 129, 0.1), transparent 40%),
        radial-gradient(circle at bottom left, rgba(99, 102, 241, 0.1), transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
}

.score-display {
    background: rgba(10, 26, 20, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.score-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--good-color);
    transition: color 0.3s ease;
}

.score-rating {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--good-color);
    transition: color 0.3s ease;
}

main {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 1fr auto;
    gap: 2rem;
    align-items: start;
}

.panel {
    border-radius: 12px;
    padding: 1.5rem;
}

.glass {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.divider {
    border: 0;
    height: 1px;
    background: var(--panel-border);
    margin: 1.5rem 0;
}

/* Controls panel */
.element-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.element-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.element-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.element-item.active {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.1);
}

.element-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
    display: inline-block;
}

.element-name {
    flex-grow: 1;
    font-size: 0.875rem;
}

.element-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
}

.element-delete:hover {
    color: var(--poor-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
    margin-bottom: 0.5rem;
    font-family: inherit;
}

.btn:last-child {
    margin-bottom: 0;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
}

.primary-btn:hover {
    background: var(--secondary);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.secondary-btn {
    background: var(--accent);
    color: #fff;
}

.secondary-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.outline-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.outline-btn:hover {
    background: rgba(16, 185, 129, 0.1);
}

.text-btn {
    background: transparent;
    color: var(--text-secondary);
}

.text-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Toggles */
.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-top: 1rem;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    transition: .4s;
    margin-right: 0.5rem;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Inspector */
.empty-state {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
    text-align: center;
    padding: 1rem 0;
}

.inspector-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label {
    width: 60px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Viewport panel */
.viewport-panel {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
}

.viewport-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 2rem;
    overflow: hidden;
}

.viewport-header {
    width: 800px;
    /* fixed size for calc */
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.viewport-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.viewport {
    width: 800px;
    height: 600px;
    background: #fff;
    position: relative;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.sim-element {
    position: absolute;
    background: var(--element-color);
    border: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: grab;
    user-select: none;
    /* transition handled dynamically */
}

.sim-element:active {
    cursor: grabbing;
}

.sim-element.selected {
    outline: 2px dashed #000;
    outline-offset: -2px;
    z-index: 100;
}

.sim-element .resizer {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #000;
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
    z-index: 102;
    display: none;
}

.sim-element.selected .resizer {
    display: block;
}

/* Overlay containers */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.overlay-container.hidden {
    display: none;
}

.cls-impact-rect {
    position: absolute;
    background: rgba(239, 68, 68, 0.3);
    border: 1px dashed #EF4444;
}

.cls-initial-rect {
    position: absolute;
    border: 1px dotted rgba(0, 0, 0, 0.5);
}

/* Recommendations panel */
.recommendations-panel {
    grid-column: 1 / -1;
    grid-row: 2;
}

.best-practices {
    list-style-position: inside;
    color: var(--text-secondary);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.best-practices li {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
}

.best-practices code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: monospace;
    color: var(--secondary);
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--panel-bg);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--primary);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
    }

    .viewport-panel {
        grid-column: 1;
        grid-row: 2;
        overflow-x: auto;
    }

    .recommendations-panel {
        grid-row: 3;
    }
}