:root {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --border-color: #333;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --toolbar-width: 60px;
    --header-height: 60px;
    --status-height: 30px;
    --properties-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Header */
.top-bar {
    height: var(--header-height);
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-color);
    letter-spacing: 1px;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

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

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

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    border-color: var(--text-secondary);
}

/* Main Workspace */
.main-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Toolbar */
.toolbar {
    width: var(--toolbar-width);
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    z-index: 5;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.tool-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

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

.separator {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    background-color: #1a1a1a;
    background-image:
        linear-gradient(45deg, #222 25%, transparent 25%),
        linear-gradient(-45deg, #222 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #222 75%),
        linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    margin: auto;
}

#mainCanvas {
    display: block;
    background-color: transparent;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Properties Panel */
.properties-panel {
    width: var(--properties-width);
    background-color: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    padding: 15px;
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 25px;
}

.panel-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

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

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

.slider-group label {
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    color: var(--text-primary);
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: #444;
    border-radius: 2px;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #2a2a2a;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

input[type="color"] {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
}

.tool-row {
    display: flex;
    gap: 8px;
}

.effects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.effect-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.effect-btn:hover {
    background: #333;
    border-color: var(--accent-color);
}

.effect-btn i {
    font-size: 1.2rem;
    color: var(--accent-color);
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 10px;
    font-style: italic;
}

/* Status Bar */
.status-bar {
    height: var(--status-height);
    background-color: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    z-index: 10;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-controls button {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

.zoom-controls button:hover {
    color: var(--accent-color);
}

/* Text Overlay */
.text-input-overlay {
    position: absolute;
    border: 1px dashed var(--accent-color);
    background: rgba(0, 0, 0, 0.5);
    /* Slight bg to see it */
    min-width: 50px;
    min-height: 20px;
    padding: 5px;
    color: white;
    caret-color: white;
    outline: none;
    white-space: pre;
    overflow: hidden;
    z-index: 1000;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-box {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    width: 400px;
    max-width: 90%;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-title {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-message {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: #2a2a2a;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent-color);
}

/* ══════════════════════════════════════════
   Mobile RWD — QuickPhoto
   Based on original styleO.css patterns
   ══════════════════════════════════════════ */

/* ─── Tablet (≤ 1024px) ─── */
@media (max-width: 1024px) {
    .properties-panel {
        width: 220px;
    }
}

/* ─── Mobile (≤ 768px) ─── */
@media (max-width: 768px) {

    /* Body — allow vertical scrolling */
    body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: 100vh;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Header — compact single-row */
    .top-bar {
        padding: 0 8px;
        height: 48px;
        min-height: 48px;
    }

    .logo span {
        font-size: 0.85rem;
    }

    .actions {
        gap: 4px;
    }

    .actions .btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        gap: 4px;
    }

    .actions .btn span {
        display: none;
        /* Hide button text, show icons only */
    }

    .actions .icon-btn {
        width: 30px;
        height: 30px;
    }

    /* Hide zoom buttons on mobile — use pinch-to-zoom */
    #headerZoomOut,
    #headerZoomIn {
        display: none;
    }

    /* Main workspace → vertical stack */
    .main-workspace {
        flex-direction: column;
        overflow: visible;
        flex: none;
    }

    /* Toolbar → horizontal scrollable row */
    .toolbar {
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 6px 8px;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 2px;
        /* Hide scrollbar */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .toolbar::-webkit-scrollbar {
        display: none;
    }

    .tool-group {
        flex-direction: row;
        width: auto;
        gap: 3px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .separator {
        margin-top: 0;
        margin-left: auto;
        padding-top: 0;
        border-top: none;
        padding-left: 8px;
        border-left: 1px solid var(--border-color);
    }

    /* Canvas → controlled height */
    .canvas-container {
        min-height: 42vh;
        max-height: 50vh;
        height: 46vh;
        flex: none;
        width: 100%;
    }

    /* Properties Panel → full width below canvas */
    .properties-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        height: auto;
        max-height: none;
        overflow-y: visible;
        padding: 12px 14px;
    }

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

    .panel-section h3 {
        font-size: 0.75rem;
        margin-bottom: 10px;
    }

    .slider-group label {
        font-size: 0.8rem;
    }

    /* Effects grid — compact */
    .effects-grid {
        gap: 6px;
    }

    .effect-btn {
        padding: 8px 4px;
    }

    .effect-btn i {
        font-size: 1rem;
    }

    .effect-btn span {
        font-size: 0.7rem;
    }

    /* Range inputs — bigger touch targets */
    input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }

    /* Color picker — compact */
    .color-picker-wrapper {
        gap: 6px;
    }

    /* Sticker tabs — horizontal scroll */
    .sticker-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .sticker-tabs::-webkit-scrollbar {
        display: none;
    }

    .sticker-tab {
        flex-shrink: 0;
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    .sticker-container {
        max-height: 150px;
    }

    /* Status bar — hidden on mobile */
    .status-bar {
        display: none;
    }

    /* Modals — wider */
    .modal-box {
        width: 92%;
        max-width: none;
        max-height: 85vh;
        overflow-y: auto;
    }

    /* Tool grid — 2 columns on mobile */
    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ─── Small phones (≤ 480px) ─── */
@media (max-width: 480px) {
    .top-bar {
        padding: 0 6px;
        height: 44px;
        min-height: 44px;
    }

    .logo {
        font-size: 1rem;
        gap: 6px;
    }

    .logo i {
        font-size: 0.9rem;
    }

    .actions .icon-btn {
        width: 28px;
        height: 28px;
    }

    .actions .btn {
        padding: 5px 6px;
    }

    .canvas-container {
        min-height: 36vh;
        max-height: 46vh;
        height: 40vh;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
    }

    .panel-section h3 {
        font-size: 0.7rem;
    }

    .effects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .effect-btn {
        padding: 6px 2px;
    }

    .effect-btn span {
        font-size: 0.6rem;
    }
}

/* Sticker Tabs */
.sticker-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.sticker-tab {
    padding: 5px 10px;
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
}

.sticker-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.sticker-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    background: #1e1e1e;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.sticker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    user-select: none;
    padding: 8px;
    border-radius: 6px;
    background-color: #2a2a2a;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.sticker-item:hover {
    background-color: #333;
    transform: scale(1.1);
    border-color: var(--accent-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.sticker-item:active {
    transform: scale(0.95);
}

.sticker-item.selected {
    background-color: rgba(59, 130, 246, 0.3);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

/* Text Input Overlay Enhanced */
.text-input-overlay {
    display: flex;
    flex-direction: column;
    background: transparent;
    border: none;
    padding: 0;
    min-width: 150px;
}

#textInputArea {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px dashed var(--accent-color);
    padding: 5px;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    resize: both;
    min-height: 1.5em;
    overflow: hidden;
    white-space: pre-wrap;
}

.text-actions {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    justify-content: flex-end;
}

.btn-mini {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.btn-success {
    background: #22c55e;
    color: white;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

/* Tool Switcher Modal Styles */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 10px;
}

.tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.2s;
    border: 1px solid var(--border-color);
}

.tool-item:hover {
    background-color: #333;
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.tool-icon {
    font-size: 2rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    transition: color 0.2s;
}

.tool-item:hover .tool-icon {
    color: var(--accent-color);
}

.tool-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
}

@media (max-width: 600px) {
    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}