:root {
    --primary: #007bff;
    --bg: #f0f2f5;
    --panel: #ffffff;
    --border: #ccc;
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-shrink: 0;
    z-index: 10;
    width: 98%;
    max-width: 1400px;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tab-btn {
    padding: 8px 20px;
    cursor: pointer;
    border: none;
    background: #dce1e6;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
    color: #555;
    font-size: 14px;
    transition: 0.2s;
}

.info-icon {
    position: absolute;
    right: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
    border: 1px solid #ff8c00;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #ff8c00;
    font-weight: bold;
    transition: 0.2s;
    margin-bottom: 2px;
}

.info-icon:hover {
    background: #fff3e0;
    color: #e26804;
    border-color: #e26804;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: var(--panel);
    color: var(--primary);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.main-wrapper {
    flex: 1;
    width: 98%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 10px;
}

.content-area {
    background: var(--panel);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    height: 100%;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.content-area.active {
    display: flex;
}

.toolbar-row {
    background: #f8f9fa;
    padding: 6px 10px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-height: 42px;
}

.toolbar-row.secondary {
    background: #fff;
    padding: 6px 10px;
}

.divider {
    width: 1px;
    height: 20px;
    background: #bbb;
    margin: 0 2px;
}

.group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.group label {
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

input[type=number] {
    border: 1px solid #ccc;
    width: 45px;
    text-align: center;
    padding: 2px;
}

input[type=range] {
    width: 70px;
    cursor: pointer;
}

select {
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: bold;
    color: #555;
    outline: none;
    cursor: pointer;
}

.btn {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    background: #e9ecef;
    color: #333;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: 0.1s;
    white-space: nowrap;
}

.btn:hover {
    background: #dee2e6;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #007bff;
    color: white;
    border-color: #0056b3;
}

.btn-warning {
    background: #ffc107;
    color: #333;
    border-color: #d39e00;
}

.btn-red {
    background: #dc3545;
    color: white;
    border-color: #a71d2a;
}

.btn-green {
    background: #28a745;
    color: white;
    border-color: #1e7e34;
}

.btn-purple {
    background: #6f42c1;
    color: white;
    border-color: #59359a;
}

.btn-gray {
    background: #6c757d;
    color: white;
    border-color: #545b62;
}

.btn.tool-active {
    background: #e26804;
    color: white;
    border-color: #000;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.color-preview {
    width: 20px;
    height: 20px;
    border: 1px solid #999;
    background: #fff;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
}

.viewport {
    flex: 1;
    background: #808080;
    overflow: hidden;
    position: relative;
    cursor: default;
}

.canvas-stack {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-color: white;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.layer-img {
    z-index: 1;
}

.layer-ov {
    z-index: 2;
    pointer-events: none;
}

.zoom-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.9);
    padding: 5px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 100;
    display: flex;
    font-size: 12px;
}

.anim-panel {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 160px;
    background: rgba(255,255,255,0.98);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    border: 1px solid #ccc;
}

.anim-header {
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    text-align: center;
}

.anim-canvas {
    border: 1px solid #ddd;
    background: #fff;
    background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%);
    background-size: 10px 10px;
    align-self: center;
    margin-bottom: 5px;
}

.anim-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.anim-label {
    color: #666;
}

.hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 999;
}

.hint.show {
    opacity: 1;
}