/* Studio — darrell.work */
:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1a1a1a;
    --surface-3: #222;
    --border: #2a2a2a;
    --border-hover: #3a3a3a;
    --text: #e5e5e5;
    --text-dim: #888;
    --text-muted: #555;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-dim: rgba(59, 130, 246, 0.15);
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --radius: 8px;
    --radius-sm: 4px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    --topbar-h: 48px;
    --sidebar-w: 240px;
    --chat-w: 340px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; position: fixed; width: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 13px; }

/* Screens */
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* Buttons */
.btn-primary {
    width: 100%; padding: 10px 20px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
    background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 6px 12px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }
.btn-icon {
    background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 6px;
    border-radius: var(--radius-sm); transition: all 0.15s; display: flex; align-items: center;
}
.btn-icon:hover { color: var(--text); background: var(--surface-3); }
.btn-icon-sm {
    background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px;
    border-radius: var(--radius-sm); transition: all 0.15s; display: flex; align-items: center;
}
.btn-icon-sm:hover { color: var(--text); }
.btn-tool {
    background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 5px 10px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 11px; display: flex;
    align-items: center; gap: 5px; transition: all 0.15s; white-space: nowrap;
}
.btn-tool:hover { border-color: var(--text-dim); color: var(--text); }
.btn-tool.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.btn-sm {
    background: var(--accent); color: #fff; border: none; padding: 4px 12px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 11px;
}
.btn-send {
    background: var(--accent); color: #fff; border: none; padding: 8px; border-radius: var(--radius);
    cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s;
    flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-viewport {
    background: none; border: 1px solid transparent; color: var(--text-muted); padding: 4px 6px;
    cursor: pointer; border-radius: var(--radius-sm); transition: all 0.15s; display: flex; align-items: center;
}
.btn-viewport:hover { color: var(--text-dim); }
.btn-viewport.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* Login */
#login-screen { align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 360px; padding: 0 20px; }
.login-logo { text-align: center; margin-bottom: 40px; }
.login-logo h1 { font-size: 28px; font-weight: 300; letter-spacing: 0.1em; margin-top: 12px; }
.login-logo p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.logo-icon { font-size: 32px; color: var(--accent); }
.logo-icon.small { font-size: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.form-group input {
    width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none; transition: border 0.15s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-muted); }
.error-text { color: var(--danger); font-size: 12px; margin-top: 12px; text-align: center; min-height: 18px; }
#login-form .btn-primary { margin-top: 8px; }

/* Projects */
#projects-screen { flex-direction: column; }
.projects-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.projects-title { display: flex; align-items: center; gap: 10px; }
.projects-title h2 { font-size: 18px; font-weight: 400; letter-spacing: 0.05em; }
.user-menu { display: flex; align-items: center; gap: 12px; }
#user-name { color: var(--text-dim); font-size: 13px; }
.projects-grid {
    display: flex; flex-wrap: wrap;
    gap: 16px; padding: 24px; overflow-y: auto; flex: 1; align-content: flex-start;
}
.project-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; cursor: pointer; transition: all 0.2s; width: 220px;
}
.project-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.project-card .icon { font-size: 28px; margin-bottom: 12px; }
.project-card h3 { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.project-card p { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.project-card .url { font-size: 11px; color: var(--text-muted); margin-top: 8px; font-family: var(--mono); }

/* Editor */
#editor-screen { flex-direction: column; }
.editor-topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--topbar-h); padding: 0 12px; border-bottom: 1px solid var(--border);
    background: var(--surface); flex-shrink: 0; gap: 8px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-center { display: flex; align-items: center; }
.project-name { font-weight: 500; font-size: 13px; }
.file-name { color: var(--text-dim); font-size: 12px; font-family: var(--mono); }
.save-status { font-size: 11px; color: var(--success); }

.viewport-toggle { display: flex; gap: 2px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; }

/* Tab Bar */
.tab-bar {
    display: flex; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0; min-height: 0;
}
.tab-bar:empty { display: none; }
.tab-item {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 11px;
    color: var(--text-dim); cursor: pointer; border-right: 1px solid var(--border);
    white-space: nowrap; transition: all 0.1s; font-family: var(--mono);
}
.tab-item:hover { background: var(--surface-2); color: var(--text); }
.tab-item.active { background: var(--bg); color: var(--text); border-bottom: 2px solid var(--accent); }
.tab-item .tab-close {
    width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
    border-radius: 3px; font-size: 10px; opacity: 0.5; transition: all 0.1s;
}
.tab-item .tab-close:hover { opacity: 1; background: var(--danger); color: #fff; }
.tab-item .tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }

/* Editor Body */
.editor-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); border-right: 1px solid var(--border); background: var(--surface);
    display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px;
    font-weight: 500; color: var(--text-dim);
}
.file-tree { overflow-y: auto; flex: 1; padding: 4px 0; }
.tree-item {
    display: flex; align-items: center; gap: 6px; padding: 4px 12px; cursor: pointer;
    font-size: 12px; color: var(--text-dim); transition: all 0.1s; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.tree-item:hover { background: var(--surface-2); color: var(--text); }
.tree-item.active { background: var(--accent-dim); color: var(--accent); }
.tree-item.directory { font-weight: 500; }
.tree-item .indent { flex-shrink: 0; }
.tree-icon { flex-shrink: 0; font-size: 14px; width: 18px; text-align: center; }
.tree-toggle { flex-shrink: 0; width: 14px; font-size: 10px; color: var(--text-muted); }

/* Preview */
.main-area { flex: 1; display: flex; overflow: hidden; position: relative; }
.preview-container { flex: 1; display: flex; align-items: center; justify-content: center; background: #1e1e1e; overflow: hidden; position: relative; }
.preview-frame { width: 100%; height: 100%; transition: width 0.3s; }
.preview-frame.tablet { width: 768px; }
.preview-frame.mobile { width: 375px; }
.preview-frame iframe { width: 100%; height: 100%; border: none; background: #fff; }
.preview-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.empty-state { text-align: center; color: var(--text-muted); }
.empty-state svg { margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* Code Editor */
.code-container {
    width: 50%; border-left: 1px solid var(--border); display: flex; flex-direction: column;
    background: var(--surface);
}
.code-header {
    display: flex; align-items: center; justify-content: space-between; padding: 6px 12px;
    border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-dim);
    font-family: var(--mono);
}
#code-editor, #css-editor {
    flex: 1; width: 100%; padding: 12px; background: var(--bg); color: var(--text);
    border: none; outline: none; resize: none; font-family: var(--mono); font-size: 13px;
    line-height: 1.6; tab-size: 2;
}
.btn-code-tab {
    background: none; border: none; color: var(--text-dim); padding: 4px 10px;
    font-size: 11px; cursor: pointer; border-bottom: 2px solid transparent;
}
.btn-code-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Chat Panel */
.chat-panel {
    width: var(--chat-w); border-left: 1px solid var(--border); background: var(--surface);
    display: grid; grid-template-rows: auto 1fr auto; flex-shrink: 0; overflow: hidden;
}
.chat-panel.hidden { display: none; }
.chat-header {
    display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
    border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 500;
}
.chat-messages { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.chat-msg { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; max-width: 95%; }
.chat-msg.user { background: var(--accent-dim); color: var(--text); align-self: flex-end; border-radius: var(--radius) var(--radius) 4px var(--radius); }
.chat-msg.assistant { background: var(--surface-2); color: var(--text); align-self: flex-start; border-radius: var(--radius) var(--radius) var(--radius) 4px; }
.chat-msg ul { margin: 8px 0 0 16px; }
.chat-msg li { margin-bottom: 4px; color: var(--text-dim); }
.chat-msg .applied { color: var(--success); font-size: 11px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.chat-input-area {
    padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px;
    align-items: flex-end;
}
#chat-input {
    flex: 1; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 16px; font-family: var(--font);
    resize: none; outline: none; max-height: 120px; transition: border 0.15s;
    -webkit-appearance: none; min-height: 40px;
}
#chat-input:focus { border-color: var(--accent); }
#chat-input::placeholder { color: var(--text-muted); }

/* Chat FAB */
.chat-fab {
    position: absolute; bottom: 20px; right: 20px; width: 48px; height: 48px;
    background: var(--accent); color: #fff; border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: all 0.2s; z-index: 10;
}
.chat-fab:hover { transform: scale(1.1); }
.chat-fab.hidden { display: none; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    width: 100%; max-width: 700px; max-height: 80vh; overflow-y: auto; padding: 0;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
    background: var(--surface); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 500; }
.template-categories {
    display: flex; gap: 4px; padding: 12px 20px; overflow-x: auto; flex-wrap: wrap;
}
.template-categories button {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
    padding: 4px 12px; border-radius: 20px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.template-categories button.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 20px 20px; }
.template-card {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: all 0.15s;
}
.template-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.template-card h4 { font-size: 13px; margin-bottom: 4px; }
.template-card p { font-size: 11px; color: var(--text-dim); }

/* History */
.history-list { padding: 12px 20px 20px; }
.history-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px;
}
.history-item:hover { background: var(--surface-2); }
.history-item .history-date { color: var(--text-dim); font-family: var(--mono); font-size: 11px; }
.history-item .history-user { color: var(--text-muted); font-size: 11px; }

/* Loading spinner */
.spinner {
    display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar — thin, minimal */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
::-webkit-scrollbar-corner { background: transparent; }

/* iPad / Tablet */
@media (max-width: 1024px) {
    .sidebar { width: 200px; }
    .chat-panel { width: 300px; }
    .topbar-right .btn-tool span { display: none; }
}

@media (max-width: 1024px) {
    .chat-panel {
        position: absolute; right: 0; top: 0; bottom: 0; z-index: 20;
        width: 340px; box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .chat-panel {
        position: absolute; left: 0; right: 0; bottom: 0; top: auto; z-index: 20;
        width: 100%; height: 50%; max-width: none;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5); border-top: 1px solid var(--border);
        border-left: none; border-radius: 12px 12px 0 0;
    }
    .editor-topbar { padding: 0 8px; }
    .topbar-right { gap: 4px; }
}
