/* ============================================
   OnlinePS - Complete Stylesheet
   Dark theme with CSS variables
   ============================================ */

/* CSS Variables - Dark Theme (Default) */
:root {
    --background: #666d6f;
    --text-color: #f4f3f3;
    --text-color-muted: #c1c1c1;
    --text-color-red: #e38282;
    --text-color-green: #8bdb8b;
    --text-color-blue: #a4a4ff;
    --link-color: #9ffda5;
    --section-background-color: #323a3c;
    --area-background-color: #464d4f;
    --block-background-color: #464d4f;
    --header-background-color: #373d3f;
    --button-background-color: #2f3739;
    --button-background-color-hover: #5d5d5d;
    --button-background-color-active: #4d5153;
    --button-shadow-color: rgba(0, 0, 0, 0.3);
    --button-text-color-active: #5d5d5d;
    --button-border-radius: .4rem;
    --button-toggle-background-color: #575f62;
    --button-toggle-background-color-hover: #575f62;
    --input-background-color: #2f3739;
    --input-background-color-hover: #383f44;
    --input-text-color: #f4f3f3;
    --input-border-color: #0f0f0f;
    --input-border-color-active: #70996e;
    --input-border-radius: .4rem;
    --input-group-border-color: #323a3c;
    --menu-background-color: #474747;
    --menu-icons-filter: invert(1);
    --menu-icons-filter-active: none;
    --menu-text-color: #fefefe;
    --number-input-arrow-width: 2rem;
    --background-color-active: #5d5d5d;
    --background-color-hover: #575f62;
    --text-color-active: #215b2a;
    --border-color: #727677;
    --scrollbar-track-color: #464d4f;
    --scrollbar-thumb-color: #2f3739;
    --mobile-menu-toggle-filter: invert(1);

    --toolbar-width: 56px;
    --right-panel-width: 260px;
    --menu-height: 32px;
    --submenu-height: 44px;
}

/* Light Theme */
body.theme-light {
    --background: #f9f9fa;
    --text-color: #0c0c0d;
    --text-color-muted: #444444;
    --text-color-red: #bb2424;
    --text-color-green: #2b882b;
    --text-color-blue: #5454ca;
    --link-color: #000080;
    --section-background-color: #eaeaea;
    --area-background-color: #d9d9d9;
    --block-background-color: #eaeaea;
    --header-background-color: #dbdbdb;
    --button-background-color: #f9f9fa;
    --button-background-color-hover: #ddd;
    --button-background-color-active: #f3f3f3;
    --button-text-color-active: #59aed8;
    --button-shadow-color: rgba(0, 0, 0, 0.1);
    --button-toggle-background-color: #b7b7b7;
    --button-toggle-background-color-hover: #b7b7b7;
    --input-background-color: #ffffff;
    --input-background-color-hover: #ddd;
    --input-text-color: #0c0c0d;
    --input-border-color: #ccc;
    --input-border-color-active: #59aed8;
    --input-group-border-color: #c4c4c4;
    --menu-background-color: #eaeaea;
    --menu-icons-filter: none;
    --menu-icons-filter-active: invert(1);
    --menu-text-color: #333333;
    --menu-dropdown-hover-background-color: #a3dbf7;
    --menu-dropdown-border-color: #15439b;
    --background-color-active: #a3dbf7;
    --background-color-hover: #c4c4c4;
    --text-color-active: #15439b;
    --border-color: #c1c1c1;
    --scrollbar-track-color: #f9f9fa;
    --scrollbar-thumb-color: #919090;
    --mobile-menu-toggle-filter: none;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    color: var(--text-color);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    flex-direction: column;
}

/* SEO Content - Hidden */
.seo-content {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* ============================================
   Main Layout
   ============================================ */
.wrapper {
    flex: 1;
    display: grid;
    grid-template-rows: var(--menu-height) var(--submenu-height) 1fr;
    grid-template-columns: var(--toolbar-width) 1fr var(--right-panel-width);
    grid-template-areas:
        "menu menu menu"
        "submenu submenu submenu"
        "toolbar canvas rightpanel";
    height: calc(100vh - 0px);
    overflow: hidden;
    position: relative;
}

/* ============================================
   Top Menu Bar
   ============================================ */
.main_menu {
    grid-area: menu;
    background: var(--menu-background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 8px;
    z-index: 100;
}

.menu_bar {
    list-style: none;
    display: flex;
    align-items: center;
    height: 100%;
}

.menu_bar > li {
    position: relative;
    height: 100%;
}

.menu_bar > li > a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    color: var(--menu-text-color);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.menu_bar > li > a:hover,
.menu_bar > li.open > a {
    background: var(--background-color-hover);
}

.menu_bar .name {
    font-weight: 500;
}

/* Dropdown Menus */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--section-background-color);
    border: 1px solid var(--border-color);
    border-top: none;
    list-style: none;
    padding: 4px 0;
    display: none;
    z-index: 1000;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.menu_bar > li.open .dropdown {
    display: block;
}

.dropdown li {
    position: relative;
}

.dropdown li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}

.dropdown li a:hover {
    background: var(--background-color-hover);
}

.dropdown .shortcut {
    color: var(--text-color-muted);
    font-size: 12px;
    margin-left: 20px;
}

.dropdown .separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
    padding: 0;
}

/* ============================================
   Submenu / Toolbar Header
   ============================================ */
.submenu {
    grid-area: submenu;
    background: var(--header-background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 16px;
    z-index: 50;
}

.submenu .logo {
    color: var(--text-color);
    font-weight: bold;
    font-size: 15px;
    text-decoration: none;
    margin-right: 8px;
}

.action-attributes {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.attr-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.attr-item label {
    font-size: 12px;
    color: var(--text-color-muted);
}

/* ============================================
   Number Input
   ============================================ */
.ui-number-input {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--input-background-color);
    overflow: hidden;
}

.ui-number-input.small {
    width: 70px;
}

.ui-number-input input[type="number"] {
    width: 50px;
    padding: 4px 6px;
    border: none;
    background: var(--input-background-color);
    color: var(--input-text-color);
    font-size: 12px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.ui-number-input.small input[type="number"] {
    width: 40px;
}

.ui-number-input input[type="number"]::-webkit-inner-spin-button,
.ui-number-input input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ui-number-input input[type="number"]:focus {
    background: var(--input-background-color-hover);
}

.increase-number,
.decrease-number {
    width: 20px;
    border: none;
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.increase-number:hover,
.decrease-number:hover {
    background: var(--button-background-color-hover);
}

/* Toggle Button */
.ui-toggle-button {
    padding: 4px 10px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.ui-toggle-button:hover {
    background: var(--button-background-color-hover);
}

.ui-toggle-button.active {
    background: var(--background-color-active);
    border-color: var(--input-border-color-active);
}

/* ============================================
   Left Sidebar / Tools
   ============================================ */
.sidebar_left {
    grid-area: toolbar;
    background: var(--section-background-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.tools-scroll {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    gap: 2px;
}

.sidebar_left .item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    position: relative;
    transition: background 0.15s;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px 24px;
    filter: var(--menu-icons-filter);
}

.sidebar_left .item:hover {
    background-color: var(--background-color-hover);
}

.sidebar_left .item.active {
    background-color: var(--background-color-active);
    filter: var(--menu-icons-filter-active);
}

/* Tool Icons - SVG data URIs */
.item.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M5 3l14 9-6 2-2 6-6-17z'/%3E%3C/svg%3E");
}

.item.selection {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='18' height='18' rx='1' stroke-dasharray='4 2'/%3E%3C/svg%3E");
}

.item.brush {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M7 14c-1.66 0-3 1.34-3 3 0 1.31-1.16 2-2 2 .92 1.22 2.49 2 4 2 2.21 0 4-1.79 4-4 0-1.66-1.34-3-3-3zm13.71-9.37l-1.34-1.34a.996.996 0 00-1.41 0L9 12.25 11.75 15l8.96-8.96a.996.996 0 000-1.41z'/%3E%3C/svg%3E");
}

.item.pencil {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 000-1.41l-2.34-2.34a.996.996 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
}

.item.pick_color {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M20.71 5.63l-2.34-2.34a1 1 0 00-1.41 0l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12a1 1 0 00.01-1.42zM6.92 19L5 17.08l8.06-8.06 1.92 1.92L6.92 19z'/%3E%3C/svg%3E");
}

.item.erase {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M16.24 3.56l4.95 4.94c.78.79.78 2.05 0 2.84L12 20.53a4.008 4.008 0 01-5.66 0L2.81 17c-.78-.79-.78-2.05 0-2.84l10.6-10.6c.79-.78 2.05-.78 2.83 0zM4.22 15.58l3.54 3.53c.78.79 2.04.79 2.83 0l3.53-3.53-4.95-4.95-4.95 4.95z'/%3E%3C/svg%3E");
}

.item.magic_erase {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
}

.item.fill {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15a1.49 1.49 0 000 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z'/%3E%3C/svg%3E");
}

.item.shape {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='8' height='8'/%3E%3Ccircle cx='17' cy='17' r='4'/%3E%3C/svg%3E");
}

.item.line {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cline x1='4' y1='20' x2='20' y2='4'/%3E%3C/svg%3E");
}

.item.arrow {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z'/%3E%3C/svg%3E");
}

.item.rectangle {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='14' rx='1'/%3E%3C/svg%3E");
}

.item.ellipse {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cellipse cx='12' cy='12' rx='9' ry='7'/%3E%3C/svg%3E");
}

.item.triangle {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpolygon points='12,4 22,20 2,20'/%3E%3C/svg%3E");
}

.item.star {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E");
}

.item.heart {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
}

.item.polygon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpolygon points='12,2 22,8.5 19,20 5,20 2,8.5'/%3E%3C/svg%3E");
}

.item.text {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M5 4v3h5.5v12h3V7H19V4z'/%3E%3C/svg%3E");
}

.item.gradient {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23000'/%3E%3Cstop offset='100%25' stop-color='%23fff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='24' height='24' fill='url(%23g)'/%3E%3C/svg%3E");
}

.item.clone {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z'/%3E%3C/svg%3E");
}

.item.crop {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M6 2v14a2 2 0 002 2h14'/%3E%3Cpath d='M18 22V8a2 2 0 00-2-2H2'/%3E%3C/svg%3E");
}

.item.blur {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z' opacity='0.3'/%3E%3Ccircle cx='14' cy='9' r='3' opacity='0.5'/%3E%3Ccircle cx='10' cy='14' r='2' opacity='0.4'/%3E%3C/svg%3E");
}

.item.sharpen {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M12 2L1 21h22L12 2zm0 3.83L19.13 19H4.87L12 5.83z'/%3E%3C/svg%3E");
}

.item.desaturate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18'/%3E%3C/svg%3E");
}

.item.magic_wand {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M7.5 21l-1.41-1.41L8.67 17l-2.58-2.59L7.5 13l4 4-4 4zM5 11H2V9h3V6h2v3h3v2H7v3H5v-3zm11.5.5l-2.5-2.5 3.5-3.5 2.5 2.5-3.5 3.5zm-1 8L14 17.5l2-2 1.5 1.5-2 2zM19 5V2h2v3h3v2h-3v3h-2V7h-3V5h3z'/%3E%3C/svg%3E");
}

/* ============================================
   Middle Canvas Area
   ============================================ */
.middle_area {
    grid-area: canvas;
    background: var(--area-background-color);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main_wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas_wrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

#mainCanvas,
.preview-canvas,
.overlay-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

#mainCanvas {
    position: relative;
}

.preview-canvas {
    pointer-events: none;
}

.overlay-canvas {
    pointer-events: none;
    z-index: 10;
}

/* Transparent Grid Background */
.transparent-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.transparent-grid.white {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #fff;
}

/* ============================================
   Right Sidebar
   ============================================ */
.sidebar_right {
    grid-area: rightpanel;
    background: var(--section-background-color);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.block {
    border-bottom: 1px solid var(--border-color);
}

.block > .toggle {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    background: var(--header-background-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.block > .toggle:hover {
    background: var(--background-color-hover);
}

.block > .toggle::after {
    content: '▼';
    font-size: 9px;
    transition: transform 0.2s;
}

.block.collapsed > .toggle::after {
    transform: rotate(-90deg);
}

.block .content {
    padding: 10px 12px;
}

.block.collapsed .content {
    display: none;
}

/* Preview Panel */
.canvas-preview-wrapper {
    position: relative;
    width: 100%;
    height: 120px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.canvas-preview-wrapper .transparent-grid {
    position: absolute;
}

#canvas_preview {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
}

.canvas-preview-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.canvas-preview-details .details {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.layer_add {
    padding: 4px 8px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--button-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s;
}

.layer_add:hover {
    background: var(--button-background-color-hover);
}

#zoom_range {
    width: 100%;
    accent-color: var(--input-border-color-active);
}

/* Color Panel */
.color-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.ui-color-sample {
    width: 40px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #008000;
}

.color-buttons {
    display: flex;
    gap: 4px;
}

.ui-icon-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--input-border-color);
    border-radius: var(--button-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.15s;
}

.ui-icon-button:hover {
    background: var(--button-background-color-hover);
}

.ui-icon-button.active {
    background: var(--background-color-active);
    border-color: var(--input-border-color-active);
}

.ui-icon-button svg {
    width: 18px;
    height: 18px;
}

/* Color Picker */
.ui-color-picker {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.color-picker-gradient {
    flex: 1;
    height: 120px;
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: crosshair;
    background: linear-gradient(to bottom, transparent 0%, #000 100%),
                linear-gradient(to right, #fff 0%, hsl(120, 100%, 50%) 100%);
}

.color-picker-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.color-picker-hue {
    width: 20px;
    height: 120px;
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: ns-resize;
    background: linear-gradient(to bottom,
        #ff0000 0%, #ffff00 17%, #00ff00 33%,
        #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}

.color-picker-handle-h {
    position: absolute;
    left: -3px;
    width: 26px;
    height: 6px;
    border: 2px solid #fff;
    border-radius: 3px;
    transform: translateY(-50%);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.color-hex-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.color-hex-input label {
    font-size: 12px;
    color: var(--text-color-muted);
    width: 30px;
}

.color-hex-input input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--input-background-color);
    color: var(--input-text-color);
    font-size: 12px;
    font-family: monospace;
    outline: none;
}

.color-hex-input input:focus {
    border-color: var(--input-border-color-active);
}

.color-rgb-inputs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rgb-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rgb-row label {
    width: 16px;
    font-size: 11px;
    color: var(--text-color-muted);
    text-align: right;
}

.rgb-row input {
    flex: 1;
    padding: 3px 6px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--input-background-color);
    color: var(--input-text-color);
    font-size: 11px;
    outline: none;
}

/* Info Panel */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

.info-label {
    color: var(--text-color-muted);
}

.info-value {
    color: var(--text-color);
    font-family: monospace;
}

/* Details Panel */
.details-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-row label {
    width: 50px;
    font-size: 12px;
    color: var(--text-color-muted);
}

.detail-row .ui-number-input {
    flex: 1;
}

.reset-btn {
    padding: 3px 6px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--button-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 10px;
    transition: background 0.15s;
}

.reset-btn:hover {
    background: var(--button-background-color-hover);
}

.detail-row.blend-mode select {
    flex: 1;
    padding: 4px 6px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--input-background-color);
    color: var(--input-text-color);
    font-size: 11px;
    outline: none;
    cursor: pointer;
}

/* Layers Panel */
.layers-toolbar {
    display: flex;
    gap: 3px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.layer-btn {
    padding: 4px 8px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--button-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s;
    min-width: 28px;
    text-align: center;
}

.layer-btn:hover {
    background: var(--button-background-color-hover);
}

.layers-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--input-background-color);
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.1s;
    gap: 6px;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item:hover {
    background: var(--background-color-hover);
}

.layer-item.active {
    background: var(--background-color-active);
}

.layer-thumb {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.layer-thumb canvas {
    width: 100%;
    height: 100%;
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 12px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-type {
    font-size: 10px;
    color: var(--text-color-muted);
}

.layer-visibility-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-color-muted);
    cursor: pointer;
    font-size: 14px;
}

.layer-visibility-btn.visible {
    color: var(--text-color);
}

/* ============================================
   Welcome Modal
   ============================================ */
.welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
}

.welcome-modal.hidden {
    display: none;
}

.welcome-content {
    background: #ffffff;
    max-width: 580px;
    width: 90%;
    max-height: 85vh;
    border: 2px solid #333333;
    opacity: 1 !important;
    position: relative;
    display: flex;
    flex-direction: column;
}

.welcome-header {
    background: #f5f5f5;
    padding: 10px 30px;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.welcome-header p {
    margin: 0;
    font-size: 16px;
    color: #000;
    font-weight: bold;
}

.welcome-close {
    background: transparent !important;
    border: none !important;
    font-size: 24px;
    cursor: pointer;
    color: #000;
    padding: 0;
    line-height: 1;
    margin: 0;
    outline: none !important;
    box-shadow: none !important;
}

.welcome-body {
    padding: 20px 30px;
    overflow-y: auto;
    flex: 1;
    color: #222;
}

.welcome-body p {
    color: #222222;
    line-height: 1.5;
    font-size: 14px;
    margin: 0 0 15px 0;
    font-weight: bold;
}

.welcome-body p:first-child {
    margin-top: 0;
    font-weight: normal;
}

.welcome-body ul {
    color: #222222;
    padding-left: 25px;
    font-size: 14px;
    margin: 0 0 15px 0;
}

.welcome-body li {
    margin: 5px 0;
    line-height: 1.4;
}

.welcome-buttons {
    padding: 12px 30px;
    background: #f5f5f5;
    border-top: 1px solid #ccc;
    flex-shrink: 0;
}

.welcome-btn {
    padding: 10px 20px;
    border: 1px solid #333333;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
}

.welcome-btn-primary {
    background: #0066cc;
    color: #ffffff;
}

.welcome-btn-primary:hover {
    background: #0052a3;
}

.welcome-btn-secondary {
    background: #ffffff;
    color: #000000;
}

.welcome-btn-secondary:hover {
    background: #e0e0e0;
}

/* Shortcut Table */
.shortcut-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
    margin-bottom: 15px;
}

.shortcut-table th,
.shortcut-table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #999999;
    color: #000000;
}

.shortcut-table th {
    background: #dddddd;
    font-weight: bold;
}

.shortcut-key {
    background: #f5f5f5;
    padding: 2px 8px;
    border: 1px solid #999999;
    font-family: monospace;
    font-size: 13px;
    color: #000000;
}

/* ============================================
   Help Button
   ============================================ */
.help-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    background: #0066cc;
    color: #ffffff;
    border: 1px solid #004499;
    font-size: 22px;
    cursor: pointer;
    z-index: 9999;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s, transform 0.2s;
}

.help-button:hover {
    background: #0052a3;
    transform: scale(1.05);
}

/* ============================================
   Touch Hint
   ============================================ */
.touch-hint {
    display: none;
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #333333;
    color: #ffffff;
    padding: 8px 16px;
    font-size: 14px;
    z-index: 9998;
    border-radius: 4px;
}

@media (hover: none) and (pointer: coarse) {
    .touch-hint {
        display: block;
    }
}

/* ============================================
   Mobile Menu
   ============================================ */
.mobile_menu {
    display: none;
}

/* ============================================
   Scrollbars
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb-color);
    border-radius: 5px;
    border: 2px solid var(--scrollbar-track-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--button-background-color-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    padding: 30px 20px;
    font-size: 14px;
    color: #555;
    line-height: 1.8;
    overflow-y: auto;
    max-height: 40vh;
}

.site-footer .footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.site-footer h2 {
    font-size: 16px;
    color: #333;
    margin: 20px 0 10px 0;
}

.site-footer h2:first-child {
    margin-top: 0;
}

.site-footer p {
    margin: 0 0 8px 0;
    color: #666;
}

.site-footer ul {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.site-footer ul li {
    display: inline-block;
}

.site-footer ul li a {
    color: #2196f3;
    text-decoration: none;
}

.site-footer ul li a:hover {
    text-decoration: underline;
}

.site-footer .copyright {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    color: #999;
    font-size: 13px;
}

/* ============================================
   Popup Dialogs
   ============================================ */
#popups {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10000;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.modal-dialog {
    background: var(--section-background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    min-width: 320px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--header-background-color);
    border-radius: 6px 6px 0 0;
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-color-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--header-background-color);
    border-radius: 0 0 6px 6px;
}

.modal-btn {
    padding: 6px 16px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--button-border-radius);
    background: var(--button-background-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.modal-btn:hover {
    background: var(--button-background-color-hover);
}

.modal-btn-primary {
    background: #0066cc;
    border-color: #0052a3;
    color: #fff;
}

.modal-btn-primary:hover {
    background: #0052a3;
}

/* Form groups in modals */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-color-muted);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--input-border-radius);
    background: var(--input-background-color);
    color: var(--input-text-color);
    font-size: 13px;
    outline: none;
}

.form-group input[type="range"] {
    width: 100%;
    accent-color: var(--input-border-color-active);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* ============================================
   Text Tool Overlay
   ============================================ */
.text-overlay-input {
    position: absolute;
    border: 1px dashed var(--text-color-blue);
    background: transparent;
    outline: none;
    padding: 2px;
    min-width: 50px;
    min-height: 20px;
    z-index: 100;
    resize: both;
    overflow: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================
   Selection Handles
   ============================================ */
.selection-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #333;
    z-index: 20;
}

.selection-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.selection-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.selection-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.selection-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.selection-handle.n { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.selection-handle.s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.selection-handle.e { right: -5px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.selection-handle.w { left: -5px; top: 50%; transform: translateY(-50%); cursor: w-resize; }

.selection-box {
    position: absolute;
    border: 1px dashed #333;
    pointer-events: none;
    z-index: 15;
}

/* Crop overlay */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.crop-overlay::before,
.crop-overlay::after {
    content: '';
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    :root {
        --right-panel-width: 220px;
    }
}

@media (max-width: 768px) {
    :root {
        --toolbar-width: 44px;
        --right-panel-width: 200px;
        --menu-height: 40px;
    }

    .sidebar_left .item {
        width: 36px;
        height: 36px;
        background-size: 20px 20px;
    }

    .site-footer {
        padding: 20px 15px;
    }

    .site-footer ul {
        flex-direction: column;
        gap: 6px;
    }

    .help-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    .welcome-content {
        width: 95%;
    }

    .welcome-body {
        padding: 15px 20px;
    }
}

@media (max-width: 640px) {
    .wrapper {
        grid-template-columns: var(--toolbar-width) 1fr;
        grid-template-areas:
            "menu menu"
            "submenu submenu"
            "toolbar canvas";
    }

    .sidebar_right {
        display: none;
    }

    .mobile_menu {
        display: block;
        position: fixed;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        z-index: 100;
    }

    .mobile_menu button {
        writing-mode: vertical-rl;
        padding: 12px 6px;
        background: var(--header-background-color);
        color: var(--text-color);
        border: 1px solid var(--border-color);
        border-right: none;
        cursor: pointer;
        border-radius: 4px 0 0 4px;
    }

    .sidebar_right.mobile-open {
        display: block;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 200;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    }
}

/* sr_only for accessibility */
.sr_only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Cursor Styles
   ============================================ */
.cursor-brush { cursor: crosshair; }
.cursor-eraser { cursor: crosshair; }
.cursor-text { cursor: text; }
.cursor-move { cursor: move; }
.cursor-crosshair { cursor: crosshair; }
.cursor-pointer { cursor: pointer; }
