:root {
    --bg-base: #0f1115;
    --bg-surface: #1a1d24;
    --bg-panel: rgba(26, 29, 36, 0.7);
    --text-primary: #f8f9fa;
    --text-secondary: #a1a5b7;
    --accent: #6b4cff;
    --accent-hover: #8266ff;
    --border: #2d3139;
    --danger: #ff4c4c;
    --success: #00d084;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.brand {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.brand h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #6b4cff, #00d084);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.brand p {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.tools-nav {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.divider {
    border: none;
    height: 1px;
    background-color: var(--border);
    margin: 12px 0;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.tool-btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tool-btn.active {
    background-color: rgba(107, 76, 255, 0.1);
    color: var(--accent);
    border-color: rgba(107, 76, 255, 0.2);
}

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

.tool-btn.highlight {
    background-color: var(--accent);
    color: white;
}

.tool-btn.highlight:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

/* Main Editor Area */
.editor-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at center, #1a1d24 0%, #0f1115 100%);
}

.settings-panel {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 24px;
    z-index: 20;
    display: flex;
    gap: 16px;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -20px);
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-group input[type="number"] {
    width: 70px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    color: white;
    font-family: inherit;
    font-size: 14px;
}

.setting-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.action-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.action-btn.primary {
    background: var(--accent);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-hover);
}

.action-btn.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Canvas Area */
.canvas-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    padding: 40px;
    transition: background-color 0.3s ease, border 0.3s ease;
}

.canvas-wrapper.drag-active {
    background-color: rgba(107, 76, 255, 0.05);
    border: 2px dashed var(--accent);
}

#editor-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    display: none;
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

/* Empty State */
.empty-state {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.crop-overlay.hidden {
    display: none;
}

.crop-box {
    position: absolute;
    border: 2px dashed rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    cursor: move;
}

.handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
}

.handle.nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.handle.ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.handle.se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.handle.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle.e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.handle.w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}


/* Footer */
.footer-info {
    height: 40px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 12px;
    color: var(--text-secondary);
    z-index: 10;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 2px 12px;
}

.zoom-controls button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Export Dropdown */
.export-container {
    position: relative;
    width: 100%;
}

.export-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    transition: all 0.2s ease;
}

.export-dropdown.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.export-option {
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    text-align: left;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.export-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.tool-btn.danger {
    color: var(--danger);
    margin-top: auto;
}

.tool-btn.danger:hover:not(:disabled) {
    background-color: rgba(255, 76, 76, 0.1);
    border-color: rgba(255, 76, 76, 0.2);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-actions .action-btn {
    padding: 12px;
    width: 100%;
}

.action-btn.danger {
    background: var(--danger);
    color: white;
}

.action-btn.danger:hover {
    background: #ff3333;
}

#idle-countdown {
    font-size: 1.2em;
    font-variant-numeric: tabular-nums;
}