:root { color-scheme: dark; font: 15px/1.5 system-ui, sans-serif; color: #e7e9ed; background: #1f2329; --field: #171a1f; --surface: #282d35; --muted: #aeb4be; --border: #76808e; --accent: #4da3ff; }
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 19px; margin-top: 0; } h3 { font-size: 15px; }
p { margin: .6rem 0 1rem; } .muted { color: var(--muted); }
a { color: #80baff; } code, pre, textarea { font-family: ui-monospace, monospace; }
button, input, textarea { font: inherit; }
button { background: var(--surface); color: #e7e9ed; border: 1px solid var(--border); border-radius: 5px; padding: 7px 12px; cursor: pointer; }
button:hover:not(:disabled), button[aria-pressed="true"], button[aria-selected="true"] { background: #243d58; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 1; color: var(--muted); cursor: default; background: #22262d; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #75b8ff; }
input, textarea { background: var(--field); color: #e7e9ed; border: 1px solid var(--border); border-radius: 4px; padding: 8px; min-width: 0; }
::selection { background: #4da3ff; color: #111; }
.article-source textarea.drop-target { outline: 2px solid var(--accent); background: #243d58; }
dialog { color: #e7e9ed; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; max-width: min(540px, 95vw); width: 100%; }
dialog::backdrop { background: #0009; }
#settingsPanel:not([hidden]) { display: grid; grid-template-columns: clamp(230px, 32%, 320px) minmax(0, 1fr); gap: 14px; align-items: start; }
.project-sidebar, #nativeProjectSettings { min-width: 0; }
.project-sidebar { font-size: 13px; border-right: 1px solid var(--border); padding-right: 12px; overflow-wrap: anywhere; }
.project-sidebar .path-row { flex-direction: column; }
.project-sidebar input:not([type="checkbox"]):not([type="color"]) { width: 100%; }
.project-sidebar button { padding: 5px 8px; }
.project-sidebar .settings-fields { padding: 8px; }
.project-sidebar h2 { font-size: 17px; }
.article-heading { display: flex; gap: 10px; align-items: baseline; min-width: 0; margin-bottom: 8px; }
.article-heading h3 { flex: 0 1 auto; max-width: 40%; margin: 0; }
.article-heading .path { flex: 1; margin: 0; font-size: 12px; }
.article-heading > * { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-title-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: center; }
.article-title-row label { margin: 0; }
.article-title-row input { width: 100%; }
.app-header { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.app-header .tabs { flex-shrink: 0; padding: 0; border: 0; }.app-header .tabs button { border: 1px solid var(--border); border-radius: 4px; padding: 7px 10px; }
#status { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; line-height: 1.35; }
#status.error { color: #ffb4aa; }
#workspace { display: flex; flex: 1; min-height: 0; }
#editor-pane { flex: 1 1 0; overflow: hidden; min-width: 0; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border); }
.tabs button { padding: 9px 18px; border-radius: 5px 5px 0 0; border-bottom: 0; }
.panel { padding: 20px; overflow: auto; min-height: 0; }
#settingsPanel, #articlesPanel { padding-top: 0; }
label { display: block; margin-bottom: 5px; }.path-row { display: flex; gap: 8px; }.path-row input { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
#project-info { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.path { overflow-wrap: anywhere; color: var(--muted); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--field); padding: 12px; border-radius: 5px; max-height: 60vh; overflow: auto; }
ul { padding-left: 20px; }li { margin: 5px 0; } .error-item { color: #ffb4aa; } .warning-item { color: #e6ca86; }
.browse-layout { display: grid; grid-template-columns: clamp(145px, 20%, 205px) minmax(0, 1fr); gap: 12px; align-items: start; min-width: 0; }
.article-source, .article-navigation { min-width: 0; }
.article-navigation { border: 1px solid var(--border); background: var(--field); }
.article-source > .actions { flex-wrap: wrap; }
.tree details { margin: 8px 0; }.tree details details { margin-left: 14px; }.tree summary { cursor: pointer; padding: 4px; }
.tree .page-button { margin: 4px 0 6px 14px; }.artworks { list-style: none; padding-left: 12px; }
.artwork-button { width: 100%; text-align: left; display: flex; align-items: center; gap: 10px; }
.artwork-button img { width: 56px; height: 48px; object-fit: contain; background: var(--field); }
.artwork-button small { display: block; color: var(--muted); }.article-source textarea { width: 100%; min-height: 360px; resize: none; overflow-y: hidden; }
#preview-pane { flex: 1 1 0; overflow: hidden; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--field); }
.preview-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; max-width: 100%; }
.preview-controls button { padding: 7px 9px; }
#previewStatus { padding: 20px; white-space: pre-wrap; }#previewFrame { width: 100%; flex: 1; border: 0; background: #181b1c; min-height: 240px; }


footer { font-size: 12px; color: var(--muted); padding: 6px 20px; border-top: 1px solid var(--border); }
select { font: inherit; color: #e7e9ed; background: var(--field); border: 1px solid var(--border); padding: 7px; border-radius: 4px; max-width: 100%; }
.project-settings-group { margin: 12px 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.project-settings-group summary { font-weight: 600; cursor: pointer; padding: 7px 10px; background: #303a46; }
.project-settings-group[open] summary { border-bottom: 1px solid var(--border); }
.project-module-body > h3, .project-module-body > .settings-row, .project-module-body > button, .project-module-body > div:not(.settings-table) { margin: 8px; }
.settings-table { table-layout: fixed; border-collapse: collapse; width: 100%; font-size: 14px; }
.settings-table th, .settings-table td { padding: 5px 9px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.settings-table tr:last-child > * { border-bottom: 0; }
.settings-table th { width: 38%; text-align: left; font-weight: 400; background: var(--surface); border-right: 1px solid var(--border); overflow-wrap: anywhere; }
.settings-table label { margin: 0; }
.settings-table td { background: var(--field); }
.settings-table input:not([type="checkbox"]), .settings-table select { padding: 5px 7px; }
.settings-table textarea { width: 100%; min-height: 72px; }
.settings-fields { display: grid; gap: 7px; margin-top: 12px; }
.settings-fields label { margin: 7px 0 0; }.settings-fields > input:not([type="checkbox"]), .settings-fields textarea { width: 100%; }
.settings-fields textarea { min-height: 80px; }.settings-fields input[type="checkbox"] { justify-self: start; }
.settings-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0; }.settings-row input { flex: 1; min-width: 120px; }
.asset-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; }.asset-field input:not([type="file"]) { flex: 1; min-width: 140px; }.asset-field select { max-width: 250px; }
.asset-field img { max-width: 120px; max-height: 80px; object-fit: contain; }
.navigation-section-setting { border: 1px solid var(--border); padding: 10px; margin: 12px 0; border-radius: 5px; }
.navigation-setting { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--border); padding: 10px 0; }.navigation-setting > input { flex: 1; min-width: 150px; }.navigation-setting .asset-field { flex-basis: 100%; }
.project-action-bar, .article-action-bar { position: sticky; top: 0; z-index: 4; background: #1f2329; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.project-save-actions, .article-save-actions { margin: 0; flex-wrap: wrap; }
#nativeSettingsNote { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.article-action-bar #markdownToolbar { margin: 4px 0 0; }
#galleryChangeList { max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
#galleryReviewPanel { border: 1px solid var(--accent); padding: 12px; margin: 12px 0; border-radius: 5px; }
#galleriesPanel:not([hidden]) { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; padding: 10px; }
.gallery-layout { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 10px; flex: 1; min-height: 0; min-width: 0; }
#galleryEditControls { overflow-y: auto; overflow-x: hidden; padding-right: 6px; font-size: 12px; }
.gallery-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.gallery-table-controls { display: grid; grid-template-columns: 1fr; gap: 5px; margin-top: 5px; }.gallery-table-controls button { padding: 5px 9px; text-align: left; }
#galleryTableWrap { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--border); background: var(--field); }
#galleryTable { table-layout: fixed; border-collapse: separate; border-spacing: 0; width: 100%; }
#galleryTable col:nth-child(1) { width: 24%; }#galleryTable col:nth-child(2) { width: 26%; }#galleryTable col:nth-child(3) { width: 9%; }#galleryTable col:nth-child(4) { width: 12%; }#galleryTable col:nth-child(5) { width: 13%; }#galleryTable col:nth-child(6) { width: 16%; }
.navigation-icon img { width: 30px; height: 24px; object-fit: contain; vertical-align: middle; }
.folder-drag-label { display: inline-block; max-width: calc(100% - 65px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.review-context { color: #929aa6; }.review-change { color: #fff; font-weight: 600; }
.article-actions { flex-direction: column; gap: 4px; margin: 0; padding: 6px; border-bottom: 1px solid var(--border); }
.article-actions button { padding: 5px 7px; font-size: 13px; text-align: left; }#projectOpen { margin-bottom: 12px; }#projectOpen > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
#galleryTable tr[data-kind="navigation"] .gallery-preview-cell { padding-left: 8px; }#galleryTable tr[data-kind="chapter"] .gallery-preview-cell { padding-left: 24px; }#galleryTable tr[data-kind="artwork"] .gallery-preview-cell { padding-left: 46px; }
#galleryTable th { position: sticky; top: 0; z-index: 3; text-align: left; background: var(--surface); padding: 6px 12px; height: 44px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
#galleryTable th select { width: 100%; padding: 5px; }
.gallery-column-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; touch-action: none; z-index: 4; }
#galleryTable td { position: relative; height: 34px; padding: 1px 7px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
#galleryTable .folder-table-row td { background: var(--surface); font-weight: 600; }
#galleryTable .active-row td { background: #243d58; }#galleryTable .pending-row td[data-field] { color: #f0d598; }
#galleryTable .gallery-preview-cell { cursor: grab; touch-action: none; user-select: none; }
#galleryTable .gallery-preview-cell .artwork-button { height: 32px; padding: 0 5px; width: 100%; border-color: transparent; }
#galleryTable .artwork-button img { width: 36px; height: 29px; }.active-label { font-size: 11px; color: #b6d8ff; }
.image-placeholder { display: inline-block; max-width: 100%; font-size: 11px; color: var(--muted); white-space: normal; vertical-align: middle; }
.folder-toggle, .navigation-icon { padding: 4px 6px; margin-right: 5px; }.folder-drag-label { cursor: pointer; }
#galleryTable td.editing { overflow: visible; z-index: 5; padding: 0; }
#galleryTable td input, #galleryTable td textarea { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 34px; border: 2px solid var(--accent); border-radius: 0; padding: 8px; }
#galleryTable td textarea { height: 110px; resize: vertical; }
[hidden] { display: none !important; }
@media (max-width: 850px) { .app-header { flex-wrap: wrap; } }

/* Phase 12: readable action rail and explicit section nesting. */
.gallery-table-controls button { font-size: 13px; }
.navigation-section-setting { margin: 24px 0; border: 2px solid #536174; background: #202832; padding: 14px; }
.navigation-section-setting > .navigation-setting { margin-left: 24px; padding-left: 12px; border-left: 2px solid #45566c; }
.article-navigation-icon { width: 28px; height: 24px; object-fit: contain; vertical-align: middle; margin-right: 8px; }
.help-logo { width: 38px; height: 38px; vertical-align: middle; }
#help-dialog { max-width: 850px; max-height: 85vh; overflow-y: auto; }
#help-dialog details { margin: 18px 0; line-height: 1.6; }

#public-build-status { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto; font-size: 13px; }

dialog:not(#help-dialog):not(#nativeHelpDialog)::before { content: ""; display: block; width: 30px; height: 30px; background: url("/favicon.png") center / contain no-repeat; margin-bottom: 10px; }
#gwg-confirm-message { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 55vh; overflow-y: auto; }

#markdownToolbar { flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.article-chapter-row { display: flex; align-items: stretch; min-width: 0; border-top: 1px solid var(--border); }
#nativeArticleTree details { margin: 0; }
#nativeArticleTree summary { display: list-item; padding: 6px; background: #303a46; border-top: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
#nativeArticleTree .page-button { margin: 0; border: 0; border-radius: 0; padding: 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
#nativeArticleTree > .page-button { width: 100%; border-bottom: 1px solid var(--border); }
.article-chapter-row .page-button { flex: 1; min-width: 0; }
.article-chapter-row > .article-drag { flex: 0 0 27px; padding: 3px; border: 0; border-right: 1px solid var(--border); border-radius: 0; cursor: grab; }
.article-chapter-row > .article-drag:active { cursor: grabbing; }
#nativeArticleTree .article-navigation-icon { width: 22px; height: 22px; margin-right: 4px; }

#preview-start-log { margin: 8px 12px; } #preview-start-output { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow-y: auto; font-size: 12px; } #cancel-preview-start { padding: 2px 6px; font-size: 11px; white-space: nowrap; }

/* Compact, persistent status and desktop-style Project arrangement. */
.header-status { flex: 1 1 120px; min-width: 0; align-self: center; }
.header-job { display: flex; align-items: center; gap: 5px; min-width: 0; }
#background-status { font-size: 12px; line-height: 1.35; color: #c2dcff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#background-status.error { color: #ffb4aa; }
.setting-control { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.setting-control > input:not([type="checkbox"]):not([type="color"]), .setting-control > select { width: min(100%, 26rem); }
.setting-field.compact-value input:not([type="checkbox"]), .setting-field.compact-value select { width: 7rem; max-width: 100%; }
.setting-control input.color-reference { width: 8rem !important; }
.setting-control input[type="color"] { width: 38px; height: 34px; padding: 3px; }
.setting-control .asset-field { flex: 1; min-width: 0; width: 100%; }
.setting-control .asset-field input:not([type="file"]) { width: 12rem; min-width: min(100%, 10rem); }
.navigation-tree-actions { flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.navigation-tree-actions button { padding: 5px 8px; font-size: 13px; }
.navigation-tree-wrap { border: 1px solid var(--border); }
.navigation-tree { table-layout: fixed; border-collapse: separate; border-spacing: 0; width: 100%; }
.navigation-tree th { text-align: left; position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 8px; }
.navigation-tree th:first-child { width: 58%; }
.navigation-tree th:nth-child(2) { width: 84px; text-align: center; }
.navigation-tree .navigation-title-visibility { text-align: center; }
.navigation-tree .navigation-title-visibility input { width: 18px; height: 18px; margin: 0; vertical-align: middle; accent-color: var(--accent); }
.navigation-tree th, .navigation-tree td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.navigation-tree td { padding: 4px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 42px; }
.navigation-tree .navigation-tree-section td { background: #303a46; border-top: 2px solid #95a0af; font-weight: 600; }
.navigation-tree .navigation-tree-navigation td:first-child { padding-left: 26px; }
.navigation-tree input { border-color: transparent; background: transparent; padding: 4px; width: calc(100% - 80px); min-width: 0; }
.navigation-tree input:focus { border-color: var(--accent); background: var(--field); }
.navigation-tree button { padding: 2px 4px; margin-right: 4px; vertical-align: middle; }
.navigation-tree-icon, .navigation-drag { width: 26px; height: 30px; }
.navigation-tree-icon img { width: 20px; height: 22px; object-fit: contain; }
.navigation-tree .navigation-path { color: var(--muted); font-size: 12px; }
.navigation-tree tr[aria-selected="true"] td { background: #294867; }
.navigation-icon-editor { margin-top: 10px; padding: 10px; border: 1px solid var(--border); background: var(--field); }
.navigation-icon-editor h3 { margin: 0 0 8px; }
.navigation-tree .navigation-drag { cursor: grab; }
@media (max-width: 750px) { .header-status { order: 3; flex-basis: 100%; }.app-header .tabs { margin-right: auto; } }

/* One persistent divider; resizing never detaches the live preview iframe. */
#workspace-divider { flex: 0 0 20px; align-self: stretch; display: flex; align-items: center; justify-content: center; cursor: col-resize; touch-action: none; user-select: none; background: #20252c; border-inline: 1px solid #424b58; position: relative; z-index: 6; }
#workspace-divider > span { width: 4px; height: 56px; border-radius: 2px; background: #8593a6; pointer-events: none; }
#workspace-divider:hover > span, #workspace-divider:focus-visible > span { background: var(--accent); }
#workspace-divider:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#workspace[data-dragging] { cursor: col-resize; user-select: none; }
#workspace[data-dragging] iframe { pointer-events: none; }
#divider-guard { position: fixed; inset: 0; z-index: 5; cursor: col-resize; touch-action: none; background: transparent; }
@media (any-pointer: coarse) { #workspace-divider { flex-basis: 24px; } }
.gallery-button-pair { display: flex; flex-wrap: wrap; gap: 4px; }
.gallery-button-pair button { flex: 1 1 auto; padding-inline: 5px; white-space: nowrap; text-align: center; }
.article-source textarea { overflow-y: hidden; resize: none; }

.preview-controls button { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.article-source h3 { overflow-wrap: anywhere; }

/* Subtle action families retain neutral disabled states and readable text. */
.gallery-visibility-action:not(:disabled) { background: #25382e; border-color: #61826b; color: #d6eadb; }
.gallery-visibility-action:hover:not(:disabled) { background: #314b3c; }
.gallery-selection-action:not(:disabled) { background: #402d3b; border-color: #98738b; color: #f1d3e8; }
.gallery-selection-action:hover:not(:disabled), .gallery-selection-action[aria-pressed="true"]:not(:disabled) { background: #594052; }
#project-section-title { width: 100%; }
#project-section-error { color: #ffb4aa; }

#project-section-error:empty { display: none; }

.project-sidebar .setting-control > input:not([type="checkbox"]), .project-sidebar .setting-control > select { max-width: 100%; }
.project-sidebar .asset-field { width: 100%; }
.project-sidebar .asset-field select { width: 100%; max-width: 100%; min-width: 0; }
.project-sidebar .settings-row input { min-width: 0; width: 100%; flex-basis: 100%; }
.project-sidebar .settings-table th { width: 44%; padding-inline: 5px; }
.project-sidebar .settings-table td { padding-inline: 5px; }
.project-sidebar textarea.growing-field, .navigation-icon-editor textarea.growing-field { width: 100%; min-height: 0; resize: none; overflow: hidden; overflow-wrap: anywhere; padding: 5px 7px; line-height: 1.5; }
.asset-field textarea.growing-field { flex: 1 0 100%; }
.project-sidebar .settings-row textarea.growing-field { flex: 1 0 100%; }

#galleryTableWrap { overflow-anchor: none; }

#nativeProjectSettings { align-self: stretch; }

.app-header { flex-shrink: 0; }
.preview-tools-row { display: flex; align-items: flex-start; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.preview-tools-row #preview-start-log { flex: 1; min-width: 0; margin: 0; font-size: 12px; }
.preview-tools-row summary { cursor: pointer; padding: 3px 0; }
.preview-tools-row .preview-controls { flex-shrink: 0; }
.preview-tools-row button { font-size: 11px; padding: 3px 6px; }
#article-url-error { color: #ffb4aa; }
#article-url-error:empty { display: none; }

.app-header > .preview-tools-row { margin-left: auto; padding: 0; border: 0; flex-shrink: 0; position: relative; }
.app-header #preview-start-log { flex: 0 1 auto; }
.app-header #preview-start-log[open] > pre { position: absolute; z-index: 10; top: 100%; right: 0; width: min(600px,calc(100vw - 32px)); max-height: 240px; border: 1px solid var(--border); box-shadow: 0 6px 18px #0008; }
#galleryTable td.batch-editing { background: #25445b; box-shadow: inset 0 0 0 1px #8ebfe0; }

.help-credit { margin: 1.25rem 0 .75rem; padding-top: .75rem; border-top: 1px solid currentColor; font-size: .85em; opacity: .8; }
