:root {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --secondary: #06B6D4;
    --tertiary: #FF6B6B;
    --bg-light: #F8F9FF;
    --bg-dark: #0F172A;
    --surface-light: rgba(255, 255, 255, 0.85);
    --surface-dark: rgba(15, 23, 42, 0.85);
    --text-light: #1E293B;
    --text-dark: #F1F5F9;
    --error: #EF4444;
    --shadow: rgba(99, 102, 241, 0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.55) 0%, 
        rgba(6, 182, 212, 0.35) 50%,
        rgba(255, 255, 255, 0.9) 100%);
    color: var(--text-light);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark {
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.95) 0%, 
        rgba(30, 41, 59, 0.9) 50%,
        rgba(15, 23, 42, 1) 100%);
    color: var(--text-dark);
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 16px 24px;
    box-shadow: 0 4px 12px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(255, 255, 255, 0.2);
}

.app-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-title {
    flex: 1;
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-content {
    padding: 24px;
    padding-bottom: 100px;
}

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 28px;
}

.color-display-container {
    position: relative;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.color-ring {
    position: absolute;
    width: 140px;
    height: 140px;
    animation: rotate 1.8s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ring-svg {
    width: 100%;
    height: 100%;
}

.ring-circle {
    transform-origin: center;
}

.color-circle {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.color-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.color-circle:active {
    transform: scale(0.98);
}

.color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.95), rgba(99, 102, 241, 0.65));
    transition: background 0.35s ease;
}

.hex-display {
    margin-bottom: 4px;
}

.hex-value {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-light);
    transition: color 0.3s ease;
}

body.dark .hex-value {
    color: var(--text-dark);
}

.tap-hint {
    font-size: 0.875rem;
    color: var(--text-light);
    opacity: 0.7;
    transition: color 0.3s ease;
}

body.dark .tap-hint {
    color: var(--text-dark);
}

/* Input Section */
.input-section {
    margin-bottom: 28px;
}

.section-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-light);
    transition: color 0.3s ease;
}

body.dark .section-title {
    color: var(--text-dark);
}

.input-card {
    background: linear-gradient(135deg, var(--surface-light), rgba(255, 255, 255, 0.65));
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 8px 20px var(--shadow);
    transition: all 0.3s ease;
}

body.dark .input-card {
    background: linear-gradient(135deg, var(--surface-dark), rgba(15, 23, 42, 0.65));
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.color-prefix-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.6px solid rgba(0, 0, 0, 0.15);
    background: radial-gradient(circle, var(--primary), rgba(99, 102, 241, 0.65));
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark .color-prefix-swatch {
    border-color: rgba(255, 255, 255, 0.15);
}

.hex-input {
    flex: 1;
    border: 1.6px solid rgba(99, 102, 241, 0.5);
    border-radius: 18px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1.3px;
    font-family: 'Inter', monospace;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-light);
    transition: all 0.3s ease;
}

body.dark .hex-input {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-dark);
    border-color: rgba(139, 140, 255, 0.5);
}

.hex-input:focus {
    outline: none;
    border-color: var(--primary);
    border-width: 2.2px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

body.dark .hex-input:focus {
    background: rgba(15, 23, 42, 0.8);
}

.hex-input::placeholder {
    color: var(--text-light);
    opacity: 0.5;
}

body.dark .hex-input::placeholder {
    color: var(--text-dark);
}

.input-actions {
    display: flex;
    gap: 4px;
}

.input-icon-btn {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-light);
    border-radius: 12px;
    transition: all 0.3s ease;
}

body.dark .input-icon-btn {
    color: var(--text-dark);
}

.input-icon-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.input-icon-btn svg {
    width: 20px;
    height: 20px;
}

.error-message {
    margin-top: 16px;
    color: var(--error);
    font-size: 0.875rem;
    min-height: 20px;
    animation: shake 0.45s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* Button Section */
.button-section {
    margin-bottom: 28px;
    display: flex;
    justify-content: center;
}

.analyze-button {
    width: 80%;
    max-width: 400px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 26px;
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.analyze-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.4);
}

.analyze-button:active:not(:disabled) {
    transform: translateY(0);
}

.analyze-button:disabled {
    background: rgba(99, 102, 241, 0.45);
    cursor: not-allowed;
    box-shadow: none;
}

.button-icon {
    width: 20px;
    height: 20px;
}

/* Ad Section */
.ad-section {
    margin: 24px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(5px);
}

body.dark .ad-section {
    background: rgba(15, 23, 42, 0.3);
}

.ad-section ins.adsbygoogle {
    display: block !important;
    width: 100%;
    max-width: 728px;
    margin: 0 auto;
}

/* Results ad is hidden by default, shown via JavaScript */

/* Results Section */
.results-section {
    margin-top: 28px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.target-banner {
    background: linear-gradient(135deg, var(--surface-light), rgba(255, 255, 255, 0.65));
    backdrop-filter: blur(10px);
    border-radius: 28px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 8px 20px var(--shadow);
}

body.dark .target-banner {
    background: linear-gradient(135deg, var(--surface-dark), rgba(15, 23, 42, 0.65));
}

.banner-color {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.banner-info {
    flex: 1;
}

.banner-hex {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.banner-rgb {
    font-size: 0.875rem;
    opacity: 0.8;
}

.method-card {
    background: linear-gradient(135deg, var(--surface-light), rgba(255, 255, 255, 0.65));
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 20px var(--shadow);
}

body.dark .method-card {
    background: linear-gradient(135deg, var(--surface-dark), rgba(15, 23, 42, 0.65));
}

.method-label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.method-toggle {
    display: flex;
    gap: 8px;
}

.method-btn {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    background: transparent;
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

body.dark .method-btn {
    color: var(--text-dark);
    border-color: rgba(139, 140, 255, 0.3);
}

.method-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.method-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.components-section {
    background: linear-gradient(135deg, var(--surface-light), rgba(255, 255, 255, 0.65));
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 20px var(--shadow);
}

body.dark .components-section {
    background: linear-gradient(135deg, var(--surface-dark), rgba(15, 23, 42, 0.65));
}

.components-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.components-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    transition: all 0.3s ease;
}

body.dark .component-item {
    background: rgba(15, 23, 42, 0.5);
}

.component-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.component-color {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.component-info {
    flex: 1;
}

.component-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.component-percentage {
    font-size: 0.875rem;
    opacity: 0.8;
}

.diagram-section {
    background: linear-gradient(135deg, var(--surface-light), rgba(255, 255, 255, 0.65));
    backdrop-filter: blur(10px);
    border-radius: 28px;
    padding: 24px;
    box-shadow: 0 8px 20px var(--shadow);
}

body.dark .diagram-section {
    background: linear-gradient(135deg, var(--surface-dark), rgba(15, 23, 42, 0.65));
}

.diagram-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.mixing-diagram {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diagram-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.diagram-color {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.diagram-plus {
    font-size: 1.5rem;
    font-weight: 300;
    opacity: 0.6;
}

.diagram-equals {
    font-size: 1.5rem;
    font-weight: 300;
    opacity: 0.6;
}

.diagram-result {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--surface-light);
    border-radius: 24px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

body.dark .modal-content {
    background: var(--surface-dark);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
}

body.dark .modal-close {
    color: var(--text-dark);
}

.modal-close:hover {
    background: rgba(99, 102, 241, 0.1);
}

.color-picker-container {
    display: flex;
    justify-content: center;
}

#nativeColorPicker {
    width: 100%;
    height: 60px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader {
    display: flex;
    gap: 8px;
    align-items: center;
}

.loader-bar {
    width: 10px;
    height: 40px;
    background: var(--primary);
    border-radius: 8px;
    animation: loader 0.9s ease-in-out infinite;
}

.loader-bar:nth-child(2) {
    animation-delay: 0.15s;
}

.loader-bar:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes loader {
    0%, 100% {
        height: 12px;
        transform: scaleY(1);
    }
    50% {
        height: 40px;
        transform: scaleY(1.5);
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 500;
}

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

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }

    .hero-section {
        padding: 12px 12px 32px;
    }

    .color-display-container {
        height: 140px;
    }

    .color-circle {
        width: 110px;
        height: 110px;
    }

    .hex-value {
        font-size: 1.5rem;
    }

    .analyze-button {
        width: 90%;
    }

    .input-card {
        padding: 16px;
    }

    .input-wrapper {
        gap: 12px;
    }

    .input-prefix {
        padding: 0 8px;
    }

    .input-icon-btn {
        width: 44px;
        height: 44px;
    }

    .target-banner {
        flex-direction: column;
        text-align: center;
        padding: 18px;
    }

    .target-banner,
    .method-card,
    .components-section,
    .diagram-section {
        padding: 18px;
    }

    .banner-color {
        width: 100px;
        height: 100px;
    }

    .results-container {
        gap: 18px;
    }
}

@media (max-width: 580px) {
    .main-content {
        padding: 16px;
    }

    .input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .input-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .input-icon-btn {
        width: 42px;
        height: 42px;
    }

    .hero-section {
        padding-top: 0;
    }

    .color-display-container {
        height: 120px;
    }

    .color-circle {
        width: 96px;
        height: 96px;
    }

    .ad-section {
        min-height: 80px;
    }
}

@media (max-width: 420px) {
    .main-content {
        padding: 14px 12px;
    }

    .input-card,
    .target-banner,
    .method-card,
    .components-section,
    .diagram-section {
        padding: 14px;
    }

    .hex-input {
        padding: 12px;
        font-size: 0.95rem;
    }

    .color-display-container {
        height: 110px;
    }

    .color-circle {
        width: 90px;
        height: 90px;
    }

    .hex-value {
        font-size: 1.35rem;
    }

    .button-section {
        margin-bottom: 22px;
    }
}

/* Disable ring animation when needed */
.color-ring.no-animation {
    animation: none;
}

