:root {
    --bg-color: #f0f4f8;
    --panel-bg: rgba(255, 255, 255, 0.75);
    --panel-border: rgba(255, 255, 255, 0.4);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --sidebar-w: 260px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.bg-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15), transparent 25%);
    z-index: -1;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1200px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: rgba(255, 255, 255, 0.4);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 0 8px;
}

.logo-icon {
    font-size: 24px;
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-main);
}

.nav-item.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.nav-item .icon {
    font-size: 18px;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 0 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    position: relative;
}

.tool-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tool-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header {
    margin-bottom: 32px;
}

.panel-header h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 15px;
}

/* Tool Layouts */
.layout-split {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 32px;
    align-items: start;
}

/* Dropzone */
.area-dropzone {
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.area-dropzone:hover,
.area-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-content {
    text-align: center;
}

.drop-icon {
    font-size: 40px;
    margin-bottom: 16px;
    display: block;
}

.drop-content p {
    font-weight: 500;
    margin-bottom: 4px;
}

.drop-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.preview-img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8fafc;
    z-index: 2;
}

.hidden {
    display: none !important;
}

/* Controls */
.area-controls {
    background: #ffffff;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group>label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.flex-bw {
    display: flex;
    justify-content: space-between;
}

/* Radio Buttons for format */
.radio-group {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.radio-btn {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.radio-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Range Slider */
.slider {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.control-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* Stats */
.stats-card {
    background: #f8fafc;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.stat:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: var(--text-muted);
}

.stat-val {
    font-weight: 600;
    font-family: monospace;
    font-size: 15px;
}

.stat-val.highlight {
    color: #10b981;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:not(:disabled):hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.full-width {
    width: 100%;
}

/* ================== Tool 2: Color Extractor ================== */
.palette-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.color-swatch-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s;
}

.color-swatch-wrap:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.highlight-swatch .color-swatch {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.color-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-role {
    font-size: 12px;
    color: var(--text-muted);
}

.color-hex {
    font-family: monospace;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-main);
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
}

.grid-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.grid-swatch .color-block {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.grid-swatch:hover .color-block {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.grid-swatch .color-hex {
    font-size: 12px;
}

.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ================== Tool 3: Dark Mode Inverter ================== */
.color-picker-group {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
}

.native-color-picker {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.native-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.native-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.hex-input {
    font-family: monospace;
    font-size: 20px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-main);
    width: 120px;
    outline: none;
    text-transform: uppercase;
}

.dark-result-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 32px;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s;
}

#darkHexResult {
    font-family: monospace;
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
}

.btn.outline-light {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

.btn.outline-light:hover {
    background: rgba(255, 255, 255, 0.2);
}