:root {
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg-dark: #0f172a;
    --bg-glass: rgba(15, 23, 42, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-hover: rgba(30, 41, 59, 0.9);
}

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

body {
    font-family: var(--font-ui);
    color: var(--text-main);
    background-color: var(--bg-dark);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Dynamic Background */
.app-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: var(--bg-dark);
    /* We will inject a radial gradient overlay via JS for a soft glow of the color */
    transition: background-color 0.5s ease;
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    z-index: 10;
    position: relative;
}

/* Header Input */
.header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

#color-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 3rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-main);
    text-align: center;
    padding: 1rem 0;
    outline: none;
    text-transform: lowercase;
}

#color-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
    font-size: 2rem;
}

.input-underline {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 4px;
    width: 50%;
    background: var(--text-main);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

#color-input:focus~.input-underline {
    width: 100%;
}

.error-message {
    margin-top: 1rem;
    color: #ef4444;
    font-weight: 500;
    font-size: 0.9rem;
    opacity: 1;
    transition: opacity 0.3s;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.error-message.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Contrast Section */
.contrast-section {
    width: 100%;
}

.contrast-box {
    width: 100%;
    height: 120px;
    border-radius: 16px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    transition: background-color 0.3s ease;
}

.contrast-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease;
}

.contrast-text.black-text {
    color: #000000;
}

.contrast-text.white-text {
    color: #ffffff;
}

.text-sample {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.contrast-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ratio {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.badge.pass {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge.fail {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.contrast-text.black-text .badge.pass {
    background: rgba(16, 185, 129, 0.3);
    color: #047857;
}

.contrast-text.black-text .badge.fail {
    background: rgba(239, 68, 68, 0.3);
    color: #b91c1c;
}

/* Formats Grid */
.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.format-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.format-card:hover {
    background: var(--card-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.format-header h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.format-value-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.format-value {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 500;
    outline: none;
    width: 100%;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    transform: scale(0.9);
}

.format-card:hover .copy-btn {
    opacity: 1;
    transform: scale(1);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Shades */
.shades-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.shades-track {
    display: flex;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.swatch {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.5rem;
    cursor: pointer;
    transition: flex 0.3s ease;
    position: relative;
}

.swatch:hover {
    flex: 1.5;
}

.swatch-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.swatch:hover .swatch-label {
    opacity: 1;
    transform: translateY(0);
}

.swatch-label.dark {
    color: #000;
}

.swatch-label.light {
    color: #fff;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #fff;
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsiveness */
@media (max-width: 768px) {
    #color-input {
        font-size: 2rem;
    }

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

    .copy-btn {
        opacity: 1;
        /* Always show on touch devices */
        transform: scale(1);
    }
}