/* =============================================
   DISPLAY-NAME CSS VARIABLES
   ============================================= */
:root {
    /* ---- gear_type ---- */
    --dn-gear_type-NotGear:          "-";
    --dn-gear_type-Weapon:           "Weapon";
    --dn-gear_type-Offhand:          "Offhand";
    --dn-gear_type-Head:             "Helmet";
    --dn-gear_type-Chest:            "Chestpiece";
    --dn-gear_type-Legs:             "Legpiece";
    --dn-gear_type-Cloak:            "Cloak";
    --dn-gear_type-Gloves:           "Gloves";
    --dn-gear_type-Boots:            "Boots";
    --dn-gear_type-Amulet:           "Amulet";
    --dn-gear_type-EnchantedBook:    "Enchanted book";
    --dn-gear_type-Accessory:        "Accessory";
    --dn-gear_type-FishingRod:       "Fishing rod";

    /* ---- rarity ---- */
    --dn-rarity-None:                "Generated";
    --dn-rarity-Common:              "Common";
    --dn-rarity-Uncommon:            "Uncommon";
    --dn-rarity-Rare:                "Rare";
    --dn-rarity-Epic:                "Epic";
    --dn-rarity-Legendary:           "Legendary";
    --dn-rarity-Celestial:           "Celestial";

    /* ---- item_purpose ---- */
    --dn-item_purpose-gear:          "Gear";
    --dn-item_purpose-consumable:    "Consumable";
    --dn-item_purpose-material:      "Material";
    --dn-item_purpose-furniture:     "Furniture";
    --dn-item_purpose-gold:          "Gold";

    /* ---- consumable_type ---- */
    --dn-consumable_type-NotConsumable:      "-";
    --dn-consumable_type-InstantPotion:      "Instant potion";
    --dn-consumable_type-UtilityPotion:      "Utility potion";
    --dn-consumable_type-CombatPotion:       "Combat potion";
    --dn-consumable_type-Food:               "Food";
    --dn-consumable_type-Essence:            "Elemental essence";
    --dn-consumable_type-Recipe:             "Recipe";
    --dn-consumable_type-Key:                "Key item";
    --dn-consumable_type-FishingItem:        "Fishing item";
    --dn-consumable_type-EnemySoul:          "Enemy soul";
    --dn-consumable_type-InventoryExpander:  "Inventory expander";

    /* ---- material_type ---- */
    --dn-material_type-NotMaterial:          "-";
    --dn-material_type-Mineable:        "Mineral";
    --dn-material_type-Gatherable:     "Gatherable";
    --dn-material_type-Crystals:              "Crystal";
    --dn-material_type-EnemyLoot:            "Enemy loot";
    --dn-material_type-RiftShard:                 "Rift shard";
    --dn-material_type-Fish:                 "Fish";

    /* ---- type (unified) ---- */
    --dn-type-Weapon:           "Weapon";
    --dn-type-Offhand:          "Offhand";
    --dn-type-Head:             "Helmet";
    --dn-type-Chest:            "Chestpiece";
    --dn-type-Legs:             "Legpiece";
    --dn-type-Cloak:            "Cloak";
    --dn-type-Gloves:           "Gloves";
    --dn-type-Boots:            "Boots";
    --dn-type-Amulet:           "Amulet";
    --dn-type-EnchantedBook:    "Enchanted book";
    --dn-type-Accessory:        "Accessory";
    --dn-type-FishingRod:       "Fishing rod";
    --dn-type-InstantPotion:    "Instant potion";
    --dn-type-UtilityPotion:    "Utility potion";
    --dn-type-CombatPotion:     "Combat potion";
    --dn-type-Food:             "Food";
    --dn-type-Essence:          "Elemental essence";
    --dn-type-Recipe:           "Recipe";
    --dn-type-Key:              "Key item";
    --dn-type-FishingItem:      "Fishing item";
    --dn-type-EnemySoul:        "Enemy soul";
    --dn-type-InventoryExpander:"Inventory expander";
    --dn-type-MinableCommon:    "Ore (common)";
    --dn-type-MinableUncommon:  "Ore (uncommon)";
    --dn-type-GatherableCommon: "Herb (common)";
    --dn-type-GatherableUncommon:"Herb (uncommon)";
    --dn-type-Crystal:          "Crystal";
    --dn-type-EnemyLoot:        "Enemy loot";
    --dn-type-Fish:             "Fish";

    /* ---- column headers ---- */
    --dn-col-icon:             "";
    --dn-col-name:             "Name";
    --dn-col-item_level:       "Item level";
    --dn-col-gear_type:        "Gear type";
    --dn-col-rarity:           "Rarity";
    --dn-col-attack:           "Attack";
    --dn-col-armor:            "Armor";
    --dn-col-power:            "Power";
    --dn-col-vitality:         "Vitality";
    --dn-col-hitpoints:        "Hitpoints";
    --dn-col-crit_chance:      "Crit chance";
    --dn-col-crit_dmg:         "Crit damage";
    --dn-col-item_purpose:     "Category";
    --dn-col-value:            "Value";
    --dn-col-haste:            "Haste";
    --dn-col-evasion:          "Evasion";
    --dn-col-luck:             "Luck";
    --dn-col-mana_regen:       "Mana regen";
    --dn-col-cd_rate:          "Cooldown rate";
    --dn-col-torment:          "Torment";
    --dn-col-havoc:            "Havoc";
    --dn-col-precision:        "Precision";
    --dn-col-source_group:     "Source";
    --dn-col-type:             "Type";
    --dn-col-tier:             "Tier";
    --dn-col-min_tier:         "Min source tier";
    --dn-col-max_tier:         "Max source tier";
    --dn-col-max_rift_tier:    "Max source tier (rift only)";
    --dn-col-vendor_amount_base:"Base merchant stock";
    --dn-col-value_multiplier: "Value multiplier";
    --dn-col-off_hand_gen_mode:"Offhand main stats";
    --dn-col-power_vit_spread: "Power/Vitality spread";
    --dn-col-ele_stats_set:    "Set elemental stats";
    --dn-col-enchants:         "Enchants";
    --dn-col-highest_possible_rarity: "Highest default rarity";
    --dn-col-lowest_possible_rarity:  "Lowest default rarity";
    --dn-col-uncommon_chance:  "Default uncommon chance";
    --dn-col-rare_chance:      "Default rare chance";
    --dn-col-epic_chance:      "Default epic chance";
    --dn-col-legendary_chance: "Default egendary chance";
    --dn-col-celestial_chance: "Default celestial chance";
    --dn-col-icon_path:        "Icon name";

    /* ---- off_hand_gen_mode ---- */
    --dn-off_hand_gen_mode-0:  "Random";
    --dn-off_hand_gen_mode-1:  "Always attack";
    --dn-off_hand_gen_mode-2:  "Always armor";

    /* =============================================
       THEME PALETTE
       ============================================= */
    --bg-page:       #edddc0;
    --bg-content:    #fff2e3;
    --bg-panel:      #fff8ee;
    --bg-title:      linear-gradient(to bottom, #f0ddc0 0%, #e0caa2 100%);
    --bg-title-hover:linear-gradient(to bottom, #ead3b4 0%, #d8bf94 100%);
    --bg-highlight:  #f0ddbd;
    --bg-input:      #fffbf5;

    --border-light:  #e8d9c0;
    --border-mid:    #c9b896;
    --border-dark:   #8a7a68;
    --border-accent: #a88055;
    --border-outer:  #a69785;

    --text-primary:  #4a3520;
    --text-secondary:#5a3d1a;
    --text-muted:    #7a6a55;
    --text-link:     #ab6432;
    --text-link-hover:#573218;

    --shadow-box: 1px 2px 3px rgba(90,61,26,0.2), inset 0 0 0 1px rgba(255,255,255,0.3);
    --shadow-title: inset 0 2px 0 rgba(255,255,255,.7), inset 2px 0 0 rgba(255,255,255,.45),
                    inset 0 0 0 2px rgba(255,255,255,.18), inset 0 -1px 2px rgba(138,122,104,.3);

    --rarity-Common:    #666;
    --rarity-Uncommon:  #2d8a2d;
    --rarity-Rare:      #3a6ec0;
    --rarity-Epic:      #8a4cc0;
    --rarity-Legendary: #c88a15;
    --rarity-Celestial: #cc3333;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* =============================================
   CORNER BUTTONS (wiki + dark mode)
   ============================================= */
#corner-buttons {
    position: fixed;
    top: 10px;
    right: 14px;
    z-index: 500;
    display: flex;
    gap: 6px;
    align-items: center;
}

#darkmode-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 5px 8px;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
#darkmode-toggle:hover {
    background: var(--bg-highlight);
    border-color: var(--border-accent);
}
/* Show sun in dark mode, moon in light mode */
#darkmode-toggle .icon-sun  { display: none; }
#darkmode-toggle .icon-moon { display: block; }
body.dark-mode #darkmode-toggle .icon-sun  { display: block; }
body.dark-mode #darkmode-toggle .icon-moon { display: none; }

#wiki-link-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.15s;
}
#wiki-link-btn:hover {
    background: var(--bg-highlight);
    border-color: var(--border-accent);
    color: var(--text-link);
}

/* =============================================
   LANDING PAGE
   ============================================= */
#landing {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.landing-inner {
    text-align: center;
    width: 100%;
    max-width: 720px;
}
.landing-title {
    font-size: 2.8em;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.landing-subtitle {
    color: var(--text-muted);
    font-size: 1.05em;
    margin-bottom: 28px;
}

/* =============================================
   SEARCH BAR (shared)
   ============================================= */
.search-bar-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border-outer);
    border-radius: 6px;
    padding: 0;
    overflow: hidden;
    box-shadow: var(--shadow-box);
    transition: border-color 0.2s;
}
.search-bar-wrap:focus-within {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-box), 0 0 0 3px rgba(168,128,85,0.15);
}
.search-icon {
    flex-shrink: 0;
    margin-left: 12px;
    color: var(--text-muted);
}
.search-bar-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 1em;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}
.search-bar-wrap input::placeholder { color: var(--text-muted); opacity: 0.6; }

.search-btn {
    flex-shrink: 0;
    background: var(--bg-title);
    border: none;
    border-left: 1px solid var(--border-mid);
    padding: 10px 22px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95em;
    transition: background 0.15s;
}
.search-btn:hover { background: var(--bg-title-hover); }

.landing-search {
    max-width: 600px;
    margin: 0 auto 20px auto;
}
.landing-search input { padding: 14px 14px; font-size: 1.1em; }
.landing-search .search-btn { padding: 14px 28px; font-size: 1.05em; }

/* =============================================
   FILTER BAR
   ============================================= */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0 10px;
    max-width: 800px;
    margin: 0 auto;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.filter-group label {
    font-size: 0.78em;
    font-weight: 600;
    color: var(--text-secondary);
    padding-left: 2px;
}
.filter-group select,
.filter-group input[type="number"] {
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.88em;
    color: var(--text-primary);
    min-width: 110px;
    outline: none;
    transition: border-color 0.2s;
}
.filter-group select:focus,
.filter-group input[type="number"]:focus {
    border-color: var(--border-accent);
}
.filter-range {
    display: flex;
    align-items: center;
    gap: 3px;
}
.filter-range input { width: 65px; min-width: 0; }
.filter-range .range-sep { color: var(--text-muted); font-size: 0.85em; }

.filter-group .filter-clear-btn {
    background: none;
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 0.88em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    align-self: flex-end;
}
.filter-group .filter-clear-btn:hover {
    background: var(--bg-highlight);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.filter-group select optgroup {
    font-weight: 700;
    font-style: normal;
    color: var(--text-secondary);
    background: var(--bg-panel);
}
.filter-group select option {
    font-weight: 400;
    color: var(--text-primary);
    padding-left: 6px;
}

/* â”€â”€ Color picker filter â”€â”€ */
.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}
.color-picker-wrap input[type="color"] {
    width: 32px;
    height: 28px;
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 1px;
    cursor: pointer;
    background: var(--bg-input);
}
.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-picker-wrap input[type="color"]::-webkit-color-swatch { border-radius: 2px; border: none; }
.color-picker-wrap .color-clear-x {
    background: none;
    border: 1px solid var(--border-mid);
    border-radius: 3px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.color-picker-wrap .color-clear-x:hover {
    background: var(--bg-highlight);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

/* =============================================
   TOP BAR
   ============================================= */
#top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: var(--bg-content);
    border-bottom: 2px solid var(--border-dark);
    box-shadow: 0 2px 6px rgba(90,61,26,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-title {
    font-size: 1.25em;
    color: var(--text-primary);
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}
.top-title:hover { color: var(--text-link); }
.top-search { flex: 1; max-width: 520px; }
.top-search input { padding: 7px 10px; }
.top-search .search-btn { padding: 7px 18px; }

#results-view > .filters-bar {
    background: var(--bg-content);
    border-bottom: 1px solid var(--border-mid);
    padding: 10px 16px;
    max-width: none;
    justify-content: flex-start;
    position: sticky;
    top: 48px;
    z-index: 99;
    box-shadow: 0 2px 4px rgba(90,61,26,0.08);
}/* =============================================
   MAIN LAYOUT
   ============================================= */
#main-content {
    display: flex;
    min-height: calc(100vh - 110px);
}
#table-panel {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    transition: flex 0.25s ease;
    display: flex;
    flex-direction: column;
}
#results-info {
    padding: 4px 0 8px 0;
    font-size: 0.88em;
    color: var(--text-muted);
}

.table-scroll { flex: 1; overflow-x: auto; }

/* =============================================
   ITEMS TABLE
   ============================================= */
#items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-content);
    border: 2px solid var(--border-light);
    border-bottom-color: var(--border-dark);
    border-right-color: var(--border-dark);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--shadow-box);
}

#items-table thead th {
    background: var(--bg-title);
    border: 1px solid var(--border-accent);
    border-top-color: #ceb08b;
    border-left-color: #ceb08b;
    border-bottom: 2px solid var(--border-dark);
    padding: 6px 10px;
    font-size: 0.88em;
    font-weight: 700;
    color: var(--text-primary);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-title);
    transition: background 0.15s;
}
#items-table thead th:hover { background: var(--bg-title-hover); }
#items-table thead th .sort-arrow {
    display: inline-block;
    margin-left: 3px;
    font-size: 0.75em;
    opacity: 0.4;
}
#items-table thead th.sorted .sort-arrow { opacity: 1; }

#items-table thead th.col-icon {
    width: 42px; min-width: 42px; max-width: 42px;
    padding: 4px 5px; cursor: default; text-align: center;
}

#items-table tbody td {
    padding: 4px 10px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9em;
    vertical-align: middle;
    white-space: nowrap;
}
#items-table tbody td.col-icon {
    width: 42px; min-width: 42px; max-width: 42px;
    padding: 4px 5px; text-align: center;
}
#items-table tbody tr { cursor: pointer; transition: background 0.1s; }
#items-table tbody tr:nth-child(odd) { background: var(--bg-panel); }
#items-table tbody tr:hover {
    background: var(--bg-highlight);
    box-shadow: 0 0 0 2px var(--border-dark) inset;
}
#items-table tbody tr.active-row {
    background: var(--bg-highlight);
    box-shadow: 0 0 0 2px var(--border-accent) inset;
}

.item-icon-tiny {
    width: 32px; height: 32px;
    image-rendering: pixelated;
    border-radius: 2px;
    flex-shrink: 0;
    background: var(--bg-page);
    border: 1px solid var(--border-light);
    display: block;
    margin: 0 auto;
}

/* Rarity coloring */
.rarity-Common    { color: var(--rarity-Common); }
.rarity-Uncommon  { color: var(--rarity-Uncommon); font-weight: 600; }
.rarity-Rare      { color: var(--rarity-Rare); font-weight: 600; }
.rarity-Epic      { color: var(--rarity-Epic); font-weight: 600; }
.rarity-Legendary { color: var(--rarity-Legendary); font-weight: 700; }
.rarity-Celestial { color: var(--rarity-Celestial); font-weight: 700; }

/* =============================================
   PAGINATION
   ============================================= */
#pagination {
    display: flex; justify-content: center; align-items: center;
    gap: 4px; padding: 12px 0;
}
.page-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 0.88em;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s;
}
.page-btn:hover { background: var(--bg-highlight); border-color: var(--border-accent); }
.page-btn.active {
    background: var(--bg-title);
    border-color: var(--border-accent);
    font-weight: 700;
    box-shadow: var(--shadow-title);
}
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* =============================================
   DETAIL SIDE-PANEL
   ============================================= */
#detail-panel {
    width: 380px; min-width: 320px; max-width: 420px;
    flex-shrink: 0;
    background: var(--bg-content);
    border-left: 2px solid var(--border-dark);
    box-shadow: -3px 0 10px rgba(90,61,26,0.12);
    overflow-y: auto;
    position: sticky;
    top: 52px;
    height: calc(100vh - 52px);
    padding: 0;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
    from { transform: translateX(30px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

#detail-close {
    position: sticky; top: 0; float: right;
    background: var(--bg-title);
    border: 1px solid var(--border-mid);
    border-radius: 0 0 0 6px;
    width: 34px; height: 34px;
    font-size: 1.3em;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 5;
    transition: background 0.15s;
    line-height: 1;
}
#detail-close:hover { background: var(--bg-title-hover); }

.detail-card { padding: 12px 16px; }

.detail-card-title {
    background: var(--bg-title);
    border: 1px solid var(--border-accent);
    border-top-color: #ceb08b;
    border-left-color: #ceb08b;
    border-bottom: 2px solid var(--border-dark);
    padding: 8px 12px;
    text-align: center;
    font-size: 1.25em;
    font-weight: 700;
    color: var(--text-primary);
    box-shadow: var(--shadow-title);
    border-radius: 4px 4px 0 0;
    margin: -12px -16px 12px -16px;
}

.detail-image-wrap {
    text-align: center;
    margin-bottom: 12px;
}
.detail-image-wrap img {
    width: 192px; height: 192px;
    image-rendering: pixelated;
    border: 2px solid var(--border-light);
    border-bottom-color: var(--border-dark);
    border-right-color: var(--border-dark);
    border-radius: 4px;
    background: var(--bg-page);
    padding: 4px;
}

.detail-section { margin-bottom: 10px; }
.detail-section-title {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-mid);
    border-radius: 3px;
    padding: 3px 8px;
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 8px;
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-label { color: var(--text-muted); }
.detail-row-value { font-weight: 600; }

.detail-generated-note {
    text-align: center;
    padding: 6px 8px;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9em;
}

.detail-wiki-link,
.detail-action-btn {
    display: block;
    text-align: center;
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--bg-title);
    border: 1px solid var(--border-accent);
    border-radius: 4px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: var(--shadow-title);
    transition: background 0.15s;
}
.detail-wiki-link:hover,
.detail-action-btn:hover {
    background: var(--bg-title-hover);
    color: var(--text-link);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .landing-title { font-size: 2em; }
    .landing-search input { padding: 10px; font-size: 1em; }
    #top-bar { flex-wrap: wrap; gap: 8px; }
    .top-title { font-size: 1em; }
    .filters-bar { gap: 6px; }
    .filter-group select,
    .filter-group input[type="number"] { min-width: 90px; font-size: 0.82em; }
    #detail-panel {
        position: fixed; top: 0; right: 0;
        height: 100vh; z-index: 200;
        box-shadow: -6px 0 20px rgba(90,61,26,0.3);
    }
    #items-table thead th,
    #items-table tbody td { padding: 4px 6px; font-size: 0.82em; }
}


/* =============================================
   IMPROVED COLOR PICKER STYLES
   Add these to your styles.css
   ============================================= */

/* Color filter group */
.filter-group-color {
    position: relative;
}

.color-picker-wrap {
    position: relative;
}

/* Main button that opens the picker */
.color-picker-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.88em;
    color: var(--text-primary);
    transition: all 0.15s;
}

.color-picker-btn:hover {
    border-color: var(--border-accent);
    background: var(--bg-highlight);
}

.color-picker-btn.active {
    border-color: var(--border-accent);
    background: var(--bg-highlight);
    font-weight: 600;
}

.color-picker-btn .color-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: var(--picker-color);
    border: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.color-picker-btn .color-label {
    white-space: nowrap;
}

/* Dropdown panel */
.color-picker-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: var(--bg-content);
    border: 2px solid var(--border-dark);
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(90,61,26,0.25);
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.color-picker-dropdown.hidden {
    display: none;
}

/* Color input — large square on the left */
.color-picker-dropdown input[type="color"] {
    width: 120px;
    height: 120px;
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
    background: var(--bg-input);
    flex-shrink: 0;
}

.color-picker-dropdown input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-dropdown input[type="color"]::-webkit-color-swatch {
    border-radius: 3px;
    border: none;
}

/* Right side: preview + buttons stacked vertically */
.color-picker-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    min-width: 90px;
}

/* Preview row */
.color-preview-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-panel);
    border-radius: 4px;
    flex: 1;
}

.color-preview-row .preview-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--border-dark);
    flex-shrink: 0;
}

.color-preview-row .preview-hex {
    font-family: monospace;
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Button column */
.color-btn-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-btn-row button {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.color-apply-btn {
    background: var(--bg-title);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
}
.color-apply-btn:hover {
    background: var(--bg-title-hover);
}

.color-clear-btn {
    background: none;
    border: 1px solid var(--border-mid);
    color: var(--text-muted);
}
.color-clear-btn:hover {
    background: var(--bg-highlight);
    border-color: var(--border-accent);
    color: var(--text-primary);
}
