:root {
    /* Light Theme (Default) */
    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --text-color: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --primary-color: #3a86ff;
    --font-main: 'Inter', sans-serif;
    --toast-bg: #111827;
    --toast-text: #ffffff;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --toast-bg: #f8fafc;
    --toast-text: #0f172a;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--surface-color);
    padding: 2rem 0;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px -10px rgba(0,0,0,0.1);
    transition: background-color 0.3s, border-color 0.3s;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    margin-bottom: -1rem; /* Adjust positioning */
    position: relative;
    z-index: 101;
}

.header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    padding-top: 1rem;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Controls (Theme & Lang) */
.theme-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.theme-btn:hover {
    background: var(--bg-color);
    transform: rotate(15deg);
}

.lang-select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
}

.lang-select:hover {
    border-color: var(--text-secondary);
}

/* Input Group */
.input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

.input-wrapper {
    display: inline-flex;
    align-items: center;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(58, 134, 255, 0.1);
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

input[type="color"] {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200%;
    height: 200%;
    padding: 0;
    border: none;
    cursor: pointer;
}

input[type="text"] {
    border: none;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-color);
    width: 120px;
    padding: 0 12px;
    outline: none;
    text-transform: uppercase;
    background: transparent;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-color);
    color: var(--surface-color);
    border: none;
    width: 56px; /* Square-ish */
    height: 56px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

/* Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 3rem 0;
}

/* Card Design */
.color-card {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.color-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.preview-box {
    flex: 1;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 160px;
    position: relative;
    cursor: pointer;
    transition: filter 0.2s;
}

.preview-box:hover {
    filter: brightness(0.95);
}

.preview-text-large {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
    letter-spacing: -0.05em;
}

.preview-text-small {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.9;
    letter-spacing: 0.05em;
}

.hex-tag {
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 200;
    font-weight: 600;
}

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

@media (max-width: 640px) {
    .header h1 { font-size: 1.5rem; }
    .input-group { width: 100%; }
    .input-wrapper { flex: 1; }
    .header-top { justify-content: center; margin-bottom: 0.5rem; }
    .lang-select { width: 100%; max-width: 200px; }
}
