/* Shared workbench geometry and frosted glass surfaces. */
:root {
    --workspace-width: clamp(340px, 36vw, 520px);
    --shell-inset: 16px;
    --shell-gap: 14px;
    --panel-radius: 22px;
    --glass-panel: rgba(22, 23, 25, .48);
    --glass-chrome: rgba(64, 64, 66, .42);
    --glass-edge: rgba(255, 246, 232, .13);
    --glass-sheen: linear-gradient(128deg, #ffffff24 0%, #ffffff09 26%, #ffffff00 46%, #ffab5f0d 100%);
    --panel-shadow: 0 28px 65px #0006, 0 8px 18px #0004, inset 0 2px 6px #ffffff24, inset 2px 0 8px #ffffff08, inset 0 -2px 8px #ffbe7512;
    --control-shadow: 0 7px 12px #0005, inset 0 2px 5px #ffffff29, inset 0 -2px 5px #0002;
    --reply-surface: rgba(29, 30, 32, .73);
    --ambient-warm: #db854322; --ambient-pearl: #e5e7ee28;
}
html[data-theme="light"] {
    --glass-panel: rgba(255, 255, 255, .32);
    --glass-chrome: rgba(255, 255, 255, .48);
    --glass-edge: rgba(255, 255, 255, .46);
    --glass-sheen: linear-gradient(128deg, #ffffffbf 0%, #ffffff45 25%, #ffffff05 52%, #fff8ed38 100%);
    --panel-shadow: 0 28px 60px #46372924, 0 7px 16px #46372912, inset 0 2px 6px #ffffffb3, inset 2px 0 8px #ffffff70, inset 0 -2px 8px #ffffff66;
    --control-shadow: 0 7px 12px #65503a20, inset 0 2px 5px #ffffffb3, inset 0 -2px 5px #8a796412;
    --reply-surface: rgba(255, 255, 255, .64);
    --ambient-warm: #eeb48326; --ambient-pearl: #ffffffa6;
}
body.workspace-app {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
    isolation: isolate;
    background: linear-gradient(145deg, var(--ambient-pearl), transparent 65%),
                linear-gradient(325deg, var(--ambient-warm), transparent 70%), var(--bg);
}
#topbar {
    position: fixed; top: calc(12px + var(--viewport-top, 0px)); left: var(--shell-inset); right: var(--shell-inset);
    height: 54px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between;
    background: var(--glass-sheen), var(--glass-chrome); border: 1px solid var(--glass-edge); border-radius: 18px;
    backdrop-filter: blur(32px) saturate(135%); -webkit-backdrop-filter: blur(32px) saturate(135%);
    box-shadow: var(--control-shadow), 0 12px 30px #00000012; z-index: 20;
}
.platform-wordmark { font-size: 15px; font-weight: 700; letter-spacing: -.5px; margin-right: 12px; white-space: nowrap; }
.platform-wordmark > span { font-size: 8px; font-weight: 600; letter-spacing: 1px; color: var(--text-muted); margin-left: 5px; vertical-align: middle; }
#project-btn { border-radius: 10px; width: 34px; height: 34px; padding: 8px; }
.pinned-project-chip { border-radius: 10px; min-height: 30px; padding-inline: 12px; }
.pinned-project-chip.active { box-shadow: inset 0 1px 0 #ffffff12; }
.topbar-avatar { border-radius: 50%; width: 28px; height: 28px; border: 2px solid var(--glass-edge); }
#workbench {
    position: fixed; top: calc(80px + var(--viewport-top, 0px)); left: var(--shell-inset); right: var(--shell-inset);
    height: calc(var(--app-height, 100dvh) - 96px - env(safe-area-inset-bottom, 0px));
    display: none; grid-template-columns: var(--workspace-width) minmax(0, 1fr); gap: var(--shell-gap);
    min-height: 0; isolation: isolate;
}
body.logged-in #workbench { display: grid; }
#workspace-column, #preview-panel {
    min-width: 0; min-height: 0; overflow: hidden; border-radius: var(--panel-radius);
    border: 1px solid var(--glass-edge); background: var(--glass-sheen), var(--glass-panel); box-shadow: var(--panel-shadow);
    backdrop-filter: blur(32px) saturate(130%); -webkit-backdrop-filter: blur(32px) saturate(130%);
}
#workspace-column { position: relative; display: flex; flex-direction: column; }
#workspace-view { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#sidebar { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; overflow: hidden; background: transparent; }
#sidebar[data-mode="prompt"] { --sidebar-accent: var(--accent); --sidebar-border: var(--border); }
.pane-heading {
    min-height: 78px; height: 78px; flex-shrink: 0; padding: 18px 22px; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); background: transparent;
}
.pane-heading h1 { font-size: 18px; font-weight: 650; color: var(--text); letter-spacing: -.5px; line-height: 1.3; }
.pane-heading p { margin-top: 4px; font-size: 11px; color: var(--text-muted); font-weight: 400; }
#editor-toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 12px 16px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); }
#editor-toolbar[hidden] { display: none; }
#chat-messages { padding: 22px; }
#chat-messages > .system-msg:only-child { margin: 24px 0; text-align: center; color: var(--text-muted); line-height: 1.8; }
#chat-messages > .chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; margin: 0; padding: 24px 12px clamp(24px, 10vh, 90px); text-align: center; }
.chat-empty h2 { color: var(--text); font-size: 21px; line-height: 1.5; font-weight: 550; letter-spacing: -.4px; }
.chat-empty p { margin-top: 12px; color: var(--text-muted); font-size: 13px; line-height: 1.9; }

#chat-input-area { padding: 12px 16px 16px; border-top: 0; background: transparent; }
#chat-input-row { align-items: flex-end; gap: 8px; padding: 8px 10px; background: var(--glass-sheen), var(--glass-chrome); border: 1px solid var(--glass-edge); border-radius: 26px; box-shadow: var(--control-shadow), 0 10px 28px #00000015; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
#chat-input-row:focus-within { border-color: var(--accent-border); box-shadow: var(--control-shadow), 0 0 0 3px var(--accent-soft), 0 0 22px var(--accent-soft); }
#chat-input { background: transparent; border: 0; border-radius: 0; position: relative; min-width: 0; padding: 6px 2px; min-height: 36px; max-height: 200px; box-shadow: none; font-size: 16px; line-height: 24px; overflow-wrap: anywhere; }
#chat-input:focus { border: 0; box-shadow: none; outline: none; }
#image-upload-btn { border: 0; background: transparent; margin: 0; width: 36px; height: 36px; border-radius: 50%; }
#chat-send, #chat-stop { display: flex; align-items: center; justify-content: center; border-radius: 50%; margin: 0; padding: 0; width: 36px; height: 36px; box-shadow: none; }
#chat-input:empty::before { position: absolute; top: 6px; left: 2px; right: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#preview-panel { position: relative; display: flex; flex-direction: column; }
#preview-status { min-width: 0; max-width: 100%; overflow-wrap: anywhere; font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
#preview-status::before { content: ''; flex-shrink: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); }
#preview-status[data-state="ready"]::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 10%, transparent); }
.preview-actions button, .preview-actions a, #preview-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 10px; font-size: 11px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.preview-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.preview-actions button, .preview-actions a { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 7px 8px; }
.preview-actions svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.preview-actions :is(button, a):hover { background: var(--hover); }
#preview-toggle { display: none; }
#preview-device-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; flex-shrink: 0; }
#preview-device-switch { display: flex; flex-shrink: 0; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
#preview-device-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 5px 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-muted); font-size: 11px; cursor: pointer; }
#preview-device-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 2px 5px #00000008; }
#preview-device-switch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
#preview-device-size { margin-right: auto; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
#preview-stage { flex: 1; min-height: 0; min-width: 0; position: relative; overflow: hidden; margin: 0 14px; border: 1px solid var(--border); border-radius: 15px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--surface-sunken) 40%, transparent); box-shadow: inset 0 1px 12px #00000004; }
#preview-device { position: relative; flex: none; overflow: hidden; background: white; }
#preview-panel[data-preview-device="phone"] #preview-device { border-radius: 16px; box-shadow: 0 0 0 1px var(--border-strong), 0 10px 30px #0002; }
#preview-frame { position: absolute; top: 0; left: 0; border: 0; background: white; transform-origin: top left; }
#preview-device[hidden], #preview-frame[hidden], #preview-empty[hidden], #preview-open[hidden] { display: none; }
#preview-empty { margin: auto; max-width: 360px; padding: 32px; text-align: center; line-height: 1.8; color: var(--text-muted); font-size: 13px; }
#preview-help { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding: 10px 16px; font-size: 10px; color: var(--text-faint); text-align: center; }
.pane-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.pane-empty-icon { display: grid; place-items: center; width: 68px; height: 68px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); margin-bottom: 24px; }
.pane-empty-icon svg { width: 30px; height: 30px; }
.pane-empty h2 { font-size: 20px; font-weight: 600; letter-spacing: -.5px; }
.pane-empty p { font-size: 13px; line-height: 1.9; color: var(--text-muted); margin-top: 10px; }
.modal { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.workspace-app .modal-content { background: var(--glass-panel); border: 1px solid var(--glass-edge); border-radius: 26px; box-shadow: 0 24px 90px #0003, inset 0 1px 0 #ffffff15; backdrop-filter: blur(40px) saturate(150%); -webkit-backdrop-filter: blur(40px) saturate(150%); }
.settings-modal-content { padding: 26px; }
.settings-modal-header { padding-bottom: 20px; }
.settings-modal-header h3 { font-size: 20px; letter-spacing: -.5px; }
.settings-system-section { margin-top: 22px; }
#research-consent-dialog { margin: auto; width: min(580px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--glass-edge); border-radius: 24px; background: var(--glass-panel); color: var(--text); box-shadow: 0 24px 90px #0005; backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px); }
#research-consent-dialog[open] { display: flex; flex-direction: column; }
#research-consent-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.research-consent-header { flex-shrink: 0; padding: 26px 28px 16px; border-bottom: 1px solid var(--border); }
.research-consent-eyebrow { color: var(--accent); font-size: 12px; margin-bottom: 8px; }
#research-consent-title { font-size: 24px; line-height: 1.4; }
#research-consent-title:focus { outline: none; }
#research-consent-status { margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.research-consent-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 28px; font-size: 14px; line-height: 1.8; }
.research-consent-body h3 { margin: 18px 0 6px; font-size: 14px; color: var(--text); }
.research-consent-body p { color: var(--text-muted); }
.research-consent-body p + p { margin-top: 8px; }
.research-consent-footer { flex-shrink: 0; padding: 18px 28px 22px; border-top: 1px solid var(--border); }
.research-consent-check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.65; cursor: pointer; }
#research-consent-checkbox { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
#research-consent-error { font-size: 13px; color: var(--danger); }
#research-consent-error:not(:empty) { margin-top: 10px; }
.research-consent-actions { display: flex; gap: 10px; margin-top: 18px; }
.research-consent-actions button { flex: 1; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; }
#research-consent-agree { background: var(--action-bg); color: var(--action-ink); border-color: transparent; }
.research-consent-actions button:disabled { opacity: .45; cursor: not-allowed; }
.research-consent-remember { margin-top: 12px; font-size: 12px; text-align: center; color: var(--text-faint); }
.workspace-app :is(button, a, input, [contenteditable]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body.embedded-preview #workbench { grid-template-columns: minmax(0, 1fr); }
body.embedded-preview #preview-panel, body.embedded-preview #preview-toggle { display: none !important; }
@media (max-width: 1100px) {
    #preview-device-size { display: none; }
}
@media (max-width: 768px) {
    #research-consent-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 20px; }
    .research-consent-header { padding: 20px 20px 14px; }
    .research-consent-body { padding: 16px 20px; }
    .research-consent-footer { padding: 14px 20px 18px; }
    .research-consent-actions button { font-size: 16px; }
    #research-consent-checkbox { font-size: 16px; }
    :root { --shell-inset: 8px; --panel-radius: 18px; --shell-gap: 0px; }
    #topbar { top: calc(8px + var(--viewport-top, 0px)); height: 48px; padding: 0 10px; border-radius: 15px; }
    .platform-wordmark { font-size: 13px; margin-right: 4px; }
    .platform-wordmark > span { display: none; }
    #project-btn { width: 30px; height: 30px; }
    #workbench { top: calc(64px + var(--viewport-top, 0px)); height: calc(var(--app-height, 100dvh) - 72px - env(safe-area-inset-bottom, 0px)); grid-template-columns: minmax(0, 1fr); }
    #preview-panel { display: none; }
    #preview-toggle { display: block; padding: 6px 8px; }
    #preview-panel { position: absolute; inset: 0; z-index: 5; }
    body.logged-in.show-preview #preview-panel { position: relative; display: flex; }
    body.show-preview #workspace-view { visibility: hidden; }
    .pane-heading { height: 72px; min-height: 72px; padding: 16px 18px; }
    #chat-messages { padding: 18px 16px; }
    #chat-input-area { padding: 8px 12px 12px; }
    #chat-input { font-size: 16px; min-height: 36px; max-height: min(200px, 35dvh); }
    #preview-device-toolbar { padding: 10px 12px; gap: 8px; }
    #preview-device-switch button { min-height: 34px; padding: 5px 10px; }
    #preview-stage { margin-inline: 8px; }
    #preview-help { padding: 8px; }
    .pane-empty { padding: 20px; }
}
@media (max-width: 370px) {
    .platform-wordmark { display: none; }
    #preview-device-switch button { gap: 4px; padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) { .workspace-app * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* Conversation attachments */
.attachment-file { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 180px; min-height: 64px; padding: 12px 28px 12px 12px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); }
.attachment-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.attachment-file small { color: var(--text-muted); font-size: 11px; }
.bubble-images a { text-decoration: none; max-width: 100%; }
.img-preview-thumb .bubble-img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
#sidebar.attachment-dragover #chat-input-area { outline: 2px dashed var(--accent); outline-offset: -4px; }
#image-upload-btn:focus-visible { outline: 2px solid var(--accent); border-radius: 6px; }

/* Warm highlights and quiet translucent cards. */
.platform-wordmark > span { color: var(--accent); }
.agent-card { background: var(--reply-surface); border: 0; border-radius: 18px; box-shadow: 0 8px 22px #0000000d; }
.agent-card-status { background: transparent; border-bottom: 0; }
.agent-card, #chat-input-row { position: relative; }
.agent-card::after {
    position: absolute; inset: 0; border-radius: inherit; padding: 1.5px;
    pointer-events: none; z-index: 1;
}
#chat-input-row::after {
    position: absolute; bottom: -1px; left: 17%; right: 17%; height: 16px;
    border-radius: 50%; pointer-events: none;
}
.chat-msg.user .bubble { background: var(--surface); border: 0; color: var(--text); border-radius: 18px 18px 5px 18px; box-shadow: none; }
#chat-send, #login-confirm, .input-dialog-ok { background: var(--action-bg); color: var(--action-ink); border-color: transparent; }
#chat-send:hover, #login-confirm:hover, .input-dialog-ok:hover { background: var(--action-hover); }
.pinned-project-chip.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.settings-theme-control button.active { box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-sm); }
#context-menu { background: var(--glass-chrome); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
@supports not (backdrop-filter: blur(1px)) {
    :root { --glass-panel: #24221f; --glass-chrome: #302d29; }
    html[data-theme="light"] { --glass-panel: #faf8f4; --glass-chrome: #fffdfa; }
}

#settings-skills-section[hidden] { display: none; }
.settings-skill-graph { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 14px; border: 1px solid var(--glass-edge); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-sm); }
.settings-skill-graph:hover { background: var(--hover-strong); border-color: var(--accent-border); }

/* Raised glass controls and a recessed preview stage. */
#project-btn, .pinned-project-chip, #preview-device-switch button[aria-pressed="true"],
.preview-actions button, .settings-skill-graph, .settings-theme-control button.active {
    background-image: linear-gradient(150deg, #ffffff16, #ffffff00 65%);
    box-shadow: var(--control-shadow);
}
#chat-send { box-shadow: 0 6px 12px #00000040, 0 0 16px var(--accent-soft), inset 0 2px 4px #ffffff59, inset 0 -2px 4px #0000001a; }
#preview-stage { box-shadow: inset 0 3px 14px #00000012, 0 1px 0 #ffffff14; }
#preview-device-switch { box-shadow: inset 0 2px 5px #00000018, 0 1px 0 #ffffff18; }
.platform-wordmark > span { text-shadow: 0 0 14px var(--accent-border); }
forme-orb { filter: drop-shadow(0 0 5px var(--accent-border)); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    #chat-send, #project-btn, .preview-actions button, .settings-skill-graph { transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease; }
    #chat-send:hover, #project-btn:hover, .preview-actions button:hover, .settings-skill-graph:hover { transform: translateY(-1px); }
    #chat-send:active, #project-btn:active, .preview-actions button:active, .settings-skill-graph:active { transform: translateY(1px); }
}

.settings-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#settings-reset-tests { color: var(--text); }
#settings-reset-tests:disabled { opacity: .55; cursor: wait; }
#settings-reset-result { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }

/* Top-level navigation and project directories share the workbench bounds. */
#primary-nav { display: flex; gap: 4px; flex-shrink: 0; }
#primary-nav button { min-height: 36px; padding: 7px 18px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-muted); font: inherit; cursor: pointer; }
#primary-nav button[aria-current="page"] { color: var(--text); background: var(--surface); border-color: var(--glass-edge); box-shadow: var(--control-shadow); }
#current-project-name { min-width: 0; max-width: 320px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-muted); font-size: 12px; margin-left: 10px; padding: 7px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer; }
#current-project-name:disabled { cursor: default; opacity: 1; }
#current-project-name.needs-profile { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); animation: profile-invite 2s ease-in-out infinite; }
@keyframes profile-invite { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { #current-project-name.needs-profile { animation: none; } }
#project-btn[hidden], #current-project-name[hidden] { display: none; }
#project-profile-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; margin: auto; padding: 28px; border: 1px solid var(--glass-edge); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: var(--panel-shadow); }
#project-profile-dialog::backdrop { background: #0006; backdrop-filter: blur(4px); }
#project-profile-form { display: flex; flex-direction: column; gap: 12px; }
#project-profile-form h2 { font-size: 20px; }
#project-profile-form p { color: var(--text-muted); font-size: 13px; line-height: 1.7; }
#project-profile-form label { font-size: 13px; margin-top: 4px; }
#project-profile-form input, #project-profile-form textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
#project-profile-form textarea { resize: vertical; }
#project-profile-form #project-profile-error { color: #c34b43; }
#project-profile-error:empty { display: none; }
.project-profile-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.project-profile-actions button { font: inherit; padding: 9px 18px; border-radius: 9px; border: 1px solid var(--border); color: var(--text); background: var(--surface-2); cursor: pointer; }
.project-profile-actions #project-profile-save { color: var(--action-ink); background: var(--action-bg); }
body.logged-in[data-page="directory"] #workbench { display: none; }
body[data-page="directory"] #preview-toggle { display: none; }
#project-directory { position: fixed; top: calc(80px + var(--viewport-top, 0px)); left: var(--shell-inset); right: var(--shell-inset); height: calc(var(--app-height, 100dvh) - 96px - env(safe-area-inset-bottom, 0px)); overflow-y: auto; padding: clamp(24px, 4vw, 60px); border: 1px solid var(--glass-edge); border-radius: var(--panel-radius); background: var(--glass-sheen), var(--glass-panel); box-shadow: var(--panel-shadow); }
#project-directory[hidden] { display: none; }
.directory-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 32px; }
#directory-eyebrow { color: var(--accent); font-size: 10px; letter-spacing: 2px; font-weight: 600; margin-bottom: 12px; }
#directory-title { font-size: clamp(26px, 3vw, 36px); font-weight: 600; letter-spacing: -1px; }
#directory-description { margin-top: 12px; font-size: 14px; color: var(--text-muted); line-height: 1.8; }
#directory-count { white-space: nowrap; color: var(--text-muted); font-size: 12px; padding-bottom: 4px; }
#directory-status { color: var(--text-muted); line-height: 1.8; }
#directory-status:empty { display: none; }
#directory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.directory-card { display: flex; flex-direction: column; text-align: left; gap: 14px; padding: 16px; min-width: 0; color: var(--text); background: var(--surface); border: 1px solid var(--glass-edge); border-radius: 18px; cursor: pointer; font: inherit; box-shadow: var(--shadow-sm); }
.directory-card:hover { border-color: var(--accent-border); background: var(--hover); }
.directory-card-cover { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 8 / 5; overflow: hidden; border-radius: 11px; background: linear-gradient(135deg, var(--accent-soft), var(--glass-chrome)); }
.directory-card-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.directory-cover-placeholder { color: var(--text-muted); font-size: 12px; letter-spacing: .5px; text-align: center; }
.directory-cover-placeholder::before { content: ''; display: block; width: 60px; height: 42px; margin: 0 auto 12px; border: 1px solid var(--accent-border); border-radius: 7px; background: linear-gradient(155deg, transparent 45%, var(--accent-soft) 45% 65%, transparent 65%), var(--glass-sheen); box-shadow: var(--shadow-sm); }
.directory-cover-placeholder[hidden] { display: none; }
.directory-card:nth-child(3n+2) .directory-card-cover { background: linear-gradient(145deg, var(--glass-chrome), var(--surface-2)); }
.directory-card:nth-child(3n) .directory-card-cover { background: linear-gradient(35deg, var(--surface-2), var(--accent-soft)); }
.directory-card strong { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.directory-card-copy { display: flex; flex-direction: column; gap: 7px; }
.directory-card-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-height: 3.4em; color: var(--text-muted); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.directory-card-author { color: var(--text-muted); font-size: 11px; overflow-wrap: anywhere; margin-top: auto; }
.directory-card-cover[data-device="phone"] img { object-fit: contain; object-position: center; }
#directory-retry { margin: 16px 0; padding: 10px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
#directory-create { margin: 0 0 22px; padding: 10px 18px; border: 1px solid var(--accent-border); border-radius: 10px; background: var(--accent-soft); color: var(--accent); font: inherit; cursor: pointer; }
#directory-create[hidden] { display: none; }
#directory-create:disabled { opacity: .5; cursor: wait; }
body.readonly-project #image-upload-btn { opacity: .4; pointer-events: none; }
#settings-col-apps[hidden] { display: none; }
.settings-body { flex-direction: column; overflow-y: auto; gap: 24px; }
.settings-body .settings-col { width: 100%; flex: none; padding: 0; max-height: none; overflow: visible; }
@media (max-width: 768px) {
    #primary-nav button { min-height: 34px; padding: 6px 12px; }
    #topbar-left { gap: 5px; }
    #current-project-name { display: block; flex: 1; max-width: 180px; margin-left: 0; padding: 7px 5px; }
    body[data-page="project"] .platform-wordmark { display: none; }
    body[data-page="project"] #topbar-left { flex: 1; min-width: 0; }
    #project-directory { top: calc(64px + var(--viewport-top, 0px)); height: calc(var(--app-height, 100dvh) - 72px - env(safe-area-inset-bottom, 0px)); padding: 24px 18px; }
    .directory-heading { margin-bottom: 24px; gap: 10px; }
    #directory-count { display: none; }
    #directory-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
    .settings-body .settings-col.active { display: block; }
    #settings-col-apps[hidden] { display: none; }
    body.logged-in.show-preview #workspace-column { display: none; }
}

/* Independent loading states for conversation history and the embedded app. */
.pane-loading { color: var(--text-muted); text-align: center; line-height: 1.8; }
.pane-loading::before {
    content: ''; display: block; width: 24px; height: 24px; margin: 0 auto 14px;
    border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
    animation: pane-loading-spin .85s linear infinite;
}
#chat-messages > .chat-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; margin: 0; padding: 24px; font-size: 13px; }
#preview-stage.frame-loading #preview-device { visibility: hidden; }
#preview-stage.frame-loading #preview-empty { position: absolute; inset: 0; z-index: 1; height: fit-content; }
@keyframes pane-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pane-loading::before { animation: none; } }
