/* ===== Right Property Panel ===== */
#property-panel {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: none;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
}

#property-panel.visible {
    display: block;
}

.panel-section {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.panel-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.panel-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-align: left;
}

.panel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    margin-bottom: 5px;
}

.panel-row label {
    flex: 0 0 55px;
    font-size: 11px;
}

.panel-row > input[type="number"] {
    width: 55px;
}

.panel-row input[type="range"] {
    flex: 1;
    margin: 0 6px;
}

.panel-row .range-value {
    min-width: 28px;
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
}

.panel-row select {
    flex: 1;
    font-size: 11px;
}

/* === Custom Number Input Field === */
.num-field {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    height: 22px;
}
.num-field + .num-field {
    margin-left: 0;
}
.num-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 3px 0 6px;
    flex-shrink: 0;
    user-select: none;
    letter-spacing: 0.3px;
    line-height: 1;
}
.num-suffix {
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 2px;
    flex-shrink: 0;
    user-select: none;
}
.num-field input[type="number"] {
    flex: 1;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 2px 2px;
    width: 0;
    min-width: 28px;
    font-size: 11px;
    outline: none;
    -moz-appearance: textfield;
    color: var(--text-primary);
}
.num-field input[type="number"]::-webkit-inner-spin-button,
.num-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.num-spinners {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
}
.num-spinners button {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 11px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 7px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
    box-sizing: border-box;
}
.num-spinners button + button {
    border-top: 1px solid var(--border-color);
}
.num-spinners button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== Color Picker Grid ===== */
.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    margin-top: 4px;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
}
.color-swatch:hover {
    border-color: var(--text-secondary);
    transform: scale(1.15);
}
.color-swatch.selected {
    border-color: #fff;
}

/* ===== Layer Panel ===== */
#layer-panel {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 220px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.layer-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-height: 0;
}

.layer-panel-header button {
    padding: 1px 2px;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.layer-panel-header button .material-symbols-outlined {
    font-size: 14px;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

.layer-list {
    overflow-y: auto;
    padding: 4px;
    max-height: 93px; /* ~3 items */
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.1s;
}
.layer-item:hover {
    background: var(--bg-hover);
}
.layer-item.selected {
    background: var(--bg-active);
    color: var(--text-primary);
}

.layer-item .layer-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.layer-item .layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-item .layer-visibility {
    cursor: pointer;
    opacity: 0.5;
    font-size: 14px;
}
.layer-item .layer-visibility:hover {
    opacity: 1;
}
.layer-item .layer-visibility.hidden {
    opacity: 0.2;
}

.layer-drag-handle {
    color: var(--text-muted);
    font-size: 13px;
    cursor: grab;
    flex-shrink: 0;
    opacity: 0.35;
    line-height: 1;
    transition: opacity 0.1s;
}
.layer-item:hover .layer-drag-handle {
    opacity: 0.7;
}
.layer-item.drag-over {
    background: var(--bg-active);
    outline: 1px dashed var(--accent);
    outline-offset: -1px;
}

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

.modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.modal-dialog h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-dialog textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    outline: none;
}
.modal-dialog textarea:focus {
    border-color: var(--accent);
}

.modal-dialog select {
    width: 100%;
    margin-bottom: 10px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.modal-actions .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.modal-actions .btn-primary:hover {
    background: var(--accent-hover);
}

/* ===== Context Menu ===== */
.context-menu {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
    z-index: 3000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    min-width: 160px;
}
.context-menu-item {
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.context-menu-item:hover {
    background: var(--bg-hover);
}
.context-menu-item .shortcut {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 20px;
}
.context-menu-sep {
    height: 1px;
    background: var(--border-color);
    margin: 3px 6px;
}

/* ===== Notification Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 5000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===== Right-click Context Menu ===== */
#context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    display: none;
    min-width: 160px;
    user-select: none;
}

.ctx-item {
    padding: 7px 16px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ctx-item .material-symbols-outlined {
    font-size: 16px;
    line-height: 1;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
    flex-shrink: 0;
}
.ctx-item:hover {
    background: var(--bg-hover);
}
.ctx-item.ctx-danger {
    color: #e06c75;
}
.ctx-item.ctx-danger:hover {
    background: rgba(224,108,117,0.15);
}

.ctx-separator {
    height: 1px;
    background: var(--border-color);
    margin: 3px 0;
}

/* ===== Inline Rename Input ===== */
#rename-input {
    position: fixed;
    z-index: 9999;
    display: none;
    background: var(--bg-secondary);
    border: 1.5px solid var(--accent);
    color: var(--text-primary);
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 4px;
    min-width: 160px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
