body.app-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.studio {
    width: min(1180px, calc(100% - 24px));
    margin: 12px auto 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.studio-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 10px;
    box-shadow: var(--shadow);
}

.studio-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.92rem;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.7; }
}

.sync-pill {
    font-size: 0.8rem;
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--paper);
    border: 1px solid var(--border);
    color: var(--ink-soft);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}
.sync-dot.ok { background: #16a34a; }
.sync-dot.loading { background: #f59e0b; }
.sync-dot.error { background: #dc2626; }

.studio-bar .btn-primary,
.studio-bar .btn-secondary {
    padding: 8px 14px;
    font-size: 0.9rem;
}

.studio-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 52px;
    z-index: 30;
}

.color-palette {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    align-items: center;
}

.color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.color-btn:hover { transform: scale(1.08); }
.color-btn.active { outline: 2px solid var(--primary); }

.color-picker {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.tool-group {
    display: flex;
    gap: 4px;
    background: var(--paper-deep);
    padding: 4px;
    border-radius: 12px;
}

.tool-btn,
.action-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-family: inherit;
}

.tool-btn.active,
.mobile-tool-btn.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.action-btn {
    background: #fff;
    border: 1px solid var(--border);
}

.thickness-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--paper-deep);
    padding: 6px 12px;
    border-radius: 12px;
    min-width: 180px;
    font-weight: 800;
    font-size: 0.85rem;
}

.thickness-slider {
    flex-grow: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #d6cbb8;
    border-radius: 3px;
    outline: none;
}

.thickness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
}

.studio-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 12px;
    align-items: start;
}

.studio-stage.chat-collapsed {
    grid-template-columns: 1fr;
}

#canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;
    aspect-ratio: 4 / 3;
    background: #fff;
    border-radius: 4px 18px 18px 18px;
    box-shadow:
        0 18px 40px rgba(92, 64, 32, 0.14),
        0 0 0 1px rgba(92, 64, 32, 0.08);
    overflow: hidden;
    line-height: 0;
    margin: 0 auto;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #fff;
    cursor: none;
}

.brush-cursor {
    position: absolute;
    border: 2px solid rgba(28, 25, 23, 0.55);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 3;
    display: none;
}

.remote-cursors {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.remote-cursor {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.remote-cursor-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.remote-cursor-name {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 800;
    background: rgba(28, 25, 23, 0.86);
    color: #fff;
    padding: 2px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.empty-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 253, 248, 0.88);
    padding: 24px;
    text-align: center;
    line-height: 1.4;
}

.empty-overlay h2,
.word-card h2 {
    margin: 0;
    font-size: 1.25rem;
}

.idea-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
}

.idea-btn:hover { border-color: var(--primary); color: var(--primary-hover); }

.word-card {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 6;
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(250, 245, 255, 0.96);
    padding: 10px 14px;
    text-align: left;
    line-height: 1.3;
    border-radius: 12px;
    border: 1px solid #ddd6fe;
    box-shadow: var(--shadow);
}

.word-card.is-on { display: flex; }
.word-timer { font-size: 1.4rem; font-weight: 800; color: #6d28d9; }

.chat-drawer {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 280px;
    max-height: min(70vh, 640px);
}

.studio-stage.chat-collapsed .chat-drawer { display: none; }

.chat-head {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.chat-head input,
.chat-form input,
.modal-content input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
}

.chat-messages {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 140px;
}

.chat-msg {
    padding: 7px 8px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--paper);
    line-height: 1.35;
}

.chat-msg.own {
    background: var(--primary-soft);
    border: 1px solid #bbf7d0;
}

.chat-msg-meta {
    font-size: 0.75rem;
    color: var(--ink-soft);
    margin-bottom: 4px;
}

.chat-form { margin-top: 8px; display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.chat-form button {
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    padding: 9px 14px;
    cursor: pointer;
    font-family: inherit;
}

.studio-title {
    text-align: center;
    margin: 8px auto 0;
    max-width: 720px;
}

.studio-title h1 {
    font-size: 1.05rem;
    margin: 0;
    font-weight: 800;
}

.studio-title p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 0.92rem;
}

.seo-content {
    width: min(900px, calc(100% - 24px));
    margin: 36px auto 0;
    background: var(--card);
    padding: 28px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    content-visibility: auto;
    contain-intrinsic-size: 900px;
}

.faq-list { display: grid; gap: 12px; margin-top: 12px; }

.mobile-tools-bar { display: none; }

.sheet {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 950;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.sheet.is-open { display: block; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}

.modal-overlay.is-open { display: flex; }

.modal-content {
    background: var(--card);
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

.modal-content h3 { margin-top: 0; }
.modal-content input { width: 100%; margin: 8px 0; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    background: #1c1917;
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    display: none;
    max-width: 320px;
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .studio-stage { grid-template-columns: 1fr; }
    .chat-drawer {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        z-index: 940;
        max-height: 46vh;
        display: none;
    }
    .studio-stage.chat-open-mobile .chat-drawer { display: flex; }
}

@media (max-width: 768px) {
    body.app-page {
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }
    body.app-page .site-nav {
        position: sticky;
        top: 0;
        z-index: 40;
    }
    .studio-tools {
        position: sticky;
        top: 48px;
        z-index: 35;
        padding: 8px;
        gap: 8px;
    }
    .studio-tools .action-btn {
        display: none;
    }
    .color-btn,
    .color-picker {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    .tool-btn {
        padding: 10px 12px;
        min-height: 44px;
        font-size: 0.9rem;
    }
    .thickness-box {
        min-width: 0;
        width: 100%;
    }
    .mobile-tools-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        background: rgba(255, 253, 248, 0.96);
        border-top: 1px solid var(--border);
    }
    .mobile-tool-btn {
        border: 1px solid var(--border);
        background: #fff;
        border-radius: 10px;
        font-size: 0.78rem;
        padding: 12px 4px;
        color: var(--ink-soft);
        font-weight: 800;
        cursor: pointer;
        font-family: inherit;
        min-height: 44px;
    }
    .mobile-tool-btn.active {
        color: #fff;
        background: var(--primary);
        border-color: var(--primary);
    }
    .sheet {
        z-index: 980;
        left: 8px;
        right: 8px;
        bottom: calc(96px + env(safe-area-inset-bottom));
    }
    .sheet-title {
        margin: 0 0 10px;
        font-weight: 800;
    }
    .toast { bottom: calc(108px + env(safe-area-inset-bottom)); }
}

@media (min-width: 769px) {
    .mobile-only { display: none !important; }
}
