:root {
    --writems-ink: #252320;
    --writems-muted: #77716b;
    --writems-rule: #ded8d1;
    --writems-paper: #f7f4ef;
}

html {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    max-width: 100%;
    overflow-x: hidden;
}

.writems-page {
    background: var(--writems-paper);
    color: var(--writems-ink);
    font-family: system-ui, sans-serif;
    margin: 0;
}

#collection.writems-reader {
    box-sizing: border-box;
    background: var(--writems-paper);
    color: var(--writems-ink);
    font-family: system-ui, sans-serif;
    margin: 0 !important;
    max-width: none;
    padding: 0 !important;
    width: 100%;
}

body#collection.writems-reader {
    box-shadow: none !important;
    margin: 0 !important;
    max-width: none !important;
    padding: 0 !important;
    width: 100% !important;
}

#collection.writems-reader .writems-collection-header,
#collection.writems-reader #wrapper,
#collection.writems-reader .writems-reader-footer {
    box-sizing: border-box;
    float: none;
    margin-left: auto !important;
    margin-right: auto !important;
    width: min(100%, 48rem);
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

#collection.writems-reader .writems-collection-header {
    padding-top: 4rem;
}

#collection.writems-reader #blog-title {
    font-family: Georgia, serif;
    font-size: clamp(2.5rem, 8vw, 5rem);
    letter-spacing: -.06em;
    line-height: 1;
    margin: 0;
}

#collection.writems-reader #blog-title a {
    color: inherit;
    text-decoration: none;
}

#collection.writems-reader .description {
    color: var(--writems-muted);
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 1.25rem 0;
    max-width: 38rem;
}

.writems-public-nav {
    display: flex;
    gap: 1rem;
    margin: 2rem 0 1rem;
}

.writems-public-nav a {
    color: var(--writems-muted);
    text-decoration: none;
}

.writems-public-nav a[aria-current="page"] {
    color: var(--writems-ink);
    font-weight: 700;
}

#collection.writems-reader .writems-post-list {
    padding-bottom: 3rem;
    padding-top: 1rem;
}

#collection.writems-reader .writems-post-list article {
    border-top: 1px solid var(--writems-rule);
    padding: 2rem 0;
}

#collection.writems-reader .writems-post-list > article:first-of-type {
    border-top: 0;
}

#collection.writems-reader .writems-post-list .post-title {
    font-family: Georgia, serif;
    font-size: clamp(1.5rem, 4vw, 2.1rem);
    line-height: 1.15;
    margin: .5rem 0;
}

#collection.writems-reader .writems-post-list .post-title a {
    color: inherit;
    text-decoration: none;
}

#collection.writems-reader .writems-post-list time {
    color: var(--writems-muted);
    font-size: .85rem;
}

#collection.writems-reader .writems-post-list .book {
    font-family: Georgia, serif;
    font-size: 1.08rem;
    line-height: 1.75;
}

.writems-reader-footer {
    border-top: 1px solid var(--writems-rule);
    color: var(--writems-muted);
    padding-bottom: 2rem;
    padding-top: 1.25rem;
}

.writems-reader-footer nav {
    display: flex;
    gap: .75rem;
}

.writems-reader-footer a { color: inherit; }

.writems-header,
.writems-main,
.writems-footer {
    margin: 0 auto;
    max-width: 48rem;
    padding: 1.25rem 1.25rem;
}

.writems-header {
    align-items: baseline;
    display: flex;
    justify-content: space-between;
}

.writems-header nav { display: flex; gap: 1rem; }
.writems-brand { color: inherit; font-weight: 700; text-decoration: none; }
.writems-main { padding-bottom: 4rem; padding-top: 5rem; }
.eyebrow { color: var(--writems-muted); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; }
.writems-main h1 { font-size: clamp(2.5rem, 8vw, 5rem); letter-spacing: -.05em; margin: 0 0 3rem; }
.writems-intro { padding-bottom: 4rem; }
.writems-intro h1 { font-family: Georgia, serif; margin-bottom: 1rem; }
.writems-intro p:not(.eyebrow) { color: var(--writems-muted); font-size: 1.15rem; line-height: 1.6; max-width: 34rem; }
.writems-home-section { margin-top: 3rem; }
.writems-section-heading { align-items: baseline; display: flex; justify-content: space-between; }
.writems-section-heading a, .writems-home-links a { color: var(--writems-muted); }
.writems-featured-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.writems-featured-card { background: var(--writems-ink); color: var(--writems-paper); display: grid; gap: 1rem; min-height: 9rem; padding: 1.25rem; text-decoration: none; }
.writems-featured-card span, .writems-recent-list time { font-size: .85rem; opacity: .7; }
.writems-featured-card strong { align-self: end; font-family: Georgia, serif; font-size: 1.4rem; }
.writems-recent-list article { border-top: 1px solid var(--writems-rule); padding: 1.5rem 0; }
.writems-recent-list h2 { font-family: Georgia, serif; margin: .4rem 0; }
.writems-recent-list h2 a { color: inherit; text-decoration: none; }
.writems-recent-list article > div { color: var(--writems-muted); line-height: 1.6; }
.writems-home .writems-recent-list {
    display: grid;
    gap: 2.5rem;
}
.writems-home .writems-recent-list article {
    background: #fff;
    border: 0;
    padding: 1.5rem;
}
.writems-home .writems-recent-list article:first-child {
    border-top: 0;
}
.writems-home-links { border-top: 1px solid var(--writems-rule); display: flex; gap: 1rem; margin-top: 3rem; padding-top: 1.25rem; }
.writems-note { border-top: 1px solid var(--writems-rule); padding: 1.75rem 0 2.5rem; }
.writems-note time { color: var(--writems-muted); font-size: .85rem; }
.writems-note h2 { font-size: 1.7rem; margin: .45rem 0 1rem; }
.writems-note h2 a { color: inherit; text-decoration: none; }
.writems-note-content { line-height: 1.7; }
.writems-note .read-more { color: var(--writems-muted); display: inline-block; margin-top: 1rem; }
.writems-footer { border-top: 1px solid var(--writems-rule); color: var(--writems-muted); }
#me .right-side .simple-btn {
    background: var(--writems-paper);
    border: 1px solid var(--writems-rule);
    color: var(--writems-ink);
}
#me .right-side .simple-btn:hover,
#me .right-side .simple-btn:focus {
    background: #ebe5dd;
    color: var(--writems-ink);
}
.manage-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manage-card { border: 1px solid var(--writems-rule); color: inherit; display: grid; gap: .4rem; padding: 1.25rem; text-decoration: none; }
.manage-card span { color: var(--writems-muted); font-size: .9rem; }
.manage-card-primary { background: var(--writems-paper); color: var(--writems-ink); }
.featured-manage-list { display: grid; gap: 1rem; }
.featured-manage-list .manage-card { gap: .7rem; }
.featured-manage-list button { background: transparent; border: 1px solid var(--writems-rule); cursor: pointer; padding: .45rem .7rem; }
.stats-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-card { border: 1px solid var(--writems-rule); display: grid; gap: .35rem; padding: 1.25rem; }
.stats-card strong { font-family: Georgia, serif; font-size: 2.5rem; }
.stats-card small, .stats-list small { color: var(--writems-muted); }
.stats-list { border-top: 1px solid var(--writems-rule); display: grid; }
.stats-list a { align-items: center; border-bottom: 1px solid var(--writems-rule); color: inherit; display: flex; justify-content: space-between; padding: 1rem 0; text-decoration: none; }
.stats-trend { align-items: end; border-bottom: 1px solid var(--writems-rule); display: grid; gap: .5rem; grid-template-columns: repeat(7, 1fr); min-height: 8rem; }
.stats-trend-day { align-items: center; display: flex; flex-direction: column; gap: .25rem; justify-content: end; min-height: 8rem; padding-bottom: .75rem; }
.stats-trend-day strong { background: var(--writems-ink); color: var(--writems-paper); min-height: 1.5rem; padding: .35rem .55rem; }
.stats-trend-day span, .stats-trend-day small { color: var(--writems-muted); font-size: .75rem; }

@media (max-width: 36rem) {
    html,
    body,
    body#me,
    body#pad,
    .writems-page {
        max-width: 100%;
        overflow-x: hidden;
    }
    .writems-header, .writems-main, .writems-footer { padding-left: 1rem; padding-right: 1rem; }
    .writems-main { padding-top: 3rem; }
    .manage-grid { grid-template-columns: 1fr; }
    .writems-featured-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .stats-list a { align-items: flex-start; flex-direction: column; gap: .3rem; }
    .writems-manage .stats-chart { gap: .25rem; height: 10rem; padding: 0 .25rem 1rem; }
    .writems-manage .stats-chart-bar { width: min(1.5rem, 70%); }
    .writems-manage .stats-chart-day small,
    .writems-manage .stats-chart-day em { font-size: .62rem; }
    .writems-home .writems-recent-list article { padding: 1.25rem; }
    #collection.writems-reader .writems-collection-header,
    #collection.writems-reader #wrapper,
    #collection.writems-reader .writems-reader-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    #collection.writems-reader .writems-collection-header { padding-top: 2.5rem; }
}

/* Stable single-blog layout and owner actions. */
#collection.writems-reader .writems-collection-header,
#collection.writems-reader #wrapper {
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

#collection.writems-reader .writems-collection-header {
    margin-bottom: 4rem;
    margin-top: 3rem;
    width: min(100%, 48rem);
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    text-align: center;
}

#collection.writems-reader #wrapper {
    background: transparent;
    width: min(100%, 49rem);
    padding: .5em 0 1.5em;
}

#collection.writems-reader #wrapper article {
    background: #fff;
    margin-bottom: 2.5rem;
    padding: 1.5rem 4.5rem;
}

#collection.writems-reader #wrapper article .post-title {
    margin-bottom: 1.35rem;
    margin-top: 1.35rem;
}

/* Separate the public entry header from its white reading card. */
body#post {
    background: var(--writems-paper);
    box-shadow: none !important;
    color: var(--writems-ink);
    margin: 0 auto !important;
    max-width: 784px !important;
    width: 100%;
}

body#post > header {
    box-sizing: border-box;
    margin: 0 auto;
    max-width: none;
    padding: 4rem 1.25rem 2.5rem;
    width: 100%;
}

body#post > article#post-body {
    box-sizing: border-box;
    background: #fff;
    border: 0;
    margin: 0 auto 3rem;
    max-width: none;
    padding: 3rem 4.5rem;
    width: 100%;
}

#collection.writems-reader .description {
    margin-left: auto;
    margin-right: auto;
}

#post .entry-owner-actions,
#collection .entry-owner-actions {
    display: inline-flex;
    gap: .9rem;
    margin-left: .8rem;
    opacity: 0;
    transition: opacity .15s ease;
    vertical-align: middle;
}

#post .entry-owner-actions a,
#collection .entry-owner-actions a {
    color: var(--writems-muted);
    font-family: Georgia, serif;
    font-size: .62em;
    font-weight: 400;
    letter-spacing: .08em;
    text-decoration: underline;
    text-underline-offset: .2em;
    white-space: nowrap;
}

#post article:hover .entry-owner-actions,
#post article:focus-within .entry-owner-actions,
#collection article:hover .entry-owner-actions,
#collection article:focus-within .entry-owner-actions {
    opacity: 1;
}

@media (max-width: 36rem) {
    #collection.writems-reader .writems-collection-header,
    #collection.writems-reader #wrapper {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    #collection.writems-reader #wrapper {
        padding-left: 0;
        padding-right: 0;
    }
    #collection.writems-reader #wrapper article {
        border: 1px solid rgba(222, 216, 209, .7);
        padding-block: 1.25rem;
        padding-inline: clamp(.75rem, 4vw, 1.25rem);
    }
    #collection.writems-reader #wrapper article .book {
        font-size: clamp(.95rem, 2.2vw, 1.08rem);
        line-height: 1.7;
    }
    #collection.writems-reader,
    #collection.writems-reader body {
        max-width: 100%;
        overflow-x: hidden;
    }
    #collection.writems-reader #wrapper,
    #collection.writems-reader #wrapper article {
        min-width: 0;
    }
    #collection.writems-reader #wrapper article .book,
    #collection.writems-reader #wrapper article .book * {
        max-width: 100%;
        overflow-wrap: anywhere;
    }
    #collection.writems-reader #wrapper article img,
    #collection.writems-reader #wrapper article video,
    #collection.writems-reader #wrapper article iframe {
        height: auto;
        max-width: 100%;
    }
    #collection.writems-reader #wrapper article pre {
        max-width: 100%;
        overflow-x: auto;
        overflow-wrap: normal;
    }
    body#post > header {
        padding: 2.5rem 1rem 1.5rem;
    }
    body#post > article#post-body {
        border: 0;
        margin-bottom: 1.5rem;
        padding: 1.5rem clamp(.75rem, 4vw, 1.25rem);
        width: 100%;
    }
}

/* Keep owner tools in the same sepia visual language as the public blog. */
body.writems-settings,
body#me,
body#pad.writems-editor {
    background: var(--writems-paper);
    color: var(--writems-ink);
}

body#me #official-writing,
body#me > footer,
body.writems-settings #official-writing,
body.writems-settings .content-container {
    background: var(--writems-paper);
    color: var(--writems-ink);
}

body#me #official-writing {
    min-height: calc(100vh - 8rem);
}

body#me #official-writing .content-container {
    background: var(--writems-paper);
    color: var(--writems-ink);
}

body#me > footer {
    border-top-color: var(--writems-rule);
}

body#me > footer a,
body#me #official-writing a {
    color: var(--writems-ink);
}

body#me #official-writing h1,
body#me #official-writing h2,
body#me #official-writing h3 {
    color: var(--writems-ink);
}

body.writems-settings #official-writing {
    min-height: calc(100vh - 8rem);
}

body.writems-settings .content-container {
    max-width: 48rem;
    padding-bottom: 4rem;
    padding-top: 3rem;
}

body.writems-settings h1,
body.writems-settings h2,
body.writems-settings h3 {
    color: var(--writems-ink);
    font-family: Georgia, serif;
}

body.writems-settings .option {
    border-top: 1px solid var(--writems-rule);
    margin: 0;
    padding: 1.75rem 0;
}

body.writems-settings input[type="text"],
body.writems-settings input[type="password"] {
    background: #fbf9f5;
    border: 1px solid #cfc7bd;
    color: var(--writems-ink);
    font: inherit;
    padding: .65rem .7rem;
}

body.writems-settings input[type="submit"] {
    background: var(--writems-ink);
    border: 1px solid var(--writems-ink);
    color: var(--writems-paper);
    cursor: pointer;
    padding: .65rem .9rem;
}

.writems-settings-stats {
    margin: 1.25rem 0 2rem;
}

.writems-settings-stats a {
    color: var(--writems-muted);
}

.settings-section {
    border-top: 1px solid var(--writems-rule);
    margin-top: 2rem;
    padding-top: 1.75rem;
}

.settings-section h2 {
    margin-top: 0;
}

.settings-intro,
.settings-section .describe,
.settings-note {
    color: var(--writems-muted);
    font-size: .86rem;
}

.settings-blog-title {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.settings-field {
    display: grid;
    gap: .45rem;
}

.settings-field label,
.settings-inline-field label {
    font-size: .86rem;
}

body.writems-settings .settings-field input[type="text"] {
    box-sizing: border-box;
    max-width: 34rem;
    width: 100%;
}

.settings-value {
    margin: .35rem 0;
}

.settings-inline-field {
    margin: .8rem 0 0 1.5rem;
}

.settings-inline-field input {
    margin-left: .5rem;
}

.settings-save {
    margin: 2rem 0 .5rem;
    text-align: right;
}

.settings-table {
    border-collapse: collapse;
    width: 100%;
}

.settings-table th,
.settings-table td {
    border-bottom: 1px solid var(--writems-rule);
    padding: .7rem .5rem;
    text-align: left;
}

.settings-table th:last-child,
.settings-table td:last-child {
    text-align: right;
}

.settings-table tr:last-child td {
    border-bottom: 0;
}

.stats-site-name {
    color: var(--writems-muted);
    margin-top: -1rem;
}

.stats-note {
    margin-top: -.5rem;
}

.writems-manage .stats-chart {
    align-items: end;
    border-bottom: 1px solid var(--writems-rule);
    display: flex;
    gap: .5rem;
    height: 12rem;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding: 0 .75rem 1rem;
}

.writems-manage .stats-chart-day {
    align-items: center;
    display: flex;
    flex: 1;
    flex-direction: column;
    height: 100%;
    justify-content: end;
    min-width: 0;
}

.writems-manage .stats-chart-bar {
    background: #5577b5;
    border-radius: 2px 2px 0 0;
    min-height: 3px;
    position: relative;
    transition: opacity .15s ease;
    width: min(2.25rem, 72%);
}

.writems-manage .stats-chart-bar:hover {
    opacity: .78;
}

.writems-manage .stats-chart-bar span {
    color: var(--writems-muted);
    font-size: .7rem;
    left: 50%;
    position: absolute;
    top: -.1rem;
    transform: translate(-50%, -100%);
}

.writems-manage .stats-chart-day small,
.writems-manage .stats-chart-day em {
    color: var(--writems-muted);
    font-size: .7rem;
    font-style: normal;
    white-space: nowrap;
}

.writems-manage .stats-chart-day small {
    margin-top: .6rem;
}

.stats-table-wrap {
    border: 1px solid var(--writems-rule);
    overflow-x: auto;
}

.writems-manage .stats-table {
    border-collapse: collapse;
    min-width: 34rem;
    width: 100%;
}

.writems-manage .stats-table th,
.writems-manage .stats-table td {
    border-bottom: 1px solid var(--writems-rule);
    padding: .8rem 1rem;
    text-align: left;
    vertical-align: top;
}

.writems-manage .stats-table thead {
    background: #ebe5dd;
}

.writems-manage .stats-table th {
    color: var(--writems-muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.writems-manage .stats-table th:first-child,
.writems-manage .stats-table td:first-child {
    width: 68%;
}

.writems-manage .stats-table td:nth-child(2) {
    color: var(--writems-muted);
    white-space: nowrap;
}

.writems-manage .stats-table th:last-child,
.writems-manage .stats-table td:last-child {
    text-align: right;
    white-space: nowrap;
}

.writems-manage .stats-table tbody tr:last-child td {
    border-bottom: 0;
}

.writems-manage .stats-table tbody tr:hover {
    background: rgba(235, 229, 221, .42);
}

body#pad.writems-editor #tools {
    background: #ebe5dd;
    border-bottom-color: var(--writems-rule);
}

body#pad.writems-editor #writer,
body#pad.writems-editor #editor,
body#pad.writems-editor .ProseMirror {
    background: var(--writems-paper);
    color: var(--writems-ink);
}

body#pad.writems-editor #modal-preview {
    background: var(--writems-paper);
    color: var(--writems-ink);
}

body#pad #tools #wc {
    margin-left: 1.25em;
}

.editor-mode-switch a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: .2em;
}
