/* Writing and reading use the same paper, ink, and accent as the community. */
.field { min-width: 0; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; }
.field .helptext { color: var(--muted); font-size: 13px; margin-top: 5px; }
.field textarea, .field input, .field select { max-width: 100%; }
.errorlist { color: var(--refuted); padding-left: 20px; font-size: 14px; }
.checkbox-field { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.checkbox-field input { width: auto; }
.checkbox-field label { font-weight: 400; order: 1; }
.checkbox-field .hint, .checkbox-field .errorlist { flex-basis: 100%; order: 2; }
.writer-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.writer-heading > .btn { flex-shrink: 0; }
.page-content.writing-page { max-width: none; }
.writer-form { max-width: none; gap: 20px; }
.writer-title input { font-size: 24px; line-height: 1.4; padding: 15px; font-weight: 600; }
.writer-controls, .editor-toolbar, .editor-tabs, .article-actions, .profile-actions, .topic-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.writer-controls { justify-content: space-between; border-block: 1px solid var(--rule); padding: 10px 0; }
.editor-toolbar .btn, .editor-tabs .btn { min-height: 38px; padding: 7px 11px; }
.editor-toolbar select { width: auto; max-width: 145px; height: 38px; padding: 6px 9px; }
.editor-tabs [aria-pressed="true"] { color: var(--accent); background: var(--accent-dim); border-color: var(--accent); }
.editor-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; min-height: 340px; }
.editor-workspace[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.editor-workspace[data-mode="preview"] .editor-source { display: none; }
.editor-source, .preview-panel, .reading-text { min-width: 0; }
.editor-source > label { font-size: 13px; font-weight: 600; }
.editor-source textarea { width: 100%; min-height: 380px; font: 14px/1.85 var(--mono); padding: 18px; resize: vertical; tab-size: 2; }
.preview-panel { border: 1px solid var(--rule); border-radius: 8px; background: var(--card); padding: 20px; max-height: 700px; overflow: auto; }
.preview-panel h2 { font-size: 25px; }
.preview-panel .body { font-size: 16px; }
.writer-metadata { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.writer-metadata .field:last-child { grid-column: 1 / -1; }
.writer-extras { margin: 0; }
.writer-extras summary, .writer-help summary { cursor: pointer; font-weight: 600; }
.writer-extras .field { margin-top: 20px; }
.writer-footer { position: sticky; bottom: 0; z-index: 12; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 16px; background: var(--card); border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 -3px 16px #00000008; }
.writer-footer > div:first-child { min-width: 0; }
.save-status { display: block; color: var(--muted); font-size: 13px; }
[data-save-error] { display: block; color: var(--refuted); }
.writer-help { margin-top: 25px; color: var(--ink-soft); }
.writer-help p { max-width: 80ch; }
.topic-chips, .card-tags { display: flex; flex-wrap: wrap; gap: 7px 12px; margin: 12px 0 20px; }
.topic-chips > a, .subject-pill { font-size: 12px; padding: 4px 9px; background: var(--accent-dim); color: var(--accent); border-radius: 5px; }
.card-tags { margin: 3px 0 8px; font-size: 11px; gap: 5px 9px; }
.filter-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; padding: 18px; border: 1px solid var(--rule); border-radius: 8px; margin: 20px 0; background: var(--surface); }
.filter-form > div { flex: 1; min-width: 140px; }
.filter-form label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.filter-form input, .filter-form select { width: 100%; }
.subject-grid, .collection-grid, .people-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin-bottom: 30px; }
.subject-card { display: block; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 25px; }
.subject-card:hover { border-color: var(--accent); text-decoration: none; }
.subject-card h2 { margin-bottom: 9px; }
.subject-card p { color: var(--muted); font-size: 14px; }
.subject-mark { font: 36px var(--serif); color: var(--accent); }
.collection-card { border: 1px solid var(--rule); border-radius: 9px; overflow: hidden; min-width: 0; background: var(--card); }
.collection-cover { min-height: 115px; background: var(--accent-dim); color: var(--accent); display: flex; align-items: center; justify-content: space-between; padding: 25px; }
.collection-cover .icon { width: 45px; height: 45px; stroke-width: 1; }
.collection-cover span { font: italic 26px var(--serif); }
.cover-book { background: var(--surface); }
.collection-details { padding: 20px; }
.collection-details h2 { font-size: 20px; }
.collection-details p:not(.eyebrow) { color: var(--muted); font-size: 14px; }
.collection-description { max-width: 75ch; margin-bottom: 28px; }
.chapter-list { padding-left: 26px; }
.chapter-list li { padding: 12px 5px; border-bottom: 1px solid var(--rule); }
.chapter-list a { font-weight: 600; }
form.profile-form { max-width: 720px; margin-bottom: 30px; }
.profile-actions { gap: 18px; margin: 18px 0 24px; }
.profile-about { max-width: 75ch; }
.people-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.people-grid .panel { margin: 0; }
.people-grid h2 { font-size: 18px; margin: 0; }
.people-grid .profile-heading { margin: 0; }
.people-grid .profile-heading p { margin: 4px 0 0; }
.draft-row { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.draft-row h2 { margin: 0; }
.draft-row p { margin-bottom: 5px; }
.delete-control { font-size: 13px; max-width: 260px; }
.delete-control summary { color: var(--muted); cursor: pointer; padding: 8px; }
.manage-chapters { padding-left: 22px; }
.manage-chapters li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.manage-chapters form { display: flex; gap: 7px; margin-top: 8px; }
.manage-chapters .btn { padding: 5px 10px; min-height: 36px; }
.notification-list .unread { border-left: 3px solid var(--accent); }
.notification-list h2 { font-size: 19px; }
.count-badge { background: var(--accent-dim); color: var(--accent); border-radius: 12px; min-width: 22px; text-align: center; }
.reading-page { max-width: none; }
.reading-layout { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 30px; align-items: start; }
.reading-layout:not(:has(.article-contents)) { grid-template-columns: minmax(0, 1fr); }
.article-contents { grid-column: 2; grid-row: 1; position: sticky; top: 92px; padding: 15px; background: var(--surface); border: 1px solid var(--rule); border-radius: 7px; font-size: 12px; max-height: calc(100dvh - 125px); overflow: auto; }
.article-contents summary { font-weight: 650; cursor: pointer; font-size: 13px; }
.article-contents ol { list-style: none; padding: 0; margin: 12px 0 0; }
.article-contents li { padding: 5px 0; overflow-wrap: anywhere; }
.article-contents .toc-level-3, .article-contents .toc-level-4 { padding-left: 12px; }
.article-contents a { color: var(--ink-soft); }
.article-contents a:hover { color: var(--accent); }
.reading-text { grid-column: 1; grid-row: 1; }
.article-actions { margin: 20px 0; }
.article-actions .btn { min-height: 38px; font-size: 12px; padding: 7px 12px; }
.article-actions .icon { width: 15px; height: 15px; }
.learning-notice { border: 1px solid var(--rule); background: var(--warn-bg); color: var(--warn); padding: 15px 18px; border-radius: 6px; margin: 20px 0 28px; font-size: 13px; }
.math-box { border-left: 3px solid var(--accent); padding: 15px 20px; margin: 24px 0; background: var(--surface); border-radius: 0 6px 6px 0; }
.math-box > p:first-child { font-family: var(--sans); font-size: 14px; color: var(--accent); margin-top: 0; }
.math-box-proof { border-left-color: var(--muted); background: var(--paper); }
.article-references { border-top: 1px solid var(--rule); margin-top: 36px; padding-top: 15px; }
.article-author { margin-top: 35px; }
.article-author h2 { font-size: 20px; }
.chapter-navigation { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 15px; padding: 20px 0; border-block: 1px solid var(--rule); }
.chapter-navigation a { max-width: 40%; overflow-wrap: anywhere; }
.collection-membership { display: flex; flex-wrap: wrap; gap: 12px; margin: 25px 0; }
.auth-dialog { background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 12px; padding: 28px; width: min(450px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow: auto; }
.auth-dialog::backdrop { background: #061b24aa; }
.dialog-heading { display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.dialog-heading h2 { margin: 0; font-size: 25px; }
.dialog-heading button { font-size: 23px; }
.show-password { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.show-password input { width: auto; }
@media (max-width: 1100px) {
  .subject-grid, .collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reading-layout { grid-template-columns: minmax(0, 1fr); }
  .article-contents { grid-column: 1; grid-row: auto; position: static; max-height: 330px; }
  .reading-text { grid-row: auto; }
}
@media (max-width: 767px) {
  .writer-heading { flex-direction: column; gap: 8px; }
  .writer-heading h1 { font-size: 30px; }
  .writer-title input { font-size: 20px; }
  .writer-metadata { grid-template-columns: minmax(0, 1fr); }
  .writer-controls { gap: 12px; }
  .writer-controls > div { max-width: 100%; }
  .editor-workspace[data-mode="split"] { grid-template-columns: minmax(0, 1fr); }
  .split-button { display: none; }
  .editor-source textarea { min-height: 370px; font-size: 16px; padding: 12px; }
  .writer-footer { bottom: 62px; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .writer-footer .button-row { justify-content: flex-end; }
  .subject-grid, .collection-grid, .people-grid { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .subject-card { padding: 20px; }
  .draft-row { flex-direction: column; align-items: start; }
  .profile-actions { gap: 12px; }
  .profile-heading h1 { font-size: 28px; }
  .filter-form { padding: 12px; gap: 10px; }
  .reading-layout { gap: 20px; }
  .article-contents { max-height: 280px; }
  .article-actions { gap: 6px; }
  .article-actions .btn { padding: 7px 9px; }
  .chapter-navigation { flex-direction: column; }
  .chapter-navigation a { max-width: 100%; }
}
@media print {
  .masthead, .sidebar, .mobile-nav, .foot, .article-actions, .article-author, .comments, .article-contents, .feedback-widget, .skip-link { display: none !important; }
  .site-layout, .reading-layout { display: block; }
  .page-content, .post, .reading-text { max-width: none; width: 100%; }
  .body { color: #000; }
}
