:root {
    /* Colors */
    --bg-canvas: #0E0F12;
    --bg-app: #111218;
    --bg-surface: #1B1D25;
    --bg-surface-elevated: #20232D;
    --bg-surface-hover: #242836;
    --bg-surface-pressed: #1A1D28;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-default: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.18);
    --border-focus: rgba(140, 120, 255, 0.60);

    --text-primary: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.68);
    --text-tertiary: rgba(255, 255, 255, 0.50);
    --text-disabled: rgba(255, 255, 255, 0.36);

    --brand-primary: #8B7CFF;
    --brand-primary-hover: #9A8CFF;
    --brand-primary-pressed: #7A6AF5;
    --brand-primary-muted: rgba(139, 124, 255, 0.16);

    /* Shadows */
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-pill: 999px;
}

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

body {
    font-family: Inter, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    font-size: 14px;
    line-height: 20px;
}

/* Top Toolbar (Consolidated below) */

.toolbar-bottom-center {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.toolbar-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 120ms cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.toolbar-btn:active,
.toolbar-btn.active {
    background: var(--brand-primary-muted);
    color: var(--brand-primary);
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    margin: 0 2px;
}

.separator {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    margin: 0 2px;
}

/* Left Panel - Layers */
.panel-left {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 280px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    /* transition: width 0.3s ease, max-height 0.3s ease, opacity 0.2s ease, transform 0.3s ease; */
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header:active {
    cursor: grabbing;
}

.panel-header__icon {
    color: var(--text-secondary);
    width: 16px;
    /* Adjusted size for better proportion with header text */
    height: 16px;
    transition: color 0.15s ease;
}

.panel-header:hover .panel-header__icon {
    color: var(--text-primary);
}

.panel-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-search-container {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    max-height: 60px;
    overflow: hidden;
    flex-shrink: 0;
}

#layer-search {
    width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

#layer-search:focus {
    border-color: var(--brand-primary);
    background: var(--bg-surface-hover);
}

#layer-search::placeholder {
    color: var(--text-tertiary);
}

.panel {
    display: flex;
    flex-direction: column;
}

.panel-content {
    padding: 10px;
    flex: 1;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
}

.panel:not(.collapsed) .panel-content {
    overflow-y: auto;
}

.panel.collapsed .panel-content {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}

.panel.collapsed .layer-search-container {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    opacity: 0;
    border-bottom-color: transparent;
    pointer-events: none;
}

.panel-toggle-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.18s ease, color 0.12s ease;
}

.panel-toggle-btn:hover {
    color: var(--text-primary);
}

.panel.collapsed .panel-toggle-btn {
    transform: rotate(-90deg);
}

/* Layers List */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.layer-item {
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 120ms;
    font-size: 12px;
    position: relative;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.layer-item.selected {
    background: var(--brand-primary-muted);
    color: var(--text-primary);
}

/* New Layer Item Structure */
.layer-item-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 4px;
}

.layer-item-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.layer-vis-btn,
.layer-lock-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.1s, color 0.1s, background 0.1s;
}

/* Show buttons on hover or if active */
.layer-item:hover .layer-vis-btn,
.layer-item:hover .layer-lock-btn,
.layer-vis-btn.active,
.layer-lock-btn.active {
    opacity: 1;
}

.layer-vis-btn:hover,
.layer-lock-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.layer-vis-btn.active,
.layer-lock-btn.active {
    color: var(--text-secondary);
}

.layer-vis-btn.active:hover,
.layer-lock-btn.active:hover {
    color: var(--text-primary);
}

.layer-name-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 4px;
}

.layer-name-input {
    width: 100%;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    margin-left: 4px;
}

/* Hover Actions */
.layer-actions-hover {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.1s;
}

.layer-item:hover .layer-actions-hover {
    opacity: 1;
}

.layer-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
}

.layer-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.layer-drag-grip {
    opacity: 0.4;
    cursor: grab;
    pointer-events: none;
}


/* Right Panel - Properties */
.panel-right {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 280px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    /* transition: width 0.3s ease, max-height 0.3s ease, opacity 0.2s ease, transform 0.3s ease; */
    overflow: hidden;
}

.properties-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Properties Form */
.properties-form {
    padding: 12px;
}

.property-section {
    margin-bottom: 16px;
}

.property-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.property-row:last-child {
    margin-bottom: 0;
}

.property-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.property-input {
    flex: 1;
    width: 0;
    /* Fix flex overflow issues */
    height: 32px;
    padding: 0 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    transition: all 120ms;
}

.property-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    background: var(--bg-surface-hover);
}

.property-input::placeholder {
    color: var(--text-tertiary);
}

.property-color-input {
    width: 36px;
    height: 32px;
    padding: 2px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 120ms;
}

.property-color-input:hover {
    border-color: var(--border-strong);
}

.property-color-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

/* Canvas Container */
.canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background: var(--bg-canvas);
}

.canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    position: relative;
    overflow: hidden;
}

/* Canvas Elements */
.canvas-element {
    position: absolute;
    cursor: move;
    user-select: none;
    transform-origin: center center;
}

.canvas-element.selected {
    outline: 1px solid #000000;
}

.canvas-element.rectangle {
    background: var(--brand-primary);
    border-radius: var(--radius-xs);
}

.canvas-element.text {
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--brand-primary);
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 10;
}

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

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

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

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

/* Scrollbar Styling */
.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--radius-xs);
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-default);
}

/* Bottom Left Controls - Undo/Redo */
.controls-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 120ms cubic-bezier(0.2, 0.0, 0.0, 1.0);
    box-shadow: var(--shadow-sm);
}

.control-btn:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}

.control-btn:active:not(:disabled) {
    background: var(--bg-surface-pressed);
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--text-disabled);
}

.control-btn svg {
    width: 16px;
    height: 16px;
}

/* Container */
.style-btn-group {
    display: inline-flex;
    gap: 6px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

/* Base Button */
.style-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #a1a1aa;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

/* Hover */
.style-btn:hover {
    background: var(--bg-surface-hover);
    color: #ffffff;
}

/* Active (toggled on) */
.style-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
}

/* Pressed */
.style-btn:active {
    transform: scale(0.96);
}

/* Focus (keyboard accessible) */
.style-btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* Property Checkbox */
.property-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    user-select: none;
    margin-top: 8px;
}

.property-checkbox input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--brand-primary);
}

.property-checkbox:hover {
    color: var(--text-primary);
}

/* Bottom Right Controls */
.bottom-right-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999;
}

/* Info Button */
.info-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

.info-btn:hover {
    background: var(--bg-surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    color: var(--brand-primary);
    border-color: var(--brand-primary-muted);
}

.info-btn:active {
    transform: translateY(0);
}

.info-btn svg {
    width: 16px;
    height: 16px;
}



.zoom-container {
    transition: transform 0.3s cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

/* Hide UI State */
.ui-hidden .panel-left,
.ui-hidden .panel-right,
.ui-hidden .toolbar-bottom-center {
    display: none !important;
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.modal-container {
    width: 830px;
    max-width: 90vw;
    height: 600px;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.2, 0.0, 0.0, 1.0);
    overflow: hidden;
}

.modal-backdrop.open .modal-container {
    transform: scale(1);
    opacity: 1;
}

/* Modal Header */
.modal-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
    flex-shrink: 0;
}

.modal-branding {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-logo {
    color: var(--text-primary);
}

.modal-title-text h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.modal-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Modal Body */
.modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.modal-sidebar {
    width: 200px;
    background: var(--bg-surface-elevated);
    border-right: 1px solid var(--border-subtle);
    padding: 16px 8px;
    flex-shrink: 0;
    overflow-y: auto;
}

.tab-btn {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 4px;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

.tab-btn.active {
    background: var(--brand-primary-muted);
    color: var(--brand-primary);
}

/* Content Area */
.modal-content-area {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--bg-surface);
}

/* Modal Scrollbar Styling */
.modal-content-area,
.modal-sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 120, 120, 0.35) transparent;
}

.modal-content-area::-webkit-scrollbar,
.modal-sidebar::-webkit-scrollbar {
    width: 6px;
}

.modal-content-area::-webkit-scrollbar-track,
.modal-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content-area::-webkit-scrollbar-thumb,
.modal-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(120, 120, 120, 0.35);
    border-radius: 8px;
}

.modal-content-area::-webkit-scrollbar-thumb:hover,
.modal-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(160, 160, 160, 0.5);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-pane h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.tab-pane p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    font-size: 15px;
    max-width: 600px;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: border-color 0.2s;
}

.feature-card:hover {
    border-color: var(--border-default);
}

.feature-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary-muted);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.feature-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* Tech Stack Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 6px 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

/* Developer Profile */
.dev-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-surface-elevated);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    max-width: 400px;
}

.dev-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.dev-info h4 {
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 16px;
}

.dev-info p {
    margin: 0;
    font-size: 14px;
}

/* Repository Link */
.repo-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.repo-link:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
    transform: translateY(-1px);
}

/* Shortcuts */
.shortcuts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.key-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Tool Usage */
.usage-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 500px;
}

.usage-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.usage-arrow {
    align-self: center;
    color: var(--text-tertiary);
    font-size: 20px;
}

.step-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.step-content h4 {
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 15px;
}

.step-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .modal-container {
        flex-direction: column;
        height: 100%;
        max-height: 100%;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
    }

    .modal-body {
        flex-direction: column;
    }

    .modal-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: 8px;
        white-space: nowrap;
        overflow-x: auto;
        display: flex;
    }

    .tab-btn {
        width: auto;
        margin-bottom: 0;
        margin-right: 8px;
    }

    .info-btn {
        bottom: 80px;
        /* Above bottom toolbar on mobile if needed, but toolbar is centered so right corner is fine */
    }
}

/* Frame Collapse Button */
.layer-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    width: 20px;
    height: 20px;
    margin-right: -4px;
}

.layer-collapse-btn:hover {
    color: var(--text-primary);
    opacity: 1;
}

.layer-collapse-btn.collapsed {
    transform: rotate(-90deg);
}

/* Unsupported Device Warning */
#unsupported-device-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-app);
    color: var(--text-primary);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

#unsupported-device-warning .warning-content {
    max-width: 400px;
    background: var(--bg-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#unsupported-device-warning .warning-icon {
    color: var(--brand-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--brand-primary-muted);
    border-radius: 50%;
}

#unsupported-device-warning .warning-icon svg {
    width: 40px;
    height: 40px;
}

#unsupported-device-warning .warning-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

#unsupported-device-warning .warning-content p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin: 0;
}

#unsupported-device-warning .warning-content .warning-subtext {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

@media (width <=600px) {
    #unsupported-device-warning {
        display: flex;
    }

    .app-container,
    .toolbar,
    .panel-right,
    .panel-left {
        display: none !important;
    }
}

@media (width <=900px) {

    .panel-left,
    .panel-right {
        width: 240px;
    }
}

/* File Control Bar */
.file-bar {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: transform 0.2s ease, opacity 0.2s ease, height 0.2s ease;
    overflow: hidden;
}

.file-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    min-width: 120px;
    justify-content: center;
}

.file-name-test {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    cursor: default;
}

.file-name-input,
#file-name-input {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    width: 200px;
    text-align: center;
    transition: all 0.2s;
}

.file-name-input:focus,
#file-name-input:focus {
    border-color: var(--brand-primary);
    background: var(--bg-surface-hover);
}

.file-name-input::placeholder,
#file-name-input::placeholder {
    color: var(--text-tertiary);
}

.filename-error {
    border-color: rgba(255, 80, 80, 0.8) !important;
    background-color: rgba(255, 80, 80, 0.1) !important;
    animation: input-shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes input-shake {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-4px);
    }

    40% {
        transform: translateX(4px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(2px);
    }

    100% {
        transform: translateX(0);
    }
}

.rename-file-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0;
}

.file-bar:hover .rename-file-btn,
.rename-file-btn:focus {
    opacity: 1;
}

.rename-file-btn:hover {
    background: rgb(255 255 255 / 0.1);
    color: var(--text-primary);
}

.file-bar-btn {
    height: 32px;
    width: 32px;
    padding: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.file-bar-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}

.file-bar-btn:active {
    background: var(--bg-surface-pressed);
}

/* Toggle Button */
#filebar-toggle-btn {
    position: fixed;
    bottom: 62px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1500;
    transition: all 0.2s ease;
    padding: 0;
}

#filebar-toggle-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* Collapsed State */
body.filebar-collapsed .file-bar {
    height: 0;
    opacity: 0;
    pointer-events: none;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    transform: translateX(-50%) translateY(10px);
}

body.filebar-collapsed #filebar-toggle-btn {
    transform: translateX(-50%) rotate(180deg);
    bottom: 62px;
}

/* Ensure it hides with UI toggle */
.ui-hidden .file-bar,
.ui-hidden #filebar-toggle-btn {
    display: none !important;
}

/* Error Shake Animation */
@keyframes shake {
    0% {
        transform: translateX(-50%) translateX(0);
    }

    25% {
        transform: translateX(-50%) translateX(-5px);
    }

    50% {
        transform: translateX(-50%) translateX(5px);
    }

    75% {
        transform: translateX(-50%) translateX(-5px);
    }

    100% {
        transform: translateX(-50%) translateX(0);
    }
}

.file-bar-error {
    animation: shake 0.3s cubic-bezier(.36, .07, .19, .97) both;
    border-color: rgb(255 80 80 / 0.5);
}

/* File List in Modal */
.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
    /* margin-inline: auto; */
}

.file-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px;
    width: 260px;
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border 0.2s ease, transform 0.2s ease;
}

.file-card:hover {
    border-color: #3a3a3a;
    transform: translateY(-2px);
}

/* Header */
.file-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: #f5f5f5;
}

.file-time {
    font-size: 11px;
    color: #888;
}

.file-meta-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Meta */
.file-meta {
    display: flex;
    flex-direction: column;
    text-align: center;
    width: fit-content;
}

.file-date {
    font-size: 20px;
    font-weight: 500;
    color: #aaa;
}

.file-month {
    font-size: 12px;
    font-weight: 500;
    color: #aaa;
}

/* Preview */
.file-preview {
    height: 50px;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Actions */
.file-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.btn-open {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}

.btn-open:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}

.icon-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: #fff;
    border-color: #444;
}

.icon-btn.favorite:hover {
    color: #f5c542;
}

.icon-btn.delete:hover {
    color: #ff5c5c;
}

.no-files-msg {
    text-align: center;
    padding: 40px;
    color: var(--text-tertiary);
    font-size: 14px;
    width: 100%;
}

/* Export Menu */
.export-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.export-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
    z-index: 2000;
}

.export-menu[hidden] {
    display: none;
}

.export-option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.export-option-btn:hover {
    background: rgb(255 255 255 / 0.08);
}

.export-option-btn svg {
    color: var(--text-secondary);
}

.export-option-btn:hover svg {
    color: var(--text-primary);
}