/* ============================================================
   Oyster editor — IDE-style shell
   tokens → app shell → screens → workspace → components
   ============================================================ */

:root{
    /* palette (light) */
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #fafafb;
    --surface-3: #eef0f3;
    --ink: #1c2130;
    --ink-soft: #5a6272;
    --ink-faint: #9298a5;
    --line: #e2e5ea;
    --line-strong: #c9ced8;
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.12);
    --accent-line: rgba(124, 58, 237, 0.45);
    --danger: #d92b2b;
    --danger-soft: rgba(217, 43, 43, 0.12);
    --ok: #157a4e;

    /* geometry */
    --radius: 6px;
    --radius-lg: 10px;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --shadow: 0 4px 16px rgba(20, 24, 40, 0.08);
    --shadow-lg: 0 12px 40px rgba(20, 24, 40, 0.18);

    font-size: 14px;
}

html, body{
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.hidden{
    display: none !important;
}

/* ---------- app shell ---------- */

#app{
    height: 100%;
    display: flex;
    flex-direction: column;
}

#topBar{
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    height: 44px;
    padding: 0 var(--sp-4);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

#brand{
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--accent);
}

#siteName{
    color: var(--ink-soft);
    font-size: .95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dashboardActions{
    margin-left: auto;
    display: flex;
    flex-direction: row;
    gap: var(--sp-2);
}

/* top-bar extras only make sense inside a site */
body:not([data-screen="2"]) #siteName,
body:not([data-screen="2"]) #dashboardActions{
    display: none;
}

#screenManager{
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

#statusBar{
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    height: 26px;
    padding: 0 var(--sp-4);
    background: var(--surface);
    border-top: 1px solid var(--line);
    font-size: .8em;
    color: var(--ink-faint);
}

#statusHint{
    margin-left: auto;
    white-space: nowrap;
}

#toast{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ok);
}

/* ---------- screens ---------- */

#screenManager > div{
    display: flex;
    flex-direction: column;
    align-items: center;
}

.centerView{
    justify-content: center;
    width: min(26em, 90%);
    height: fit-content;
    margin: auto;
    padding: var(--sp-5);
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    gap: var(--sp-3);
}

.centerView h1, .centerView h2{
    margin: 0;
    padding: 0;
    border: none;
    color: var(--ink);
    text-align: center;
}

.wordmark{
    font-size: 2em;
    letter-spacing: .01em;
    color: var(--ink);
}

#sitesScreen h1{
    font-size: 1.3em;
}

#siteCarousel{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-3);
    justify-content: center;
}

/* the workspace screen is the IDE proper */
/* (needs to out-rank `#screenManager > div` above, hence the longer selector) */
#screenManager > #workspaceScreen{
    flex: 1;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    justify-content: flex-start;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-width: 0;
    min-height: 0;
    position: relative;
}

/* ---------- workspace shell ---------- */

#pagePane{
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    width: 18em;
    min-width: 14em;
    gap: var(--sp-2);
    padding: var(--sp-2);
    text-align: left;
    overflow-y: auto;
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    box-sizing: border-box;
}

#pageDetail{
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3);
    text-align: left;
    overflow: hidden;
    box-sizing: border-box;
}

/* ---------- controls ---------- */

button{
    margin: 0;
    padding: 6px 12px;
    font-size: .9em;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

button:hover{
    background: var(--surface-3);
    border-color: var(--line-strong);
    color: var(--ink);
}

button:focus-visible{
    outline: 2px solid var(--accent-line);
    outline-offset: 1px;
}

#dashboardActions button{
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

#dashboardActions button:hover{
    background: #6d28d9;
    border-color: #6d28d9;
    color: #fff;
}

#brand{
    cursor: pointer;
}

#brand:hover{
    color: var(--ink);
}

#brand:focus-visible,
#shareButton:focus-visible{
    outline: 2px solid var(--accent-line);
    outline-offset: 2px;
}

#dashboardActions{
    align-items: center;
}

#shareButton{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: var(--ink-soft);
    border-radius: var(--radius);
    transition: color .12s, background .12s;
}

#shareButton:hover{
    color: var(--accent);
    background: var(--accent-soft);
}

.smallButton{
    padding: 4px 10px;
    font-size: .8em;
}

.smallButton.on{
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

.miniButton{
    margin: 0;
    padding: 2px 8px;
    font-size: .7em;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
}

.miniButton:hover{
    background: var(--accent-soft);
    color: var(--accent);
}

input, select{
    padding: 5px 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: .9em;
    font-family: inherit;
    max-width: 100%;
    box-sizing: border-box;
}

input:focus, select:focus{
    outline: none;
    border-color: var(--accent-line);
}

.renameInput{
    border-color: var(--accent-line);
    font-size: 1em;
}

/* ---------- sites screen ---------- */

.siteListing{
    height: 5em;
    width: 8em;
    background: var(--surface-3);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    padding: var(--sp-2);
    box-sizing: border-box;
    transition: border-color .15s, background-color .15s;
}

.siteListing:hover{
    cursor: pointer;
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.siteListing > div{
    flex-grow: 1;
}

.siteListing > span{
    flex-grow: 0;
    flex-shrink: 1;
    text-align: left;
    color: var(--ink);
    font-weight: 600;
    padding: var(--sp-1) var(--sp-1) 0;
}

/* ---------- pages pane ---------- */

#paneTabs{
    display: flex;
    gap: var(--sp-1);
}

.paneTab{
    flex: 1;
    padding: 4px 6px;
    font-size: .8em;
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}

.paneTab:hover{
    color: var(--ink);
    background: var(--surface-3);
}

.paneTab.active{
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

.paneView{
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    flex: 1;
    min-height: 0;
}

#filesPaneView{
    overflow: hidden;
}

#pageList{
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.pageGroup{
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.pageGroupHeader{
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px 6px;
    border-radius: var(--radius);
    font-size: .8em;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}

.pageGroupHeader:hover{
    background: var(--surface-3);
    color: var(--ink);
}

.groupArrow{
    width: 1em;
    flex-shrink: 0;
    font-size: .8em;
}

.groupName{
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.groupCount{
    margin-left: auto;
    font-size: .85em;
    color: var(--ink-faint);
}

.pageEntry{
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 2px var(--sp-1);
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: var(--radius);
    padding: 8px 10px;
    min-height: 2.3em;
    box-sizing: border-box;
    cursor: pointer;
    position: relative;
    transition: border-color .15s, background-color .15s;
}

.pageEntry .pageName{
    grid-column: 1;
    grid-row: 1;
}

.pageEntry .pageMeta{
    grid-column: 1;
    grid-row: 2;
}

.pageEntry .renderBadge,
.pageEntry .shellBadge{
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

.pageMenuButton{
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
    padding: 2px 6px;
    font-size: .9em;
    line-height: 1.2;
    background: transparent;
    border-color: transparent;
    color: var(--ink-faint);
}

.pageMenuButton:hover{
    background: var(--surface-3);
    color: var(--ink);
}

.pageMenu{
    position: absolute;
    top: calc(100% - 2px);
    right: 4px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 7em;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pageMenuDelete{
    margin: 0;
    padding: 5px 8px;
    font-size: .8em;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--danger);
}

.pageMenuDelete:hover{
    background: var(--danger-soft);
    color: var(--danger);
}

.pageEntry:active{
    cursor: grabbing;
}

.pageEntry.dragging{
    opacity: .45;
}

.pageEntry.dropAbove{
    box-shadow: 0 -2px 0 0 var(--accent);
}

.pageEntry:hover{
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.pageEntry.selected{
    border-color: var(--accent);
    background: var(--accent-soft);
}

.pageName{
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pageMeta{
    font-size: .8em;
    color: var(--ink-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shellBadge{
    font-size: .7em;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-soft);
    flex-shrink: 0;
}

.renderBadge{
    font-size: .7em;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
}

#newPageForm{
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--sp-2);
}

#pagePaneActions{
    display: flex;
    flex-direction: row;
    gap: var(--sp-1);
    margin-top: auto;
}

#pagePaneActions button{
    flex: 1;
    padding: 4px 6px;
    font-size: .8em;
}

/* ---------- detail / main area ---------- */

#detailHeader{
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    flex-shrink: 0;
}

#detailHeader .smallButton{
    margin-left: auto;
}

.detailTitle{
    font-size: 1.2em;
    font-weight: 700;
    cursor: pointer;
}

.detailTitle:hover{
    color: var(--accent);
}

.headerSlug{
    cursor: pointer;
}

.headerSlug:hover{
    color: var(--accent);
}

#previewWrap{
    flex: 1 1 0;
    min-height: 0;
    display: flex;
}

#previewFrame{
    flex: 1;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

#previewEmpty{
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--sp-5);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink-faint);
}

#detailScroll{
    flex: none;
    height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--line);
}

.layersHeading{
    margin: 0;
    font-size: .8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
}

.layerSummary{
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

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

.layerLine{
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.layerLine:hover, .layerLine.open{
    border-color: var(--accent-line);
    background: var(--accent-soft);
}

.layerLine .pageMeta{
    flex: 1;
}

.layerLine.self .pageName{
    color: var(--accent);
}

.layerToggle{
    color: var(--accent);
    font-size: .8em;
    font-weight: 700;
    white-space: nowrap;
}

.layerEdit{
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
    margin: var(--sp-1) 0 var(--sp-2) 1em;
    padding: var(--sp-2) var(--sp-3);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.layerEditRow{
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.layerEditRow select{
    max-width: 14em;
}

.dataRow{
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    align-self: stretch;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 10px;
    transition: border-color .15s;
}

.dataRow:hover{
    border-color: var(--accent-line);
}

.dataRow .pageName{
    cursor: pointer;
}

.dataRow .pageName:hover{
    color: var(--accent);
}

.dataRow select,
.dataRow input[type='text'],
.dataRow .smallButton{
    padding: 3px 8px;
    font-size: .8em;
}

.dataRow select,
.dataRow input[type='text']{
    max-width: 8em;
}

.dataAsWrap{
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.dataAsWrap .pageMeta{
    font-size: .75em;
}

.dataRowActions{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.dataRowActions .smallButton,
.dataRowActions .xButton{
    margin-left: var(--sp-1);
}

.pageActions{
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    padding-top: var(--sp-2);
}

.pageLink{
    color: var(--accent);
    text-decoration: none;
    font-size: .8em;
    white-space: nowrap;
}

.pageLink:hover{
    text-decoration: underline;
}

/* ---------- file viewer (main-area tab) ---------- */

#fileViewer{
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-3);
    box-sizing: border-box;
    overflow: hidden;
}

#fileViewerBar{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
}

#fileEditorTitle{
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#fileViewerButtons{
    display: flex;
    flex-direction: row;
    gap: var(--sp-1);
    flex-shrink: 0;
}

#editorHost{
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
}

#fileViewerBody{
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    gap: var(--sp-2);
    align-items: stretch;
    overflow: hidden;
}

#viewerPreview{
    width: 44%;
    min-width: 14em;
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

#viewerPreview iframe{
    flex: 1;
    border: none;
}

#fileSaveBtn{
    align-self: flex-start;
    flex-shrink: 0;
    font-size: .9em;
    margin: 0;
}

/* ---------- file explorer ---------- */

#explorerActions{
    display: flex;
    gap: var(--sp-1);
    align-items: center;
}

#explorerActions > button{
    padding: 3px 10px;
    font-size: .85em;
}

#explorerMenu{
    display: flex;
    gap: var(--sp-1);
}

#explorerMenu button, #newEntryRow button{
    padding: 3px 8px;
    font-size: .75em;
}

#newEntryRow{
    display: flex;
    gap: var(--sp-1);
    align-items: center;
}

#newEntryRow input{
    flex: 1;
    min-width: 0;
    font-size: .8em;
}

#rootTabs{
    display: flex;
    gap: var(--sp-1);
}

.rootTab{
    flex: 1;
    padding: 3px 4px;
    font-size: .75em;
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}

.rootTab:hover{
    color: var(--ink);
    background: var(--surface-3);
}

.rootTab.active{
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

#explorerCrumbs{
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: .8em;
    flex-wrap: wrap;
    min-height: 1.4em;
}

.crumb{
    cursor: pointer;
    color: var(--ink-soft);
}

.crumb:hover{
    color: var(--accent);
}

.crumb.here{
    cursor: default;
    color: var(--ink);
    font-weight: 700;
}

.crumbSep{
    opacity: .4;
}

#fileTree{
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: stretch;
}

.treeEmpty{
    padding: var(--sp-3) var(--sp-2);
    font-size: .8em;
    color: var(--ink-faint);
}

.treeRow{
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
}

.treeRow:hover{
    background: var(--accent-soft);
}

.treeArrow{
    width: 1em;
    color: var(--ink-faint);
    font-size: .75em;
    flex-shrink: 0;
}

.treeIcon{
    font-size: .85em;
    flex-shrink: 0;
}

.treeLabel{
    flex: 1;
    font-size: .85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.treeSize{
    font-size: .7em;
    color: var(--ink-faint);
    visibility: hidden;
}

.treeRow:hover .treeSize{
    visibility: visible;
}

.treeDelete{
    visibility: hidden;
}

.treeRow:hover .treeDelete{
    visibility: visible;
}

/* ---------- file columns ---------- */

.fileTag{
    margin: 0 0 0 .2em;
    padding: 0 6px;
    font-size: .75em;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
}

.fileTag.on{
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

.fileCellWrap{
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.fileCell .fileCellWrap{
    cursor: pointer;
}

.fileCell:hover{
    outline: 1px solid var(--accent-line);
    border-radius: 2px;
}

.cellThumb{
    max-width: 100%;
    max-height: 4.5em;
    border-radius: var(--radius);
    display: block;
}

.cellFileName{
    font-size: .85em;
    word-break: break-all;
    padding: var(--sp-1) 0;
}

.cellChoose{
    font-size: .8em;
    color: var(--ink-faint);
    padding: var(--sp-1) 0;
}

.cellLocate{
    outline: 2px solid var(--accent) !important;
    border-radius: 2px;
}

.cellClear{
    align-self: flex-start;
    visibility: hidden;
    color: var(--ink-faint);
}

.fileCellWrap:hover .cellClear{
    visibility: visible;
}

.cellClear:hover{
    color: var(--danger) !important;
}

/* ---------- data grid ---------- */

.gridTable{
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

.gridTable th, .gridTable td{
    border: 1px solid var(--line);
    padding: 4px 6px;
    vertical-align: top;
    text-align: left;
}

.gridTable th{
    background: var(--surface-3);
    font-size: .8em;
    color: var(--ink-soft);
}

.colHead{
    word-break: break-all;
}

.colName{
    cursor: pointer;
    font-weight: 700;
    margin-right: .4em;
}

.colName:hover{
    color: var(--accent);
}

.rowNumCell{
    width: 2.6em;
    text-align: right;
    color: var(--ink-faint);
    font-size: .75em;
}

.delCell{
    width: 2.2em;
    text-align: center;
}

.addColCell{
    width: 6em;
}

.gridCell{
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: .9em;
    padding: 0;
    resize: none;
    overflow: hidden;
    min-height: 1.4em;
}

.gridCell:focus{
    outline: 1px solid var(--accent-line);
    border-radius: 2px;
}

.newRowCell{
    text-align: center;
}

.xButton{
    margin: 0;
    padding: 0 4px;
    font-size: .9em;
    background: transparent;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    border-radius: var(--radius);
}

.xButton:hover{
    color: var(--danger);
    background: transparent;
}

.armed{
    color: var(--danger) !important;
}

.gridEmptyMsg{
    padding: var(--sp-4);
    color: var(--ink-faint);
    text-align: center;
}

/* ---------- file picker overlay + image preview ---------- */

#pickerBackdrop{
    position: absolute;
    inset: 0;
    background: rgba(20, 24, 40, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 19;
}

#pickerOverlay{
    width: min(34em, 85%);
    max-height: 75%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 20;
    overflow: hidden;
}

.pickerBar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line);
}

.pickerSource{
    margin: 0;
    padding: 3px 10px;
    font-size: .8em;
    background: transparent;
    color: var(--ink-soft);
}

.pickerSource.on{
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}

#pickerCrumbs{
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    font-size: .85em;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
}

#pickerSearch{
    flex: 1;
    min-width: 7em;
    font-size: .85em;
}

.pickerBar button{
    margin: 0;
    padding: 3px 8px;
    font-size: .8em;
}

.pickerTypeRow{
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line);
}

.pickerTypeRow .renameInput{
    width: 100%;
    box-sizing: border-box;
    font-size: .9em;
}

.pickerList{
    overflow-y: auto;
}

.pickerRow{
    padding: 5px var(--sp-3);
    font-size: .85em;
    cursor: pointer;
}

.pickerRow:hover{
    background: var(--accent-soft);
}

.imagePreview{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5);
}

.imagePreview img{
    max-width: 90%;
    max-height: 60vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---------- highlighted code editor ---------- */
/* NOTE: keep the monospace metrics identical — the highlight overlay
   (codeUnder) must line up with the transparent textarea (codeInput). */

.codeEditor{
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.codeGutter{
    width: 3em;
    flex-shrink: 0;
    overflow: hidden;
    padding: 1em 0;
    text-align: right;
    white-space: pre;
    color: var(--ink-faint);
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    font: 13px/1.45 'Courier New', Courier, monospace;
}

.codeScroll{
    position: relative;
    flex: 1;
    overflow: hidden;
}

.codeUnder{
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 1em;
    white-space: pre;
    color: var(--ink);
    font: 13px/1.45 'Courier New', Courier, monospace;
    pointer-events: none;
}

.codeInput{
    position: absolute;
    inset: 0;
    width: 100%;
    margin: 0;
    padding: 1em 1em 2.5em;
    border: none;
    background: transparent;
    color: transparent;
    caret-color: var(--ink);
    white-space: pre;
    font: 13px/1.45 'Courier New', Courier, monospace;
    resize: none;
    overflow: auto;
}

.codeInput::selection{
    background: rgba(124, 58, 237, 0.25);
}

.codeErrorStrip{
    position: absolute;
    left: 0;
    right: 0;
    background: var(--danger-soft);
    border-top: 1px solid rgba(200, 0, 0, 0.5);
    border-bottom: 1px solid rgba(200, 0, 0, 0.5);
    pointer-events: none;
}

.codeLineFlash{
    position: absolute;
    left: 0;
    right: 0;
    background: var(--accent-soft);
    border-top: 1px solid var(--accent-line);
    border-bottom: 1px solid var(--accent-line);
    pointer-events: none;
    z-index: 2;
}

/* ---------- inline text modal ---------- */

#textEditBackdrop{
    position: absolute;
    inset: 0;
    background: rgba(20, 24, 40, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-3);
    z-index: 30;
}

#textEditModal{
    width: min(84em, 96%);
    height: min(97%, fit-content);
    min-height: 60%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.textEditBar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line);
    font-size: .85em;
    color: var(--ink-soft);
}

.textEditTitle{
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    min-width: 0;
}

.textEditButtons{
    display: flex;
    gap: var(--sp-1);
    flex-shrink: 0;
}

#textEditArea{
    flex: 1;
    min-height: 10em;
    border: none;
    padding: var(--sp-3);
    background: var(--surface);
    color: var(--ink);
    font: 13px/1.45 'Courier New', Courier, monospace;
    white-space: pre;
    overflow: auto;
    outline: none;
    resize: none;
}

.hljTag{
    color: #1c4f9c;
    font-weight: bold;
}

.hljString{
    color: #a33535;
}

.hljBlock{
    color: #7a2ea6;
    font-weight: bold;
}

.hljExpr{
    color: #0a7a5c;
    font-weight: bold;
}

.hljComment{
    color: var(--ink-faint);
    font-style: italic;
}

/* ---------- autocomplete dropdown ---------- */

.autoComplete{
    position: absolute;
    min-width: 16em;
    max-width: 26em;
    max-height: 14em;
    overflow-y: auto;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 25;
    font-size: .85em;
}

.acItem{
    padding: 4px 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-2);
}

.acItem.sel, .acItem:hover{
    background: var(--accent-soft);
}

.acHint{
    opacity: .55;
    font-size: .85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 12em;
}

/* ============================================================
   publish + domains modal
   ============================================================ */

.modalOverlay{
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(12, 16, 30, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}

.modalPanel{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(680px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modalHeader{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--line);
}

.modalHeader h2{
    margin: 0;
    font-size: 1.1em;
}

.modalBody{
    padding: var(--sp-5);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.publishSection{
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.publishSection h3{
    margin: 0;
    font-size: .95em;
}

.publishRow{
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.publishRow input{
    flex: 1;
    min-width: 220px;
}

.domainRow{
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--line);
}

.domainRow:last-child{
    border-bottom: none;
}

.domainRow .domainName{
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9em;
}

.statusBadge{
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .75em;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-3);
    color: var(--ink-soft);
}

.statusBadge.active{
    background: rgba(21, 122, 78, .12);
    color: var(--ok);
}

.statusBadge.failed{
    background: var(--danger-soft);
    color: var(--danger);
}

.publishHint{
    font-size: .85em;
    color: var(--ink-soft);
    line-height: 1.55;
    margin: 0;
}

.publishHint code{
    background: var(--surface-3);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.publishHint ol{
    margin: var(--sp-2) 0 0;
    padding-left: 1.3em;
}

.publishHint li{
    margin-bottom: var(--sp-1);
}

.publishTarget{
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .85em;
    word-break: break-all;
    background: var(--surface-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
}

.historyRow{
    display: flex;
    justify-content: space-between;
    font-size: .85em;
    color: var(--ink-soft);
    padding: var(--sp-1) 0;
}

/* ============================================================
   auth + sharing
   ============================================================ */

#authOverlay{
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
}

.authPanel{
    width: min(380px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.authPanel .wordmark{
    margin: 0;
    text-align: center;
}

.authPanel input{
    width: 100%;
}

.authPanel .publishRow{
    justify-content: flex-end;
}

#siteCarousel .siteListing span + span{
    flex: 0 0 auto;
}

/* ============================================================
   loading states
   ============================================================ */

@keyframes oyster-shimmer{
    from{ background-position: 200% 0; }
    to{ background-position: -200% 0; }
}

.editorSkeleton,
.panelSkeleton{
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-3) 0;
}

.editorSkeleton i,
.pageSkeleton,
.panelSkeleton i{
    display: block;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%;
    animation: oyster-shimmer 1.3s linear infinite;
}

.editorSkeleton i:nth-child(1){ width: 62%; }
.editorSkeleton i:nth-child(2){ width: 88%; }
.editorSkeleton i:nth-child(3){ width: 74%; }
.editorSkeleton i:nth-child(4){ width: 95%; }
.editorSkeleton i:nth-child(5){ width: 55%; }
.editorSkeleton i:nth-child(6){ width: 82%; }
.editorSkeleton i:nth-child(7){ width: 68%; }
.editorSkeleton i:nth-child(8){ width: 90%; }

.pageSkeleton{
    height: 26px;
    margin-bottom: var(--sp-2);
}

.panelSkeleton i:nth-child(1){ width: 70%; }
.panelSkeleton i:nth-child(2){ width: 92%; }
.panelSkeleton i:nth-child(3){ width: 50%; }

.skeletonText{
    color: var(--ink-faint);
    font-style: italic;
}

.viewerClose{
    border-color: var(--accent-line);
    color: var(--accent);
    font-weight: 600;
}
