/* Quiet surfaces, one layer per task. This final component pass deliberately
   leaves table rules, editor splits, validation and keyboard focus intact. */
:root {
 --finish-fill:color-mix(in srgb,var(--ink) 4.5%,var(--paper));
 --finish-hover:color-mix(in srgb,var(--ink) 7%,var(--paper));
 --finish-selected:color-mix(in srgb,var(--accent) 12%,var(--paper));
 --finish-shadow:0 12px 36px color-mix(in srgb,var(--ink) 8%,transparent);
}

:is(.monochrome-shell,.adm,body.admin-mode,dialog,.novels-main,.auth-premium) {
 --finish-fill:color-mix(in srgb,var(--ink) 4.5%,var(--paper));
 --finish-hover:color-mix(in srgb,var(--ink) 7%,var(--paper));
 --finish-selected:color-mix(in srgb,var(--accent) 12%,var(--paper));
}

/* Model browser: calm continuous list, selected color and a real checkmark. */
body dialog:has(.model-options) {padding:28px;border-radius:22px;box-shadow:var(--ui-elevation)}
body dialog:has(.model-options) .dialog-head {margin-bottom:24px}
body dialog .model-search {border:0;border-radius:13px;background:var(--finish-fill);min-height:48px;margin-bottom:16px}
body dialog .model-search input {border:0;background:transparent;box-shadow:none;border-radius:inherit;min-height:48px}
body dialog .model-search input:focus {box-shadow:none;border:0}
body dialog .model-cats {gap:8px;padding:0 0 16px;scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
body dialog .model-cat {min-height:38px;padding:8px 12px;border:0;border-radius:10px;background:var(--finish-fill);color:var(--muted);font-size:12px}
body dialog .model-cat:hover {background:var(--finish-hover);color:var(--ink)}
body dialog .model-cat.active {border:0;background:var(--finish-selected);color:var(--accent);font-weight:600}
body dialog .model-cat i {width:22px;height:22px;flex:none}
body dialog .model-options {gap:6px;padding:2px;scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
body dialog .model-choice {border:0;border-radius:13px;padding:0 8px 0 0;gap:6px;background:transparent;box-shadow:none}
body dialog .model-choice:hover {background:var(--finish-fill)}
body dialog .model-choice.selected {border:0;background:var(--finish-selected);box-shadow:none}
body dialog .model-choice-main {min-height:76px;padding:14px 16px;border-radius:13px;background:transparent}
body dialog .model-choice-main:hover {background:transparent}
body dialog .model-choice-main strong {font-size:14px;font-weight:600;line-height:1.5}
body dialog .model-choice-main small {margin-top:3px;font-size:12px;line-height:1.5}
body dialog .model-choice-symbol {width:36px;height:36px;border-radius:10px;background:transparent}
body dialog .model-choice-symbol .identity-image {width:100%;height:100%;border-radius:inherit}
body dialog .model-favorite {width:36px;height:36px;border-radius:10px}
body dialog .model-favorite:hover {background:var(--finish-hover)}
body dialog .model-choice.selected .model-choice-main strong {color:var(--accent)}
body dialog .model-choice-main>svg {margin-inline-start:auto}

/* Search and editable fields are a material, never a box inside another box. */
:is(.adm,dialog,.novels-main,.monochrome-shell) :is(.field,.message-field,.storage-field,.cs-data-form,.layout-model-row) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea,select) {
 border:var(--admin-control-border,0);background-color:var(--admin-control-fill,var(--finish-fill));box-shadow:var(--admin-control-shadow,none);
}
body.admin-mode :is(#main,dialog) :is(.message-field,.storage-field) :is(input,textarea,select) {border:var(--admin-control-border,0);background-color:var(--admin-control-fill,var(--finish-fill));box-shadow:var(--admin-control-shadow,none)}
body.admin-mode :is(.adm,dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea,select) {border:var(--admin-control-border,0)}
body.admin-mode :is(.layout-group-name,.layout-group-heading input,.file-icon-search input,.novel-range-search input) {border:var(--admin-control-border,0);background:var(--admin-control-fill,var(--finish-fill))}
:is(body,dialog) .model-picker-trigger,
body.admin-mode .title-settings .title-model-trigger,
.novels-main [data-model-picker-variant=novel] .model-picker-trigger {border:0;border-radius:12px;background:var(--finish-fill);box-shadow:none}
:is(body,dialog) .model-picker-trigger:hover,
body.admin-mode .title-settings .title-model-trigger:hover {background:var(--finish-hover)}
:is(body,dialog) .model-picker-search,
.novels-main [data-model-picker-variant=novel] .model-picker-search {margin:10px 10px 6px;border:0;border-radius:10px;background:var(--finish-fill);box-shadow:none}
:is(body,dialog) .model-picker-search:focus-within {box-shadow:none}
:is(body,dialog) .model-picker-count {border:0;background:transparent}
:is(body,dialog) .model-picker-option[aria-selected=true][data-active] {outline:0;background:var(--finish-selected)}
body.admin-mode .title-model-popover {border:0;border-radius:14px}
body.admin-mode :is(.title-model-search,.title-model-count) {border:0}
body.admin-mode .title-model-trigger[aria-expanded=true] {border:0;box-shadow:none;background:var(--finish-selected)}

/* Spacious section rhythm takes over from decorative horizontal dividers. */
.monochrome-shell :is(.page-tabs,.image-studio-top,.avatar-editor,.inline-actions,.membership-reset,.shortcut-list,.shortcut-list p) {border:0}
.monochrome-shell .page-tabs {gap:6px;padding-block:8px}
.monochrome-shell .page-tabs a {border:0;border-radius:9px;padding:9px 14px}
.monochrome-shell .page-tabs a.active {background:var(--finish-selected);color:var(--accent)}
.monochrome-shell :is(.image-studio-action,.image-studio-action:hover,.image-studio-action[aria-pressed=true],.image-studio-pending,.tool-launcher-item) {border:0}
.monochrome-shell .image-studio-action[aria-pressed=true] {background:var(--finish-selected);color:var(--accent)}
.monochrome-shell .image-studio-pending {background:var(--finish-fill)}
.monochrome-shell .image-studio-download {border:0;box-shadow:0 4px 12px #0002}
.monochrome-shell .tool-launcher-item {background:var(--finish-fill)}
.monochrome-shell .tool-launcher-item:hover {background:var(--finish-hover)}
.monochrome-shell .membership-reset {padding-top:24px}
.monochrome-shell .upgrade-card::before {display:none}
body .monochrome-shell .upgrade-card {border:0;background:color-mix(in srgb,var(--membership-soft) 45%,var(--paper));box-shadow:none}
body .monochrome-shell .upgrade-card.is-selected {outline:0;background:color-mix(in srgb,var(--membership-soft) 85%,var(--paper));box-shadow:0 8px 28px color-mix(in srgb,var(--membership-accent) 14%,transparent)}
.monochrome-shell .upgrade-card.is-selected .upgrade-choice {color:var(--membership-accent)}
.monochrome-shell .upgrade-card.is-selected .upgrade-type {background:var(--membership-accent);color:var(--membership-on-button)}
body dialog .model-favorite.selected svg {fill:currentColor}
.monochrome-shell :is(.membership-low,.membership-exhausted) {border:0}

/* Writing keeps its editor splits, but controls and planning content stay open. */
.novels-main :is(.cs-stage-bar,.cs-plan-row,.cs-tool-history,.cs-result-actions,.cs-onboard-steps li,.nv-memory,.nv-editor-foot) {border:0}
.novels-main .cs-stage-bar {padding-bottom:12px}
.novels-main .cs-plan-row+.cs-plan-row {margin-top:12px}
.nv-dialog .sc-export-option:has(input:checked) {outline:0;background:var(--finish-selected)}
.novels-main :is(.cs-context-list details,.cs-versions>div) {border:0}

/* Admin table row separators and channel priority grouping remain legible. */
.adm :is(.model-toolbar,.user-toolbar,.drawing-toolbar,.gallery-toolbar,.conversation-toolbar,.resource-filters,.pagination,.drawing-pagination,.bulk-bar,.system-defaults,.system-settings-row,.novel-admin-heading,.novel-admin-footer,.novel-admin-capabilities,.message-card-heading,.message-provider-title,.message-save-bar,.message-delivery-note,.inline-actions,.settings-save,.layout-model-row) {border:0}
.adm :is(.system-settings-row,.layout-model-row) {border-radius:10px}
.adm .system-settings-row+.system-settings-row {margin-top:8px}
.adm .layout-model-row:hover {background:var(--finish-fill)}
.adm :is(.message-note,.message-secret-state,.message-service-badge,.storage-current,.coding-worker-hint,.file-icon-total,.gallery-admin-caption,.novel-admin-heading>span,.empty-icon,.novel-admin-links>a) {border:0}
.adm :is(.message-note,.coding-worker-hint,.storage-current) {background:var(--finish-fill);border-radius:12px}
.adm .message-secret-state {background:var(--finish-fill);border-radius:5px;padding:3px 7px}
.adm .novel-admin-links>a {background:var(--finish-fill)}
.adm .novel-admin-links>a:hover {background:var(--finish-hover)}
.adm :is(.novel-range-list>label,.file-icon-preview-frame) {border:0;background:var(--finish-fill)}
.adm .novel-range-list>label:has(input:checked),.adm .file-icon-preview-frame.is-current {background:var(--finish-selected)}
.adm .novel-range-list>label {padding:12px 14px}
.adm .file-icon-preview-frame.is-current {box-shadow:none}
.adm .overview-metric-grid {border:0;gap:16px;background:transparent}
.adm .overview-metric {border:0;border-radius:14px;background:var(--paper)}
.adm .overview-context {border:0}
body.admin-mode .plan-list {border:0;box-shadow:none}
body.admin-mode .channel-category-trigger {border:0;background:var(--finish-fill)}
body.admin-mode .channel-category-trigger:hover {background:var(--finish-hover)}
.adm .channel-form-section {border:0;padding-top:20px}
.adm .channel-form-section+.channel-form-section {margin-top:12px}
.adm .channel-save-bar {border:0;background:var(--paper)}
.adm .channel-editor>header {border:0}
body.admin-mode .adm :is(.panel,.system-settings,.message-card,.storage-panel,.channel-directory,.channel-editor) {box-shadow:var(--admin-card-shadow,none)}
.adm :is(.adm-top,.adm-tabs) {border:0}
.adm .overview-shortcuts a {border:0}

/* Pointer interaction uses the caret and stable fill; keyboard still has a
   visible outline. Invalid controls and forced-colors retain their borders. */
:root[data-focus-origin=pointer] :is(.adm,dialog,.monochrome-shell,.novels-main,.auth-premium) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea,select):not([aria-invalid=true]):focus {
 outline:0!important;box-shadow:none!important;border-color:var(--admin-control-edge,transparent);
}
:root[data-focus-origin=pointer] :is(.adm,dialog,.monochrome-shell,.novels-main) :is(.model-search,.model-picker-search,.model-filter-search,.history-search,.coding-model-search,.search-box,.drawing-search,.drawing-settings-search,.gallery-search,.user-search,.file-icon-search,.conversation-search,.layout-model-search,.title-model-search):not(:has([aria-invalid=true])):focus-within {
 outline:0!important;box-shadow:none!important;
}
:root[data-focus-origin=pointer] .monochrome-shell :is(.composer,.image-studio-composer):focus-within {outline:0;outline-offset:0}
:root[data-focus-origin=keyboard] body dialog .model-search:focus-within {outline:2px solid var(--accent);outline-offset:3px}
:root[data-focus-origin=keyboard] :is(body,dialog) .model-picker-search:focus-within {outline:2px solid var(--accent);outline-offset:-2px}
:root[data-focus-origin=keyboard] :is(.adm,dialog,.novels-main) :is(input,textarea,select):focus-visible {outline:2px solid var(--accent);outline-offset:2px}
:root[data-focus-origin=keyboard] .monochrome-shell .upgrade-card:has(.upgrade-choice:focus-visible) {outline:2px solid var(--membership-accent);outline-offset:4px}
:is(body,dialog) :is(input,textarea,select)[aria-invalid=true] {outline:2px solid var(--danger);outline-offset:2px}

@media(max-width:760px) {
 body dialog:has(.model-options) {padding:22px 18px;border-radius:22px 22px 0 0}
 body dialog .model-choice-main {min-height:72px;padding:12px}
 body dialog .model-choice-main strong {font-size:14px}
 body dialog .model-search input {font-size:16px}
 .adm .overview-metric-grid {gap:10px}
}
@media(forced-colors:active) {
 body dialog :is(.model-cat.active,.model-choice.selected),.adm .novel-range-list>label:has(input:checked),body .monochrome-shell .upgrade-card.is-selected {outline:1px solid Highlight}
 :root[data-focus-origin=pointer] :is(body,dialog) :is(input,textarea,select):focus {outline:1px solid Highlight!important}
}

/* Account details share a left edge and a readable, content-sized measure. */
.monochrome-shell .account-page #account-content {min-width:0}
.monochrome-shell .account-page :is(.account-profile,.membership-overview) {margin-inline:0}
.monochrome-shell .account-profile>.panel {padding:24px}
.monochrome-shell .account-profile .section-heading {margin-bottom:16px;gap:12px}
.monochrome-shell .account-profile .avatar-editor {padding:0 0 16px;margin-bottom:0}
.monochrome-shell .account-profile .avatar-preview {width:64px;height:64px;border-radius:50%}
.monochrome-shell .account-profile .field {margin-bottom:16px}
.monochrome-shell .account-profile .profile-meta {margin:18px 0 12px;font-size:12px;line-height:1.6}
.monochrome-shell .account-profile .inline-actions {justify-content:flex-start;flex-wrap:wrap;gap:8px;padding-top:0}
.monochrome-shell .account-profile .inline-actions .btn {min-height:40px;margin:0}
.monochrome-shell .account-orders {max-width:100%;padding:24px}
.monochrome-shell .account-orders .section-heading {align-items:flex-start;flex-wrap:wrap;gap:12px 20px;margin-bottom:20px}
.monochrome-shell .account-orders .section-heading>div {flex:1 1 240px;min-width:0}
.monochrome-shell .account-orders .section-heading .btn {margin-left:0;flex:none}
.monochrome-shell .account-orders .section-heading p {max-width:48ch;margin:6px 0 0;line-height:1.7}
.monochrome-shell .account-orders .table-wrap {scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
.monochrome-shell .account-orders table {min-width:660px}
.monochrome-shell .account-orders th,.monochrome-shell .account-orders td:not(:first-child) {white-space:nowrap}
.monochrome-shell .account-orders .order-reference {display:block;min-width:120px;max-width:240px;overflow-wrap:anywhere;line-height:1.6;font-variant-numeric:tabular-nums}
.monochrome-shell :is(.account-page,.notices-list) .empty-state {padding:36px 16px}
.monochrome-shell :is(.account-page,.notices-list) .empty-icon {width:48px;height:48px;margin-bottom:16px;border:0;border-radius:14px;background:var(--finish-fill);color:var(--muted)}
.monochrome-shell :is(.account-page,.notices-list) .empty-icon svg {width:24px;height:24px}
.monochrome-shell :is(.account-page,.notices-list) .empty-state h3 {font-size:16px;line-height:1.5;margin-bottom:6px}
.monochrome-shell :is(.account-page,.notices-list) .empty-state p {max-width:44ch;margin-inline:auto;line-height:1.7}
@media(max-width:600px) {
 .monochrome-shell .account-page .page-tabs {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));overflow:visible;gap:4px;margin-bottom:20px;padding:0;white-space:normal}
 .monochrome-shell .account-page .page-tabs>a {min-width:0;min-height:44px;padding:10px 6px;font-size:13px;text-align:center}
 .monochrome-shell .account-profile>.panel,.monochrome-shell .account-orders {padding:20px}
 .monochrome-shell .account-profile .inline-actions .btn {min-height:44px}
 .monochrome-shell .account-orders .section-heading>div {flex-basis:100%}
 .monochrome-shell .account-orders .table-wrap {overflow:visible;background:transparent;border:0;border-radius:0}
 .monochrome-shell .account-orders table {display:block;min-width:0;width:100%}
 .monochrome-shell .account-orders thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
 .monochrome-shell .account-orders tbody {display:grid;gap:12px}
 .monochrome-shell .account-orders tbody tr {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 12px;padding:16px;background:var(--paper);border:0;border-radius:12px}
 .monochrome-shell .account-orders td {display:block;padding:0;border:0!important;min-width:0;background:transparent;white-space:normal!important;font-variant-numeric:tabular-nums}
 .monochrome-shell .account-orders td:first-child {grid-column:1/-1}
 .monochrome-shell .account-orders td::before {content:attr(data-label);display:block;margin-bottom:5px;color:var(--muted);font-size:12px;line-height:1.5}
 .monochrome-shell .account-orders .order-reference {max-width:none;min-width:0;font-size:13px}
 .monochrome-shell .account-orders .empty-state {padding:28px 8px}
}
