:root {
    --primary: #22C55E;
    /* Forest Moss Primary */
    --secondary: #86EFAC;
    /* Lighter green */
    --accent: #A3E635;
    /* Lime/Yellow-green accent */
    --background: #0A1A0D;
    /* Deep dark green BG */

    --glass-bg: rgba(10, 26, 13, 0.75);
    --glass-border: rgba(34, 197, 94, 0.2);

    --card-bg: rgba(34, 197, 94, 0.05);
    --card-hover: rgba(134, 239, 172, 0.08);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --error: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 15% 15%, rgba(34, 197, 94, 0.06), transparent 50%),
        radial-gradient(circle at 85% 85%, rgba(163, 230, 53, 0.05), transparent 50%);
}

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

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
}

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

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

/* Utilities */
.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.divider {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 1.5rem 0;
}

h2 {
    font-size: 1.25rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Sidebar Inputs */
.color-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.color-list::-webkit-scrollbar {
    width: 4px;
}

.color-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.5rem;
}

.color-picker {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f8fafc;
    font-family: 'Inter', monospace;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
textarea:focus {
    border-color: var(--primary);
}

.color-hex {
    flex: 1;
    text-transform: uppercase;
}

.remove-color-btn {
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.2rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.remove-color-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

textarea {
    height: 80px;
    resize: vertical;
}

/* Buttons */
.btn {
    padding: 0.75rem 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--primary);
    color: #000;
    font-weight: 600;
}

.primary-btn:hover {
    background: var(--secondary);
}

.secondary-btn {
    background: rgba(34, 197, 94, 0.15);
    color: var(--secondary);
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(34, 197, 94, 0.25);
}

.outline-btn {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}

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

/* Scoreboard */
.scoreboard {
    text-align: center;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
}

.scoreboard h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.score-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.score-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Grid Area */
.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.legend {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.pass-aaa {
    background: #166534;
    color: #bbf7d0;
}

.pass-aa {
    background: #064e3b;
    color: #6ee7b7;
}

.pass-aa-large {
    background: #1e3a8a;
    color: #bfdbfe;
}

.fail {
    background: #7f1d1d;
    color: #fecaca;
}

.grid-scroll-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.grid-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.grid-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.contrast-grid {
    display: grid;
    gap: 1px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    overflow: hidden;
    width: max-content;
    min-width: 100%;
}

.grid-cell {
    width: 100px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, z-index 0s;
}

.grid-cell:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.grid-header-col,
.grid-header-row {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.4) !important;
    cursor: default;
}

.grid-header-col:hover,
.grid-header-row:hover {
    transform: none;
    box-shadow: none;
    z-index: 1;
}

.cell-ratio {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.cell-rating {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

/* Detail Panel */
.detail-panel {
    border-color: var(--accent);
    position: relative;
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

.detail-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-area {
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.preview-text-normal {
    font-size: 14pt;
}

.preview-text-large {
    font-size: 18pt;
    font-weight: bold;
}

.stats-area {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Suggestions */
.suggestion-box h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.suggestion-box p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.suggestion-colors {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.sugg-color-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.sugg-color-node:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sugg-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.sugg-info {
    font-family: 'Inter', monospace;
    font-size: 0.75rem;
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #000;
    padding: 0.75rem 1.25rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -10px);
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .stats-area {
        grid-template-columns: 1fr;
    }
}