:root {
  --bg-light: #f4f5f7; --bg-dark: #121212; --text-light: #111; --text-dark: #f1f1f1;
  --text-muted-light: #555; --text-muted-dark: #aaa; --accent: #007aff;
  --glass-bg-light: rgba(255, 255, 255, 0.65); --glass-bg-dark: rgba(28, 28, 30, 0.75);
  --border-light: rgba(0, 0, 0, 0.1); --border-dark: rgba(255, 255, 255, 0.15);
  --dropdown-bg-light: #ffffff; --dropdown-bg-dark: #2c2c2e;
  --dropdown-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  --card-bg-light: #ffffff; --card-bg-dark: #1e1e1e;
}
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; padding-top: 65px; background-color: var(--bg-light); color: var(--text-light); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; transition: background-color 0.3s ease, color 0.3s ease; }
body.dark { background-color: var(--bg-dark); color: var(--text-dark); }
main { flex-grow: 1; padding: 20px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
header { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: flex; align-items: center; padding: 0 24px; height: 65px; background-color: var(--glass-bg-light); border-bottom: 1px solid var(--border-light); backdrop-filter: blur(14px) saturate(180%); -webkit-backdrop-filter: blur(14px) saturate(180%); transition: background-color 0.3s ease, border-bottom 0.3s ease; }
body.dark header { background-color: var(--glass-bg-dark); border-bottom: 1px solid var(--border-dark); }
.logo-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo-img { height: 32px; }
header h1 { margin: 0; font-weight: 700; font-size: 1.6rem; color: var(--text-light); white-space: nowrap; transition: color 0.3s ease; }
body.dark header h1 { color: var(--text-dark); }
#mainNav, #productsNav { display: flex; align-items: center; gap: 16px; height: 100%; list-style: none; margin: 0; padding: 0; margin-left: 24px; }
.nav-group {
    position: relative;
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: -10px;
}
.group-btn { display: flex; align-items: center; gap: 5px; padding: 0 16px; height: 100%; border: none; background: transparent; color: var(--text-light); font-size: 1rem; font-weight: 500; cursor: pointer; transition: color 0.2s; white-space: nowrap; }
body.dark .group-btn { color: var(--text-dark); }
.group-btn::after { content: '▾'; font-size: 0.8em; opacity: 0.6; transition: transform 0.2s ease; }
.group-btn.active, .nav-group:hover .group-btn { color: var(--accent); }
.nav-group:hover .group-btn::after { transform: rotate(180deg); }
.category-list {
    position: absolute;
    top: 100%;
    margin-top: 10px;
    left: 0;
    padding: 8px;
    min-width: 160px;
    background: var(--dropdown-bg-light);
    border-radius: 12px;
    box-shadow: var(--dropdown-shadow);
    list-style: none;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
    transform: translateY(-10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
body.dark .category-list { background: var(--dropdown-bg-dark); }
.nav-group:hover .category-list {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.category-list li { width: 100%; }
.category-btn { display: block; box-sizing: border-box; width: 100%; padding: 10px 16px; text-align: left; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 0.95rem; transition: color 0.2s, background-color 0.2s; text-decoration: none; color: var(--text-light); }
body.dark .category-btn { color: var(--text-dark); }
.category-btn.active, .category-btn:hover { background-color: var(--accent); color: white !important; }
.header-actions { margin-left: auto; }
#themeToggle { display: flex; justify-content: center; align-items: center; width: 40px; height: 40px; background: transparent; border: 1px solid var(--border-light); padding: 0; border-radius: 12px; cursor: pointer; color: var(--text-muted-light); transition: all 0.2s ease; }
body.dark #themeToggle { border-color: var(--border-dark); color: var(--text-muted-dark); }
#themeToggle:hover { border-color: var(--accent); color: var(--accent); background-color: rgba(0, 122, 255, 0.08); }
#themeToggle svg { width: 20px; height: 20px; transition: transform 0.3s ease-out; }
#themeToggle:hover svg { transform: scale(1.1) rotate(15deg); }
.moon-icon { display: none; }
body.dark .sun-icon { display: none; }
body.dark .moon-icon { display: block; }
footer { width: 100%; margin-top: 40px; padding: 30px 24px; box-sizing: border-box; background: var(--bg-light); border-top: 1px solid var(--border-light); color: var(--text-muted-light); transition: background 0.3s, border-top 0.3s; }
body.dark footer { background: var(--bg-dark); border-top: 1px solid var(--border-dark); color: var(--text-muted-dark); }
.footer-content { max-width: 1000px; margin: 0 auto; text-align: center; font-size: 0.9rem; }
.footer-content p { margin: 8px 0; line-height: 1.6; }
.footer-content a { color: var(--text-muted-light); text-decoration: none; transition: color 0.2s; }
body.dark .footer-content a { color: var(--text-muted-dark); }
.footer-content a:hover { color: var(--accent); }
.donation-section { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 20px; }
.donation-title { font-weight: 500; }
.donation-item { position: relative; display: flex; align-items: center; }
.donation-icon { height: 24px; width: auto; cursor: pointer; transition: transform 0.2s ease; }
.donation-item a:hover .donation-icon, .wechat-donate:hover .donation-icon { transform: scale(1.1); }
.wechat-donate:hover .wechat-qr-popup { opacity: 1; visibility: visible; transform: translateY(-100%) translateY(-8px) translateX(-50%); }
.wechat-qr-popup { position: absolute; bottom: 100%; left: 50%; padding: 15px; background: var(--dropdown-bg-light); border-radius: 12px; box-shadow: var(--dropdown-shadow); opacity: 0; visibility: hidden; transition: all 0.25s ease-out; transform: translateY(-100%) translateY(0) translateX(-50%); pointer-events: none; }
body.dark .wechat-qr-popup { background: var(--dropdown-bg-dark); }
.wechat-qr-popup img { width: 240px; height: 240px; display: block; }
.hidden { display: none !important; }
#picker-container { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; width: 100%; max-width: 1200px; min-height: 60vh; }
#image-uploader { background-color: var(--card-bg-light); border: 2px dashed var(--border-light); border-radius: 20px; padding: 10px; display: flex; justify-content: center; align-items: center; transition: all 0.3s ease; position: relative; }
body.dark #image-uploader { background-color: var(--card-bg-dark); border-color: var(--border-dark); }
#image-uploader.dragging { border-color: var(--accent); background-color: var(--bg-light); }
body.dark #image-uploader.dragging { background-color: var(--bg-dark); }
.upload-area { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; position: relative; cursor: pointer; }
#image-canvas { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 15px; cursor: crosshair; }
#loupe { position: absolute; width: 100px; height: 100px; border-radius: 50%; border: 4px solid white; box-shadow: 0 0 15px rgba(0,0,0,0.3); pointer-events: none; transform: translate(-50%, -50%); overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; background-color: #000; z-index: 10; }
#loupe-color { width: 100%; height: 70%; }
#loupe-text { width: 100%; height: 30%; background: rgba(0,0,0,0.7); color: white; font-family: monospace; font-size: 14px; display: flex; align-items: center; justify-content: center; }
#copy-notification { position: absolute; transform: translate(-50%, -150%); background-color: var(--accent); color: white; padding: 8px 16px; border-radius: 8px; font-size: 0.9rem; font-weight: 500; z-index: 20; pointer-events: none; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; white-space: nowrap; }
#copy-notification.show { opacity: 1; transform: translate(-50%, -170%); }
.upload-prompt { text-align: center; color: var(--text-muted-light); }
body.dark .upload-prompt { color: var(--text-muted-dark); }
.upload-icon { width: 60px; height: 60px; fill: var(--text-muted-light); opacity: 0.5; margin-bottom: 20px; }
body.dark .upload-icon { fill: var(--text-muted-dark); }
.prompt-text { font-size: 1.2rem; font-weight: 600; margin: 0 0 8px 0; color: var(--text-light); }
body.dark .prompt-text { color: var(--text-dark); }
.prompt-subtext { font-size: 0.9rem; margin: 0 0 20px 0; }
.upload-button { background: var(--accent); border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; color: white; font-weight: 600; transition: opacity 0.2s; }
.upload-button:hover { opacity: 0.85; }
#palette-display { display: flex; flex-direction: column; justify-content: center; }
.palette-placeholder { text-align: center; color: var(--text-muted-light); }
body.dark .palette-placeholder { color: var(--text-muted-dark); }
.palette-placeholder h2 { font-weight: 600; color: var(--text-light); }
body.dark .palette-placeholder h2 { color: var(--text-dark); }
.palette-results h3 { font-size: 1.2rem; margin-bottom: 15px; color: var(--text-light); border-bottom: 1px solid var(--border-light); padding-bottom: 10px; margin-top: 0; }
body.dark .palette-results h3 { color: var(--text-dark); border-color: var(--border-dark); }
.dominant-color-section { margin-bottom: 30px; }
.palette-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border-light); }
body.dark .palette-header { border-color: var(--border-dark); }
.palette-header h3 { border-bottom: none; padding-bottom: 10px; margin-bottom: 0; }
.palette-controls { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--text-muted-light); }
body.dark .palette-controls { color: var(--text-muted-dark); }
#palette-size { accent-color: var(--accent); width: 80px; }
.color-card { border-radius: 12px; padding: 20px; cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.08); color: white; text-align: center; font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace; font-weight: 600; font-size: 1.1rem; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; }
.color-card:hover { transform: scale(1.03); box-shadow: 0 8px 20px rgba(0,0,0,0.15); }
.color-card.light-text { color: #111; }
.dominant-card { height: 120px; }
.color-info-text { font-size: 0.9em; opacity: 0.8; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; }
.color-grid .color-card { height: 100px; font-size: 1rem; }
@media (max-width: 900px) {
  #picker-container { grid-template-columns: 1fr; }
  #image-uploader { min-height: 40vh; }
  #palette-display { margin-top: 30px; }
}
@media (max-width: 768px) {
    header { padding: 0 16px; }
    #productsNav { margin-left: auto; }
    .logo-link h1 { display: none; }
    .header-actions { margin-left: 16px; }
    #mainNav { display: none; }
}
#floating-sidebar { position: fixed; top: 50%; right: 20px; transform: translateY(-50%); z-index: 1010; background: var(--glass-bg-light); backdrop-filter: blur(10px) saturate(150%); -webkit-backdrop-filter: blur(10px) saturate(150%); border-radius: 16px; padding: 36px 8px 8px 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid var(--border-light); transition: all 0.3s ease-in-out; }
#floating-sidebar.is-hidden { opacity: 0; visibility: hidden; transform: translateY(-50%) translateX(120%); pointer-events: none; }
body.dark #floating-sidebar { background: var(--glass-bg-dark); border-color: var(--border-dark); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.sidebar-close-btn { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: none; background: transparent; color: var(--text-muted-light); font-size: 1.5rem; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%; transition: background-color 0.2s, color 0.2s, transform 0.2s; z-index: 2; }
body.dark .sidebar-close-btn { color: var(--text-muted-dark); }
.sidebar-close-btn:hover { background-color: var(--border-light); color: var(--text-light); transform: rotate(90deg); }
body.dark .sidebar-close-btn:hover { background-color: var(--border-dark); color: var(--text-dark); }
.sidebar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 15px; }
.sidebar-item { position: relative; display: flex; justify-content: center; align-items: center; }
.sidebar-link { display: block; padding: 4px; border-radius: 50%; transition: transform 0.2s ease, background-color 0.2s; }
.sidebar-link:hover { transform: scale(1.1); background-color: rgba(0, 122, 255, 0.1); }
.sidebar-icon { width: 32px; height: 32px; display: block; }
.qr-popup, .tooltip { position: absolute; right: 100%; top: 50%; transform: translateY(-50%) translateX(0px); margin-right: 15px; padding: 15px; background: var(--dropdown-bg-light); border-radius: 12px; box-shadow: var(--dropdown-shadow); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s; white-space: nowrap; text-align: center; }
.tooltip { padding: 8px 16px; }
body.dark .qr-popup, body.dark .tooltip { background: var(--dropdown-bg-dark); }
.sidebar-item:hover .qr-popup, .sidebar-item:hover .tooltip { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(-50%) translateX(-10px); }
.qr-popup img { width: 140px; height: 140px; display: block; margin-bottom: 8px; }
.qr-popup span, .tooltip span { font-size: 0.9rem; color: var(--text-muted-light); }
body.dark .qr-popup span, body.dark .tooltip span { color: var(--text-muted-dark); }