:root {
    /* Base theme colors - will be updated by JS */
    --color-bg-primary: #040408;
    --color-bg-secondary: #0a0a12;
    --color-bg-tertiary: #12121c;
    --color-bg-elevated: rgba(30, 41, 59, 0.5);
    
    --color-surface: rgba(30, 41, 59, 0.4);
    --color-surface-hover: rgba(40, 51, 69, 0.5);
    --color-border: rgba(71, 85, 105, 0.3);
    --color-border-focus: #a78bfa;
    
    --color-text-primary: #f8fafc;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;
    --color-text-on-accent: #ffffff;
    
    --color-accent: #a78bfa;
    --color-accent-hover: #c4b5fd;
    --color-accent-subtle: rgba(167, 139, 250, 0.2);
    
    --color-success: #4ade80;
    --color-error: #f87171;
    
    /* Gradient for title */
    --gradient-title: linear-gradient(135deg, var(--color-primary-400) 0%, var(--color-accent-500) 50%, var(--color-secondary-500) 100%);
    
    /* Theme palette colors */
    --color-primary-50: #faf5ff;
    --color-primary-100: #f3e8ff;
    --color-primary-200: #e9d5ff;
    --color-primary-300: #d8b4fe;
    --color-primary-400: #c084fc;
    --color-primary-500: #a855f7;
    --color-primary-600: #9333ea;
    --color-primary-700: #7e22ce;
    --color-primary-800: #6b21a8;
    --color-primary-900: #581c87;
    --color-primary-950: #3b0764;
    
    --color-secondary-500: #ec4899;
    --color-tertiary-500: #f97316;
    --color-accent-500: #ec4899;
    --color-neutral-500: #64748b;
    --color-neutral-800: #1e293b;
    --color-neutral-900: #0f172a;
}

* {
    box-sizing: border-box;
}

/* Hide scrollbar while keeping scroll functionality */
html {
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    overscroll-behavior-y: contain;
}

html::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(145deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 50%, var(--color-bg-tertiary) 100%);
    background-attachment: fixed;
    color: var(--color-text-primary);
    padding: 1.5rem 1rem;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    transition: background 0.5s ease;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
}

.container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    background: var(--gradient-title);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    transition: background 0.3s ease;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 400;
    margin: 0 0 1rem 0;
}

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.github-link:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.github-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.github-link:hover .github-icon {
    transform: scale(1.1);
}

.npm-install {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, var(--color-primary-900) 0%, var(--color-primary-950) 100%);
    border: 1px solid var(--color-primary-700);
    border-radius: 8px;
    color: var(--color-primary-200);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.npm-install::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--color-primary-800) 0%, var(--color-primary-900) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.npm-install:hover::before {
    opacity: 1;
}

.npm-install:hover {
    border-color: var(--color-primary-500);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--color-accent-subtle);
}

.npm-install:active {
    transform: translateY(0);
}

.npm-install > * {
    position: relative;
    z-index: 1;
}

.npm-prefix {
    color: var(--color-primary-400);
    font-weight: 600;
}

.npm-install code {
    color: var(--color-primary-100);
}

.copy-icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.npm-install:hover .copy-icon {
    opacity: 1;
}

.npm-install.copied {
    border-color: var(--color-success);
}

.npm-install.copied code::after {
    color: var(--color-success);
}

.input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: var(--color-bg-elevated);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

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

#theme_base {
    width: 44px;
    height: 32px;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    transition: all 0.2s ease;
}

#theme_base:hover,
#theme_base:focus {
    border-color: var(--color-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

#color_value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--color-text-primary);
    background: var(--color-neutral-900);
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    width: 85px;
    text-align: center;
    text-transform: uppercase;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

#color_value:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

#color_value::placeholder {
    color: var(--color-text-muted);
    text-transform: none;
}

#color_value.invalid {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25);
}

.palette-wrapper {
    background: var(--color-surface);
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--color-border);
    backdrop-filter: blur(10px);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.palette-content {
    width: 100%;
}

.shade-header {
    display: none;
}

#palette {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.color-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-secondary);
    padding-left: 2px;
}

.shades {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.box-color {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.box-color::before {
    content: attr(data-shade);
    opacity: 0.8;
}

.box-color:active {
    transform: scale(0.92);
}

.box-color.light-text {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.box-color.dark-text {
    color: rgba(15, 23, 42, 0.8);
}

/* Toast notification */
#toast {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    transform: translateY(120%);
    background: var(--color-neutral-800);
    color: var(--color-text-primary);
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--color-border);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

#toast .color-preview {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

#toast .check-icon {
    color: var(--color-success);
    font-size: 0.9rem;
}

#toast .toast-text {
    font-size: 0.75rem;
}

/* Footer hint */
.footer-hint {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* ========================================
   SMALL PHONES - Landscape
   ======================================== */
@media (max-width: 639px) and (orientation: landscape) {
    body {
        padding: 1rem;
    }
    .container {
        max-width: 100%;
    }
    header {
        margin-bottom: 1rem;
    }
    h1 {
        font-size: 1.25rem;
    }
    #palette {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .shades {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ========================================
   TABLET (min-width: 640px)
   ======================================== */
@media (min-width: 640px) {
    body {
        padding: 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .container {
        max-width: 600px;
    }
    header {
        margin-bottom: 2rem;
    }
    h1 {
        font-size: 2rem;
    }
    .subtitle {
        font-size: 0.875rem;
    }
    .input-wrapper {
        gap: 1rem;
        padding: 1rem 1.25rem;
        margin-bottom: 2rem;
        border-radius: 14px;
    }
    .input-label {
        font-size: 0.8rem;
    }
    #theme_base {
        width: 52px;
        height: 38px;
        border-radius: 8px;
    }
    #color_value {
        font-size: 0.8rem;
        padding: 0.45rem 0.85rem;
        width: 95px;
    }
    .palette-wrapper {
        padding: 1.5rem;
        border-radius: 20px;
    }
    #palette {
        gap: 1rem;
    }
    .color-label {
        font-size: 0.7rem;
    }
    .shades {
        grid-template-columns: repeat(11, 1fr);
        gap: 6px;
    }
    .box-color {
        border-radius: 8px;
        font-size: 7px;
    }
    .box-color:hover {
        transform: scale(1.1);
        z-index: 10;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    }
    #toast {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(120%);
        width: auto;
        min-width: 280px;
    }
    #toast.show {
        transform: translateX(-50%) translateY(0);
    }
    .footer-hint {
        font-size: 0.7rem;
        margin-top: 1.5rem;
    }
}

/* ========================================
   TABLET - Landscape / Small Desktop
   ======================================== */
@media (min-width: 768px) {
    body {
        padding: 2.5rem;
    }
    .container {
        max-width: 800px;
    }
    header {
        margin-bottom: 2.5rem;
    }
    h1 {
        font-size: 2.25rem;
    }
    .input-wrapper {
        display: inline-flex;
        margin-bottom: 2.5rem;
    }
    .palette-wrapper {
        padding: 2rem;
    }
    .shade-header {
        display: flex;
        gap: 8px;
        margin-left: calc(90px + 1.25rem);
        margin-bottom: 0.75rem;
    }
    .shade-header span {
        flex: 1;
        max-width: 52px;
        text-align: center;
        font-size: 0.65rem;
        font-weight: 600;
        color: var(--color-text-muted);
        letter-spacing: 0.02em;
    }
    #palette {
        gap: 6px;
    }
    .color-row {
        flex-direction: row;
        align-items: center;
        gap: 1.25rem;
    }
    .color-label {
        width: 90px;
        text-align: right;
        flex-shrink: 0;
    }
    .shades {
        display: flex;
        flex: 1;
        gap: 8px;
    }
    .box-color {
        flex: 1;
        max-width: 52px;
        aspect-ratio: auto;
        height: 40px;
    }
    .box-color::before {
        display: none;
    }
    .box-color::after {
        content: 'Copy';
        position: absolute;
        bottom: -20px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 8px;
        font-weight: 500;
        color: var(--color-text-muted);
        opacity: 0;
        transition: opacity 0.15s ease;
        pointer-events: none;
    }
    .box-color:hover::after {
        opacity: 1;
    }
    .box-color:hover {
        transform: scale(1.15) translateY(-4px);
    }
    .box-color:active {
        transform: scale(1.05) translateY(-2px);
    }
}

/* ========================================
   DESKTOP (min-width: 1024px)
   ======================================== */
@media (min-width: 1024px) {
    body {
        padding: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .container {
        max-width: 1200px;
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header header"
            "sidebar palette"
            "footer footer";
        gap: 2rem;
        align-items: start;
    }
    header {
        grid-area: header;
        text-align: center;
        margin-bottom: 0;
    }
    h1 {
        font-size: 2.5rem;
    }
    .subtitle {
        font-size: 1rem;
    }
    .input-wrapper {
        grid-area: sidebar;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 1.5rem;
        margin-bottom: 0;
        border-radius: 16px;
        position: sticky;
        top: 2rem;
        min-width: 160px;
    }
    .input-label {
        font-size: 0.85rem;
    }
    #theme_base {
        width: 80px;
        height: 60px;
        border-radius: 10px;
    }
    #color_value {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        width: 100px;
    }
    .palette-wrapper {
        grid-area: palette;
        padding: 2rem;
        border-radius: 20px;
        box-shadow: 
            0 25px 50px rgba(0, 0, 0, 0.25),
            0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    }
    .shade-header {
        gap: 8px;
        margin-left: calc(90px + 1.25rem);
    }
    .shade-header span {
        max-width: 52px;
        font-size: 0.65rem;
    }
    #palette {
        gap: 8px;
    }
    .color-row {
        gap: 1.25rem;
    }
    .color-label {
        width: 90px;
        font-size: 0.7rem;
    }
    .shades {
        gap: 8px;
    }
    .box-color {
        max-width: 52px;
        height: 42px;
        border-radius: 8px;
    }
    .box-color::after {
        font-size: 8px;
        bottom: -18px;
    }
    #toast {
        bottom: 2rem;
        padding: 1rem 1.5rem;
        border-radius: 14px;
    }
    #toast .color-preview {
        width: 22px;
        height: 22px;
    }
    #toast .toast-text {
        font-size: 0.85rem;
    }
    .footer-hint {
        grid-area: footer;
        font-size: 0.75rem;
        margin-top: 0;
    }
}

/* ========================================
   LARGE DESKTOP (min-width: 1280px)
   ======================================== */
@media (min-width: 1280px) {
    body {
        padding: 2.5rem;
    }
    .container {
        max-width: 1300px;
        gap: 2.5rem;
    }
    h1 {
        font-size: 2.75rem;
    }
    .input-wrapper {
        padding: 2rem;
        min-width: 180px;
        border-radius: 20px;
    }
    .input-label {
        font-size: 0.9rem;
    }
    #theme_base {
        width: 100px;
        height: 75px;
        border-radius: 12px;
    }
    #color_value {
        font-size: 0.9rem;
        padding: 0.6rem 0.85rem;
        width: 110px;
    }
    .palette-wrapper {
        padding: 2.5rem;
        border-radius: 24px;
    }
    .shade-header {
        gap: 10px;
        margin-left: calc(100px + 1.5rem);
    }
    .shade-header span {
        max-width: 60px;
        font-size: 0.7rem;
    }
    #palette {
        gap: 10px;
    }
    .color-row {
        gap: 1.5rem;
    }
    .color-label {
        width: 100px;
        font-size: 0.75rem;
    }
    .shades {
        gap: 10px;
    }
    .box-color {
        max-width: 60px;
        height: 48px;
        border-radius: 10px;
    }
    .box-color::after {
        font-size: 9px;
        bottom: -20px;
    }
}

/* ========================================
   ULTRA-WIDE (min-width: 1536px)
   ======================================== */
@media (min-width: 1536px) {
    body {
        padding: 3rem;
    }
    .container {
        max-width: 1450px;
        gap: 3rem;
    }
    h1 {
        font-size: 3rem;
    }
    .input-wrapper {
        padding: 2.5rem;
        min-width: 200px;
    }
    #theme_base {
        width: 120px;
        height: 90px;
    }
    #color_value {
        font-size: 1rem;
        width: 120px;
    }
    .palette-wrapper {
        padding: 3rem;
    }
    .shade-header {
        gap: 12px;
        margin-left: calc(110px + 2rem);
    }
    .shade-header span {
        max-width: 70px;
    }
    #palette {
        gap: 12px;
    }
    .color-row {
        gap: 2rem;
    }
    .color-label {
        width: 110px;
        font-size: 0.8rem;
    }
    .shades {
        gap: 12px;
    }
    .box-color {
        max-width: 70px;
        height: 54px;
        border-radius: 12px;
    }
}

/* ========================================
   TOUCH DEVICES
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    .box-color:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    .box-color:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    .box-color::after {
        display: none;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
    .box-color {
        border: 2px solid currentColor;
    }
    .palette-wrapper {
        border: 2px solid #94a3b8;
    }
    .input-wrapper {
        border: 2px solid #94a3b8;
    }
}

/* ========================================
   DARK MODE PREFERENCE (already dark, but enhance)
   ======================================== */
@media (prefers-color-scheme: light) {
    body {
        background: linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
        color: #0f172a;
    }
    .subtitle {
        color: #64748b;
    }
    .input-wrapper {
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(148, 163, 184, 0.3);
    }
    .input-label {
        color: #475569;
    }
    #color_value {
        background: rgba(255, 255, 255, 0.8);
        color: #1e293b;
        border-color: #cbd5e1;
    }
    #color_value:focus {
        border-color: #a78bfa;
    }
    #color_value.invalid {
        border-color: #ef4444;
    }
    .palette-wrapper {
        background: rgba(255, 255, 255, 0.6);
        border-color: rgba(148, 163, 184, 0.3);
    }
    .color-label {
        color: #334155;
    }
    .shade-header span {
        color: #64748b;
    }
    #toast {
        background: #1e293b;
        color: #f8fafc;
    }
    .footer-hint {
        color: #64748b;
    }
}