/* =========================================================
   Painter
   Light Drawing Studio
========================================================= */

:root {

    --bg:
        #f4f6f8;

    --panel:
        #ffffff;

    --panel-soft:
        #f8fafc;

    --border:
        #e5e7eb;

    --border-dark:
        #d1d5db;

    --text:
        #111827;

    --text-secondary:
        #64748b;

    --text-muted:
        #94a3b8;

    --primary:
        #4f46e5;

    --primary-soft:
        #eef2ff;

    --primary-border:
        #c7d2fe;

    --danger:
        #ef4444;

    --shadow:
        0 4px 20px rgba(15, 23, 42, 0.06);

    --radius:
        10px;

    --topbar-height:
        64px;

    --statusbar-height:
        30px;

    --left-width:
        238px;

    --right-width:
        280px;

    --checker-a:
        #f8fafc;

    --checker-b:
        #eef2f7;
}


/* =========================================================
   Reset
========================================================= */

* {
    box-sizing: border-box;
}


html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}


body {

    font-family:
        Inter,
        "Segoe UI",
        "Microsoft YaHei",
        Arial,
        sans-serif;

    background:
        var(--bg);

    color:
        var(--text);

    overflow:
        hidden;
}


button,
input {
    font:
        inherit;
}


button {
    border: 0;
}


button,
input[type="range"],
input[type="color"] {
    cursor:
        pointer;
}


/* =========================================================
   App
========================================================= */

.painter-app {

    width:
        100vw;

    height:
        100vh;

    display:
        flex;

    flex-direction:
        column;

    background:
        var(--bg);
}


/* =========================================================
   Topbar
========================================================= */

.topbar {

    height:
        var(--topbar-height);

    flex-shrink:
        0;

    display:
        flex;

    align-items:
        center;

    gap:
        14px;

    padding:
        0 18px;

    background:
        var(--panel);

    border-bottom:
        1px solid var(--border);

    box-shadow:
        0 1px 8px rgba(15, 23, 42, 0.04);

    z-index:
        20;
}


.brand {

    width:
        190px;

    display:
        flex;

    align-items:
        center;

    gap:
        10px;

    flex-shrink:
        0;
}


.brand-icon {

    width:
        36px;

    height:
        36px;

    border-radius:
        9px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    background:
        var(--primary-soft);

    color:
        var(--primary);

    font-size:
        19px;

    border:
        1px solid var(--primary-border);
}


.brand-title {

    font-size:
        15px;

    font-weight:
        700;

    line-height:
        18px;
}


.brand-subtitle {

    margin-top:
        1px;

    font-size:
        9px;

    letter-spacing:
        1.4px;

    color:
        var(--text-muted);
}


.toolbar {

    display:
        flex;

    align-items:
        center;

    gap:
        4px;
}


.tool-button {

    min-width:
        68px;

    height:
        40px;

    padding:
        0 10px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    gap:
        6px;

    border-radius:
        8px;

    background:
        transparent;

    color:
        var(--text-secondary);

    transition:
        background 0.15s ease,
        color 0.15s ease;
}


.tool-button:hover {

    background:
        var(--panel-soft);

    color:
        var(--text);
}


.tool-button.active {

    background:
        var(--primary-soft);

    color:
        var(--primary);
}


.tool-button span:first-child {

    font-size:
        17px;
}


.tool-button span:last-child {

    font-size:
        12px;

    font-weight:
        600;
}


.topbar-divider {

    width:
        1px;

    height:
        28px;

    background:
        var(--border);

    margin:
        0 2px;
}


.history-tools {

    display:
        flex;

    gap:
        3px;
}


.icon-button {

    width:
        36px;

    height:
        36px;

    border-radius:
        8px;

    background:
        transparent;

    color:
        var(--text-secondary);

    font-size:
        20px;
}


.icon-button:hover {

    background:
        var(--panel-soft);

    color:
        var(--text);
}


.icon-button:disabled {

    opacity:
        0.35;

    cursor:
        default;
}


.topbar-spacer {

    flex:
        1;
}


.project-tools {

    display:
        flex;

    align-items:
        center;

    gap:
        7px;
}


.button {

    height:
        36px;

    padding:
        0 13px;

    border-radius:
        8px;

    font-size:
        12px;

    font-weight:
        600;

    white-space:
        nowrap;
}


.button.secondary {

    background:
        #ffffff;

    border:
        1px solid var(--border-dark);

    color:
        var(--text-secondary);
}


.button.secondary:hover {

    background:
        var(--panel-soft);

    color:
        var(--text);
}


.button.primary {

    background:
        var(--primary);

    color:
        white;

    box-shadow:
        0 2px 8px rgba(79, 70, 229, 0.2);
}


.button.primary:hover {

    filter:
        brightness(0.96);
}


/* =========================================================
   Workspace
========================================================= */

.workspace {

    min-height:
        0;

    flex:
        1;

    display:
        grid;

    grid-template-columns:
        var(--left-width) minmax(0, 1fr) var(--right-width);

    overflow:
        hidden;
}


/* =========================================================
   Left Panel
========================================================= */

.left-panel {

    min-width:
        0;

    overflow:
        auto;

    background:
        var(--panel);

    border-right:
        1px solid var(--border);

    padding:
        16px 14px;
}


.panel-section {

    padding:
        0 0 18px;

    margin-bottom:
        18px;

    border-bottom:
        1px solid var(--border);
}


.panel-section:last-child {

    border-bottom:
        0;

    margin-bottom:
        0;
}


.panel-title {

    margin-bottom:
        11px;

    font-size:
        11px;

    font-weight:
        700;

    letter-spacing:
        0.5px;

    color:
        var(--text-secondary);
}


.tool-grid {

    display:
        grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap:
        7px;
}


.panel-tool {

    min-height:
        62px;

    display:
        flex;

    flex-direction:
        column;

    align-items:
        center;

    justify-content:
        center;

    gap:
        5px;

    border-radius:
        9px;

    background:
        var(--panel-soft);

    border:
        1px solid transparent;

    color:
        var(--text-secondary);
}


.panel-tool:hover {

    border-color:
        var(--border-dark);

    color:
        var(--text);
}


.panel-tool.active {

    background:
        var(--primary-soft);

    border-color:
        var(--primary-border);

    color:
        var(--primary);
}


.tool-icon {

    font-size:
        18px;
}


.panel-tool span:last-child {

    font-size:
        11px;

    font-weight:
        600;
}


.control-row {

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    margin:
        11px 0 6px;

    font-size:
        11px;

    color:
        var(--text-secondary);
}


.control-value {

    color:
        var(--text-muted);
}


.control-value span {

    color:
        var(--text);

    font-weight:
        600;
}


input[type="range"] {

    width:
        100%;

    height:
        4px;

    margin:
        0;

    appearance:
        none;

    background:
        #e2e8f0;

    border-radius:
        999px;

    outline:
        none;
}


input[type="range"]::-webkit-slider-thumb {

    appearance:
        none;

    width:
        14px;

    height:
        14px;

    border-radius:
        50%;

    background:
        var(--primary);

    border:
        2px solid #ffffff;

    box-shadow:
        0 1px 4px rgba(15, 23, 42, 0.2);
}


.color-control {

    margin-top:
        15px;
}


.color-control label {

    display:
        block;

    margin-bottom:
        7px;

    font-size:
        11px;

    color:
        var(--text-secondary);
}


.color-row {

    display:
        flex;

    gap:
        7px;
}


#colorPicker {

    width:
        38px;

    height:
        34px;

    padding:
        3px;

    background:
        white;

    border:
        1px solid var(--border-dark);

    border-radius:
        7px;
}


#colorText {

    flex:
        1;

    min-width:
        0;

    height:
        34px;

    padding:
        0 9px;

    border:
        1px solid var(--border);

    border-radius:
        7px;

    color:
        var(--text);

    background:
        #ffffff;

    font-size:
        11px;
}


.canvas-info {

    display:
        grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap:
        6px;
}


.canvas-info div {

    padding:
        9px 6px;

    border:
        1px solid var(--border);

    border-radius:
        8px;

    background:
        var(--panel-soft);

    text-align:
        center;
}


.canvas-info span {

    display:
        block;

    margin-bottom:
        3px;

    font-size:
        9px;

    color:
        var(--text-muted);
}


.canvas-info strong {

    font-size:
        10px;

    color:
        var(--text);
}


.shortcut-list {

    display:
        flex;

    flex-direction:
        column;

    gap:
        7px;
}


.shortcut-list div {

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    font-size:
        10px;

    color:
        var(--text-secondary);
}


kbd {

    padding:
        3px 6px;

    border:
        1px solid var(--border-dark);

    border-bottom-width:
        2px;

    border-radius:
        5px;

    background:
        #ffffff;

    color:
        var(--text-muted);

    font-size:
        9px;
}


/* =========================================================
   Canvas Area
========================================================= */

.canvas-area {

    min-width:
        0;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;

    background:
        #edf0f4;
}


.canvas-toolbar {

    height:
        46px;

    flex-shrink:
        0;

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    padding:
        0 15px;

    background:
        #ffffff;

    border-bottom:
        1px solid var(--border);
}


.canvas-toolbar-left,
.canvas-toolbar-right {

    display:
        flex;

    align-items:
        center;

    gap:
        8px;
}


.canvas-title {

    font-size:
        11px;

    font-weight:
        700;

    color:
        var(--text);
}


.canvas-status {

    padding:
        3px 6px;

    border-radius:
        5px;

    background:
        var(--primary-soft);

    color:
        var(--primary);

    font-size:
        9px;

    font-weight:
        700;
}


.canvas-toolbar-right {

    color:
        var(--text-secondary);

    font-size:
        11px;
}


.zoom-button {

    height:
        28px;

    min-width:
        28px;

    padding:
        0 7px;

    border:
        1px solid var(--border);

    border-radius:
        6px;

    background:
        #ffffff;

    color:
        var(--text-secondary);

    font-size:
        11px;
}


.zoom-button:hover {

    background:
        var(--panel-soft);

    color:
        var(--text);
}


#zoomValue {

    min-width:
        42px;

    text-align:
        center;

    font-weight:
        600;
}


.canvas-viewport {

    flex:
        1;

    min-height:
        0;

    min-width:
        0;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    overflow:
        auto;

    padding:
        30px;

    background-color:
        #eef1f5;

    background-image:
        linear-gradient(45deg,
            #e8ecf1 25%,
            transparent 25%),
        linear-gradient(-45deg,
            #e8ecf1 25%,
            transparent 25%),
        linear-gradient(45deg,
            transparent 75%,
            #e8ecf1 75%),
        linear-gradient(-45deg,
            transparent 75%,
            #e8ecf1 75%);

    background-size:
        20px 20px;

    background-position:
        0 0,
        0 10px,
        10px -10px,
        -10px 0;
}


.canvas-wrapper {

    position:
        relative;

    width:
        1280px;

    height:
        720px;

    flex-shrink:
        0;

    background:
        #ffffff;

    box-shadow:
        0 12px 35px rgba(15, 23, 42, 0.15);

    transform-origin:
        center center;
}


#painterCanvas {

    display:
        block;

    width:
        1280px;

    height:
        720px;

    background:
        #ffffff;

    touch-action:
        none;
}


/* =========================================================
   Right Panel
========================================================= */

.right-panel {

    min-width:
        0;

    overflow:
        auto;

    background:
        var(--panel);

    border-left:
        1px solid var(--border);
}


.right-section {

    padding:
        15px;

    border-bottom:
        1px solid var(--border);
}


.right-section-header {

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    margin-bottom:
        12px;
}


.right-section-title {

    font-size:
        11px;

    font-weight:
        700;

    color:
        var(--text);
}


.right-section-subtitle {

    margin-top:
        3px;

    font-size:
        9px;

    color:
        var(--text-muted);
}


.layer-actions {

    display:
        flex;

    gap:
        4px;
}


.small-icon-button {

    width:
        28px;

    height:
        28px;

    border:
        1px solid var(--border);

    border-radius:
        6px;

    background:
        #ffffff;

    color:
        var(--text-secondary);

    font-size:
        15px;
}


.small-icon-button:hover {

    background:
        var(--panel-soft);

    color:
        var(--text);
}


.layers-list {

    display:
        flex;

    flex-direction:
        column;

    gap:
        5px;
}


.layer-item {

    min-height:
        46px;

    display:
        flex;

    align-items:
        center;

    gap:
        8px;

    padding:
        7px 8px;

    border:
        1px solid transparent;

    border-radius:
        8px;

    cursor:
        pointer;
}


.layer-item:hover {

    background:
        var(--panel-soft);
}


.layer-item.active {

    background:
        var(--primary-soft);

    border-color:
        var(--primary-border);
}


.layer-visibility {

    width:
        23px;

    height:
        25px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        5px;

    background:
        transparent;

    color:
        var(--text-muted);

    font-size:
        11px;
}


.layer-visibility:hover {

    background:
        #ffffff;

    color:
        var(--text);
}


.layer-preview {

    width:
        31px;

    height:
        31px;

    border:
        1px solid var(--border);

    border-radius:
        5px;

    background:
        #ffffff;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    overflow:
        hidden;
}


.layer-preview canvas {

    width:
        100%;

    height:
        100%;

    object-fit:
        contain;
}


.layer-name {

    flex:
        1;

    min-width:
        0;

    overflow:
        hidden;

    text-overflow:
        ellipsis;

    white-space:
        nowrap;

    font-size:
        11px;

    font-weight:
        600;

    color:
        var(--text);
}


.layer-object-count {

    font-size:
        9px;

    color:
        var(--text-muted);
}


.property-group {

    margin-top:
        13px;
}


.property-group:first-of-type {

    margin-top:
        12px;
}


.property-group label {

    display:
        block;

    margin-bottom:
        6px;

    font-size:
        10px;

    color:
        var(--text-secondary);
}


.property-group input[type="text"] {

    width:
        100%;

    height:
        34px;

    padding:
        0 9px;

    border:
        1px solid var(--border);

    border-radius:
        7px;

    background:
        #ffffff;

    color:
        var(--text);

    font-size:
        11px;

    outline:
        none;
}


.property-group input[type="text"]:focus {

    border-color:
        var(--primary-border);

    box-shadow:
        0 0 0 3px var(--primary-soft);
}


.property-label-row {

    display:
        flex;

    justify-content:
        space-between;

    align-items:
        center;

    margin-bottom:
        7px;
}


.property-label-row label {

    margin:
        0;
}


#layerOpacityValue {

    font-size:
        10px;

    color:
        var(--text-muted);
}


.project-info-card {

    margin-top:
        12px;

    display:
        flex;

    align-items:
        center;

    gap:
        9px;

    padding:
        10px;

    border:
        1px solid var(--border);

    border-radius:
        8px;

    background:
        var(--panel-soft);
}


.project-info-icon {

    width:
        30px;

    height:
        30px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        7px;

    background:
        var(--primary-soft);

    color:
        var(--primary);
}


.project-info-card strong {

    display:
        block;

    font-size:
        10px;
}


.project-info-card span {

    display:
        block;

    margin-top:
        3px;

    font-size:
        9px;

    color:
        var(--text-muted);
}


.project-tip {

    margin:
        9px 1px 0;

    font-size:
        9px;

    line-height:
        1.6;

    color:
        var(--text-muted);
}


.coming-card {

    margin-top:
        11px;

    padding:
        15px 10px;

    display:
        flex;

    flex-direction:
        column;

    align-items:
        center;

    text-align:
        center;

    border:
        1px dashed var(--border-dark);

    border-radius:
        9px;

    background:
        var(--panel-soft);
}


.coming-icon {

    margin-bottom:
        7px;

    color:
        var(--primary);

    font-size:
        18px;
}


.coming-card strong {

    font-size:
        10px;
}


.coming-card span {

    margin-top:
        4px;

    font-size:
        9px;

    color:
        var(--text-muted);
}


/* =========================================================
   Statusbar
========================================================= */

.statusbar {

    height:
        var(--statusbar-height);

    flex-shrink:
        0;

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    padding:
        0 12px;

    background:
        #ffffff;

    border-top:
        1px solid var(--border);

    color:
        var(--text-muted);

    font-size:
        9px;
}


.status-left,
.status-center,
.status-right {

    display:
        flex;

    align-items:
        center;

    gap:
        7px;
}


.status-dot {

    width:
        6px;

    height:
        6px;

    border-radius:
        50%;

    background:
        #22c55e;
}


.status-dot.saving {

    background:
        #f59e0b;
}


.status-dot.error {

    background:
        #ef4444;
}


.status-right {

    gap:
        14px;
}


/* =========================================================
   Scrollbar
========================================================= */

.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.canvas-viewport::-webkit-scrollbar {

    width:
        7px;

    height:
        7px;
}


.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
.canvas-viewport::-webkit-scrollbar-thumb {

    background:
        #d7dce3;

    border-radius:
        999px;
}


.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track,
.canvas-viewport::-webkit-scrollbar-track {

    background:
        transparent;
}


/* =========================================================
   Responsive
========================================================= */

@media (max-width: 1100px) {

    :root {

        --left-width:
            210px;

        --right-width:
            250px;
    }


    .brand {

        width:
            150px;
    }


    .tool-button {

        min-width:
            54px;
    }


    .tool-button span:last-child {

        display:
            none;
    }
}


@media (max-width: 850px) {

    .left-panel {

        display:
            none;
    }


    .right-panel {

        display:
            none;
    }


    .brand {

        width:
            auto;
    }


    .project-tools .secondary {

        display:
            none;
    }
}