/* Shared reading and writing widths; the user's wide preference applies to both. */
:root{--document-page-width:840px;--writing-muted:#69655f}
:root[data-page-width=wide]{--document-page-width:1200px}
.document>.page,.editor-header>.page.editor-heading,.document>.page.editor-page{width:min(100%,var(--document-page-width));max-width:var(--document-page-width);padding-inline:32px}
.document>article.page{padding-top:18px}
.document:has(#note-database)>.page{width:100%;max-width:none}
.page-eyebrow{margin-bottom:10px}
.page-title{font-size:30px;line-height:1.35;letter-spacing:-.7px;margin-bottom:12px}
.page-tags{gap:5px;margin-bottom:16px}
.page-tags .review-date{line-height:1.5}
.prose>:first-child{margin-top:0}
.reader-info{margin:0 0 16px;border-block:1px solid var(--line)}
.reader-info>summary{padding:10px 0;font-size:13px;line-height:1.5;color:var(--writing-muted);cursor:pointer}
.reader-info[open]>summary{color:var(--ink)}
.reader-info>*:not(summary){margin-top:0}

/* Focus keeps the record's own controls available, including the exit control. */
.shell.writing-focus>.sidebar,.shell.writing-focus>.scrim,.shell.writing-focus .topbar,.shell.writing-focus .record-list{display:none!important}
.shell.writing-focus .main-shell{width:100%;min-width:0}
.shell.writing-focus .workspace{display:flex}
.shell.writing-focus .document{display:block!important;width:100%;height:100%}
.focus-toggle,.reader-layout-toggle{display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap;font-size:12px;min-height:36px;padding:6px 9px}
.focus-toggle[aria-pressed=true],.reader-layout-toggle[aria-pressed=true]{background:var(--soft);color:var(--accent-text)}
.focus-toggle:hover,.reader-layout-toggle:hover{background:var(--soft-hover);color:var(--accent-text)}

/* Only the document scrolls: JavaScript grows the textarea with its content. */
.document:has(.editor-header){scroll-padding-top:var(--editor-header-height,180px)}
.document{container-type:inline-size;container-name:record}
.editor-header{overflow:visible}
.editor-header .document-toolbar{width:min(100%,var(--document-page-width));max-width:var(--document-page-width);margin-inline:auto;min-height:48px;padding:5px 32px;gap:8px;flex-wrap:nowrap}
.editor-title-field{display:flex;align-items:center;gap:8px;flex:1;min-width:0}
.editor-header .title-input{width:100%;font-size:25px;line-height:1.35;padding:2px 0;border:0;border-radius:0;text-overflow:ellipsis;background:transparent}
.editor-title-field .title-input{flex:1;min-width:0}
.editor-header .editor-title-field>.save-status{flex:0 1 auto;max-width:30%;min-width:42px;gap:2px;align-items:flex-end}
.editor-title-field>.save-status>*{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}
.editor-header .doc-actions{flex:none;margin-left:0;gap:4px}
.editor-header .editor-section-toggle{padding:6px;gap:4px;font-size:11px;min-height:34px;white-space:nowrap}
.editor-section-toggle[aria-expanded=true]{background:var(--soft);color:var(--accent-text)}
.editor-header>.page.editor-heading{padding-top:0;padding-bottom:0}
.editor-meta{display:flex;align-items:flex-start;gap:12px;min-width:0}
#editor-meta[hidden],#editor-toolbar[hidden]{display:none!important}
.editor-heading .properties{flex:1;min-width:0;margin:0;border-top:0}
.editor-heading .properties summary{color:var(--writing-muted);font-size:12px;min-height:25px;padding:3px 0}
.editor-heading .format-bar{display:flex;align-items:center;gap:6px;overflow:visible;flex-wrap:nowrap;margin:0;padding:0;border-bottom:0}
.editor-tools-scroll{display:flex;align-items:center;gap:4px;min-width:0;flex:1;height:46px;overflow-x:auto;overflow-y:hidden;overscroll-behavior-inline:contain;scrollbar-width:thin}
.editor-tools-main,.editor-tools-extra{display:flex;align-items:center;flex-wrap:nowrap;gap:2px;flex:none;min-width:0}
.editor-tools-extra{padding:0;margin:0;border:0}
.editor-tools-extra[hidden]{display:none!important}
.editor-heading .format{flex:none;min-height:34px;padding:5px 7px;font-size:12px;line-height:1.4;white-space:nowrap;justify-content:center}
.editor-heading .tools-toggle{flex:none;margin:0;border:1px solid var(--line);color:var(--writing-muted)}
.editor-heading .tools-toggle[aria-expanded=true]{background:var(--soft);border-color:var(--accent-border);color:var(--accent-text)}
.editor-page #edit-body{display:block;overflow:hidden;resize:none;min-height:max(240px,calc(100dvh - var(--editor-header-height,180px) - 140px));padding:12px 0;scroll-margin-top:var(--editor-header-height,180px)}
.editor-page .editor-footer{gap:12px;flex-wrap:wrap;line-height:1.6;margin-top:8px}
.editor-page .editor-bottom{margin-top:20px;gap:8px}

/* Body links remain usable while the original Markdown input stays editable. */
.body-link-previews[hidden]{display:none!important}
.body-link-previews{margin:12px 0 20px;min-width:0}
.body-link-previews>header{display:flex;align-items:center;gap:8px;margin-bottom:8px;color:var(--writing-muted)}
.body-link-previews h2{font-size:13px;font-weight:600;margin:0}
.body-link-count{font-size:11px}
.body-link-list{display:grid;gap:8px}
.body-link-card{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;border:1px solid var(--line);border-radius:8px;padding:10px 12px;min-width:0;background:var(--bg)}
.body-link-open{display:flex;align-items:center;gap:12px;flex:1 1 200px;min-width:0;color:var(--accent-text);text-decoration:none}
.body-link-open:hover .body-link-title{text-decoration:underline}
.body-link-info{display:flex;flex-direction:column;gap:3px;min-width:0}
.body-link-title{font-size:14px;font-weight:600;line-height:1.4;overflow-wrap:anywhere}
.body-link-address{font-size:12px;line-height:1.5;text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere}
.body-link-thumbnail{display:block;width:96px;aspect-ratio:16/9;object-fit:cover;border-radius:5px;flex:none;background:var(--soft)}
.body-link-thumbnail[hidden]{display:none}
.body-link-preview{flex:none;color:var(--accent-text);background:var(--soft);min-height:36px;font-size:12px}
.body-link-preview[aria-expanded=true]{border-color:var(--accent-border)}
.body-link-media{flex:0 0 100%;min-width:0;max-width:760px;aspect-ratio:16/9;margin-top:4px}
.body-link-media iframe{display:block;width:100%;height:100%;border:0;border-radius:6px;background:#151515}
.editor-page.has-body-links #edit-body{min-height:180px}
@container record (max-width:600px){
 .body-link-card{padding:9px;gap:8px}
 .body-link-open{gap:8px;flex-basis:100%}
 .body-link-thumbnail{width:80px}
 .body-link-preview{min-height:40px;margin-left:auto}
}

/* Metadata is secondary in hierarchy but remains readable on light surfaces. */
.note-row>p{font-size:13px;color:#625f59}
.note-eyebrow,.note-meta,.document-state,.page-eyebrow,.review-date,.editor-footer,.side-heading,.local-label,.storage-note,.mirror-indicator{font-size:12px;color:var(--writing-muted)}
.filters summary,.tag small,.chip small,.nav-item small{font-size:12px;color:var(--writing-muted)}
.status-pill{font-size:12px;color:#52613b;background:#f0f2eb}
.editor-heading .property-grid label{color:var(--writing-muted)}

@media(max-width:700px){
 .document>.page,.editor-header>.page.editor-heading,.document>.page.editor-page{padding-inline:20px}
 .document>article.page{padding-top:14px}
 .page-title{font-size:25px;line-height:1.35;letter-spacing:-.5px;margin-bottom:10px}
 .page-eyebrow{margin-bottom:8px}
 .page-tags{gap:4px;margin-bottom:14px}
 .page-tags .tag,.page-tags .chip{min-height:30px;padding:4px 8px;font-size:12px;line-height:1.4}
 .page-tags .review-date{width:100%;margin-left:0}
 .editor-header .document-toolbar{padding:4px 20px;gap:4px}
 .editor-header .doc-actions{gap:2px}
 .editor-header .title-input{font-size:22px;padding:2px 0}
 .editor-heading .properties{max-height:min(22dvh,160px)}
 .editor-heading .format-bar{overflow:visible;padding:0}
 .editor-tools-main{display:flex;gap:2px}
 .editor-heading .format{min-height:40px;padding:6px;font-size:13px;white-space:nowrap}
 .editor-heading .tools-toggle{margin-left:0}
 .editor-tools-extra{display:flex;gap:2px}
 .editor-tools-extra>.format{min-width:0;overflow-wrap:anywhere;word-break:keep-all}
 .editor-tools-extra>.format>span{min-width:0;overflow-wrap:anywhere}
 .editor-page #edit-body{font-size:var(--reading-size);line-height:1.85}
 .focus-toggle,.reader-layout-toggle{min-height:40px}
}

@container record (max-width:600px){
 .editor-header .document-toolbar{flex-wrap:wrap;padding-inline:20px;gap:3px}
 .editor-title-field{order:-1;flex-basis:100%}
 .editor-header .doc-actions{margin-left:auto}
 .editor-header .editor-section-toggle{width:30px;min-width:30px;min-height:36px;padding:5px;gap:0}
 .editor-header .editor-section-toggle>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
 .editor-header .editor-title-field>.save-status{max-width:34%;min-width:42px}
 .editor-header .focus-toggle{width:36px;min-width:36px;padding:7px;gap:0}
 .editor-header .focus-toggle>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
 .editor-meta{gap:6px;flex-wrap:wrap}
 .editor-heading .tools-toggle{width:38px;min-width:38px;padding:6px;gap:0}
 .editor-heading .tools-toggle>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
}

@media(max-width:480px){
 .doc-actions .focus-toggle{width:40px;min-width:40px;padding:8px;gap:0}
 .focus-toggle>span{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
 .document-toolbar{gap:4px;flex-wrap:wrap}
 .document-toolbar .save-status{flex:1;min-width:42px;max-width:none}
 .doc-actions{gap:2px;flex-shrink:0}
}

@container record (max-width:360px){
 .editor-header .document-toolbar{padding-inline:12px}
 .editor-header .doc-actions{gap:2px}
 .editor-header .back-button{width:36px;min-width:36px;min-height:40px;padding:8px;gap:0}
 .editor-header .back-button>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
}

@media print{
 .document>.page{width:100%;max-width:none;padding:0}
}

/* Sharing keeps the reviewed selection separate from publication and local ZIP export. */
.reading-export-dialog>header{padding:0 0 12px;gap:8px;box-shadow:0 -24px 0 #fff}
.reading-export-dialog>header h2{min-width:0}
.reading-export-dialog>header button{flex:none}
.reading-export-dialog .reading-audience{margin:12px 0;color:var(--ink)}
.reading-export-dialog .reading-publish-panel,.reading-export-dialog .reading-zip-panel{border-top:1px solid var(--line);margin-top:22px;padding-top:18px;min-width:0}
.reading-export-dialog h3{font-size:16px;line-height:1.45;margin:0 0 8px}
.reading-export-dialog .reading-publish-panel>p,.reading-export-dialog .reading-zip-panel>p{margin:6px 0 12px;color:var(--muted)}
.reading-export-dialog details>summary{cursor:pointer;line-height:1.6}
.reading-export-dialog .reading-publish-setup{border:1px solid var(--line);border-radius:8px;padding:10px 12px}
.reading-export-dialog .reading-publish-setup label,.reading-export-dialog .reading-publish-result label{display:flex;flex-direction:column;gap:6px;font-size:13px;margin:10px 0}
.reading-export-dialog [data-reading-configured]{color:var(--muted);font-size:12px}
.reading-export-dialog input[data-reading-key],.reading-export-dialog input[data-reading-url]{width:100%;min-width:0;padding:10px;border:1px solid var(--accent-border);border-radius:8px;font:inherit}
.reading-export-dialog input[data-reading-url]{font-size:13px;background:var(--soft)}
.reading-export-dialog .reading-publish-target{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;margin:12px 0}
.reading-export-dialog .reading-publish-target p{flex:1;min-width:160px;margin:0;font-size:13px;overflow-wrap:anywhere}
.reading-export-dialog .reading-publish-target button{font-size:12px}
.reading-export-dialog .reading-publish-panel .reading-actions{margin-top:8px}
.reading-export-dialog .reading-publish-result{margin-top:14px;padding:10px 14px;border:1px solid var(--accent-border);border-radius:8px;background:var(--accent-tint)}
.reading-export-dialog .reading-publish-result .quiet{min-height:42px;border:1px solid var(--accent-border);border-radius:8px;text-decoration:none;font-size:13px}
.reading-export-dialog .reading-share-manager{margin-top:20px}
.reading-export-dialog .reading-share-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid var(--line);min-width:0}
.reading-export-dialog .reading-share-row>div:first-child{flex:1;min-width:0}
.reading-export-dialog .reading-share-row strong,.reading-export-dialog .reading-share-row a,.reading-export-dialog .reading-share-row small{display:block;overflow-wrap:anywhere}
.reading-export-dialog .reading-share-row strong{font-size:14px;font-weight:600}
.reading-export-dialog .reading-share-row a{font-size:12px;color:var(--accent-text);margin-top:3px}
.reading-export-dialog .reading-share-row small{font-size:11px;color:var(--muted);margin-top:3px}
.reading-export-dialog .reading-share-actions{display:flex;gap:6px;flex:none;flex-wrap:wrap}
.reading-export-dialog .reading-share-actions button{font-size:12px;white-space:nowrap}
.reading-export-dialog .reading-share-row.selected [data-reading=update-share]{background:var(--soft);color:var(--accent-text);border-color:var(--accent-border)}
.reading-export-dialog [data-reading-status]:empty,.reading-export-dialog [data-reading-shares-status]:empty{display:none}
.reading-export-dialog .error{color:#a13c31}
.reading-export-dialog [hidden]{display:none!important}
@media(max-width:500px){
 .reading-export-dialog{padding:16px;max-height:94dvh}
 .reading-export-dialog>header h2{font-size:18px}
 .reading-export-dialog .reading-share-row{align-items:stretch;flex-direction:column;gap:8px}
 .reading-export-dialog .reading-share-actions{justify-content:flex-start}
 .reading-export-dialog .reading-publish-result{padding:10px}
 .reading-export-dialog iframe{height:420px}
 .reading-export-dialog .reading-publish-target p{flex-basis:100%}
}
