/* Loaded by the account, Discover and management views. */
:root {
    color-scheme: dark;
    --canvas: #18171c;
    --surface: #211f28;
    --inset: #19181e;
    --line: #403a49;
    --text: #f2eced;
    --muted: #c0b8c6;
    --accent: #d2bcff;
    --danger: #ffa9ad;
}

body { font: 1rem/1.55 IBMPlexSans, sans-serif; color: var(--text); }
.container { width: min(70rem, calc(100% - 3rem)); min-height: 100vh; }
.header { border-bottom: 1px solid var(--line); gap: 1rem; }
.header #logo { width: 12rem; height: 3.2rem; background-position: left center; }
.header #menu { gap: 1.3rem; }
.content { flex: 1; justify-content: flex-start; padding: clamp(2rem, 5vw, 4rem) 0; color: var(--text); }
.content a { color: var(--accent); text-underline-offset: .22em; }
.content a:hover { text-decoration: underline; }
.content h1 { font-size: clamp(2.1rem, 4.6vw, 3.7rem); line-height: 1.12; letter-spacing: -.045em; overflow-wrap: anywhere; }
.content h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); line-height: 1.35; }
.content h1.centered { text-align: start; margin: 0 0 1.6rem; }
.section-heading { margin-bottom: 2rem; }
.section-heading p, .breadcrumbs, small { color: var(--muted); }
.breadcrumbs { font-size: .9rem; margin-bottom: .85rem; overflow-wrap: anywhere; }
.breadcrumbs a { text-decoration: none; }
.dashboard-heading, .editor-heading, .management-section > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.section-heading h1::first-letter, .account-card h1::first-letter { text-transform: uppercase; }
footer.footer { font: .875rem IBMPlexSans, sans-serif; flex-wrap: wrap; border-color: var(--line); }
.footer a, .footer p, .footer select { color: var(--muted); }

.content .btn {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    height: auto;
    min-height: 2.65rem;
    padding: .55rem 1rem;
    margin: 0;
    font: inherit;
    font-size: .94rem;
    line-height: 1.4;
    border-radius: .55rem;
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--surface);
    box-shadow: none;
    text-align: center;
}
.content .btn:hover { background: #302c39; border-color: #83758e; text-decoration: none; }
.content .btn.purple, .content .btn-new-post { background: var(--accent); border-color: var(--accent); color: #241833; font-weight: bold; }
.content .btn.purple:hover, .content .btn-new-post:hover { background: #e4d5ff; }
.content .btn-delete, .content .danger-link { color: var(--danger); }
.content .btn.active { border-color: var(--accent); color: var(--accent); }

form :is(input[type=text], input[type=password], input[type=search], select, textarea.post_content) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    padding: .7rem .85rem;
    border-radius: .55rem;
    border: 1px solid #5a5262;
    background: var(--inset);
    color: var(--text);
    font: inherit;
    box-shadow: none;
}
form input:is([type=checkbox], [type=radio]) {
    appearance: auto;
    accent-color: var(--accent);
    height: 1.1rem;
    width: 1.1rem;
    flex: none;
    padding: 0;
    box-shadow: none;
    vertical-align: middle;
}
input[type=checkbox]:checked::after { content: none; }
:where(a, button, input, textarea, select, summary):focus-visible,
form input:focus-visible, textarea.post_content:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
article.main-content { padding: 1.5rem 0; text-align: start; }
div.error, div.message { width: 100%; }
.content > form, .content > article { min-width: 0; }
.content .horizontal-fields { max-height: none; }
.settings-logo { max-width: min(100%, 24rem); }

.account-card, .editor-sheet, .management-section, .blog-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .9rem;
}
.account-card {
    width: min(100%, 28rem);
    margin: clamp(.5rem, 4vh, 3rem) auto;
    padding: clamp(1.4rem, 4vw, 2.5rem);
    border-top: 3px solid var(--accent);
}
.account-card h1 { font-size: clamp(1.9rem, 3.5vw, 2.6rem); margin-bottom: 1.75rem; }
.account-form, .account-form label, .editor-tags { display: grid; gap: .45rem; }
.account-form { gap: 1.1rem; }
.account-form .btn { width: 100%; margin-top: .35rem; }
.account-link { display: block; margin-top: 1.35rem; text-align: center; }
.account-link::first-letter { text-transform: uppercase; }

.discover-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}
.discover-heading p { max-width: 32rem; }
.reading-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.5rem; }
.reading-item { padding: 1.4rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.story-byline, .story-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; font-size: .86rem; }
.story-byline span { color: var(--accent); font-weight: bold; }
.story-byline time, .story-meta { color: var(--muted); }
.reading-item h2 { margin: .65rem 0 .85rem; }
.reading-item h2 a { text-decoration: none; color: inherit; }
.reading-item h2 a:hover { text-decoration: underline; }
.lead-story {
    grid-column: 1 / -1;
    padding: clamp(1.3rem, 4vw, 3rem);
    margin-bottom: .65rem;
    border: 0;
    border-inline-start: .35rem solid #8e6bc6;
    border-radius: .4rem;
    background: var(--surface);
}
.lead-story h2 { max-width: 32ch; font-size: clamp(1.8rem, 4vw, 3.25rem); letter-spacing: -.04em; line-height: 1.15; }
.story-excerpt { max-width: 68ch; margin-bottom: 1rem; }
.empty-state { color: var(--muted); }

.dashboard { width: 100%; padding: 0; }
.blogs-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1rem; margin-bottom: 2rem; }
.blog-card, .blog-card:hover { box-shadow: none; transform: none; }
.blog-card-header { border-color: var(--line); }
.blog-card .blog-name { color: var(--text); overflow-wrap: anywhere; }
.blog-favicon { flex: none; font-size: .85em; vertical-align: middle; }
img.blog-favicon { width: 1em; height: 1em; }
.blog-address { overflow-wrap: anywhere; font-size: .94rem; }
.dashboard-settings { background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 1.5rem 0; box-shadow: none; }
.settings-title { text-align: start; margin-bottom: .8rem; }
.settings-actions { justify-content: start; gap: .65rem; }
.management-section { margin-bottom: 1.25rem; padding: clamp(1rem, 3vw, 1.8rem); }
.management-section > header { margin-bottom: 1.1rem; overflow-wrap: anywhere; }
.table-actions, .field-row, .editor-actions, .publish-options { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; }
.blog-settings-form { display: grid; gap: .6rem; max-width: 40rem; }
.blog-settings-form > :is(h3, label:not(:first-child), .editor-actions) { margin-top: .5rem; }
.theme-picker { margin-top: .5rem; min-width: 0; border: 0; }
.theme-picker legend { margin-bottom: .5rem; }
.theme-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr));
    gap: .6rem;
}
.theme-option {
    display: flex;
    flex-direction: column;
    justify-content: end;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: .55rem;
    background: var(--inset);
    cursor: pointer;
}
.theme-option img { width: 100%; height: 5.25rem; object-fit: cover; object-position: top; }
.theme-option span { display: flex; align-items: center; gap: .4rem; padding: .45rem; overflow-wrap: anywhere; }
.theme-option:has(:checked) { border-color: var(--accent); color: var(--accent); }
.theme-option:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.blog-settings-form .emoji-picker-container { width: 4.5rem; }
.blog-settings-form #blog-icon {
    display: block;
    height: 3rem;
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
    background: var(--inset);
    color: var(--text);
    opacity: 1;
}
.blog-settings-form .emoji-picker-trigger {
    inset: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}
.blog-settings-form .emoji-picker-container:focus-within #blog-icon { border-color: var(--accent); }
.blog-settings-form #blog-icon:not(:placeholder-shown) + .emoji-picker-trigger svg { visibility: hidden; }
.blog-settings-form .emoji-picker-open .emoji-picker-trigger::before { content: none; }
.blog-settings-form .emoji-picker-open #blog-icon:placeholder-shown + .emoji-picker-trigger svg { visibility: visible; opacity: 1; }
.blog-settings-form .emoji-picker-open .emoji-picker {
    top: 100%;
    left: 0;
    right: auto;
    max-width: calc(100vw - 4rem);
    color-scheme: dark;
    background: var(--surface);
    border: 1px solid var(--line);
}
.blog-settings-form .emoji-picker-tabs { background: var(--inset); }
.blog-settings-form .emoji-picker-anchor { color: var(--muted); }
.blog-settings-form .emoji-picker-anchor svg:not([fill="none"]) { fill: currentColor; }
.blog-settings-form .emoji-picker-anchor [stroke] { stroke: currentColor; }
.blog-settings-form .emoji-picker-anchor.active,
.blog-settings-form .emoji-picker-anchor:hover,
.blog-settings-form .emoji-picker-emoji:hover { background: var(--line); color: var(--accent); }
.blog-settings-form .emoji-picker-list { overflow: auto; }
.blog-settings-form textarea { min-height: 7rem; }
.danger-section { border-inline-start: 3px solid var(--danger); }
.danger-section p { color: var(--muted); margin: .5rem 0 1rem; }

.admin-directory { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.admin-directory a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1.65rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
    background: var(--surface);
    font: 1.3rem Merriweather, serif;
    color: var(--text);
    text-decoration: none;
}
.admin-directory a::after { content: '→' / ''; color: var(--accent); }
.admin-directory a:hover { border-color: var(--accent); }
.admin-nav { justify-content: start; gap: .35rem; border-bottom: 1px solid var(--line); padding-bottom: .8rem; margin: 0 0 1.6rem; }
.admin-nav a { border-radius: .4rem; padding: .4rem .7rem; color: var(--muted); text-decoration: none; }
.admin-nav a[aria-current] { background: #393041; color: var(--text); }
.admin-filter { background: var(--surface); border: 1px solid var(--line); border-radius: .65rem; padding: .85rem; }
.admin-filter input[type=search] { flex: 1 1 12rem; min-width: 0; }
.admin-pagination { justify-content: space-between; }
.admin-table-scroll { border: 1px solid var(--line); border-radius: .55rem; }
table.table { padding: 0; width: 100%; border-collapse: collapse; }
.table thead th, .table tbody tr:nth-child(n) td { padding: .75rem 1rem; text-align: start; }
table.table thead th { font-size: .88rem; background: #302b37; }
table.table tbody tr:nth-child(n) td { background: var(--surface); border-top: 1px solid var(--line); }
.table td:first-child, .table th:first-child { padding-inline-start: 1rem; }
.table-actions { flex-wrap: nowrap; }
.translation-table input { min-width: 10rem; }
.download-link { margin-top: 1rem; }

article.editor-sheet { padding: clamp(1rem, 2.5vw, 2rem); }
.editor-sheet form { gap: 1rem; font-size: 1rem; }
.editor-sheet input.editor-title {
    padding: .3rem 0 .8rem;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    font: clamp(1.6rem, 3vw, 2.5rem)/1.25 Merriweather, serif;
}
.post-editor-toolbar .small.btn { min-width: 2.35rem; min-height: 2.35rem; max-height: none; max-width: none; padding: .35rem .55rem; }
.syntax-link { margin-inline-start: auto; font-size: .9rem; }
.editor-sheet textarea.post_content { min-height: 25rem; font: 1rem/1.75 ui-monospace, monospace; resize: vertical; }
.live-preview-panel iframe { background: var(--inset); }
.publish-options { padding: .9rem 0; border-block: 1px solid var(--line); }
.publish-options label { display: flex; align-items: center; gap: .4rem; font-size: .94rem; }
.editor-actions { justify-content: flex-end; }
.editor-tags { max-width: 40rem; }
.editor-tags small { font-size: .85rem; }

@media (max-width: 850px) {
    .container { width: calc(100% - 2rem) !important; }
    .header { align-items: flex-start; gap: .5rem; }
    .header #logo { width: 10rem !important; height: 2.65rem; }
    .header #menu { justify-content: flex-start; margin: 0; gap: .4rem 1rem !important; }
    .content .blog-actions { flex-direction: row !important; }
    .blog-actions .btn { flex: 0 1 auto; }
    .settings-actions { flex-direction: row; }
    footer.footer { flex-direction: row !important; justify-content: flex-start; }
}
@media (max-width: 620px) {
    .reading-list { grid-template-columns: minmax(0, 1fr); }
    .section-heading { margin-bottom: 1.25rem; }
    .blog-actions .btn { width: auto; }
    .management-section .table { min-width: 32rem; }
    .syntax-link { margin-inline-start: 0; }
    .admin-filter label[for=admin-search] { width: 100%; }
}

.post-writing-area { display: flex; flex-direction: column; gap: 1rem; }
.post-writing-area .post-editor-options { align-items: center; gap: .5rem; }
.post-editor-options .live-preview-toggle { margin-inline-end: auto; }

/* Keep the same form, textarea and preview frame mounted while expanding. */
body.editor-expanded .container { width: 100% !important; }
.editor-expanded .container > :is(.header, .footer),
.editor-expanded .content > :is(.breadcrumbs, .editor-heading) { display: none; }
.editor-expanded .content { padding: 0; }
.editor-expanded .editor-sheet {
    --editor-padding: clamp(.75rem, 1.5vw, 1.5rem);
    padding: var(--editor-padding);
    border: 0;
    border-radius: 0;
}
.editor-expanded .post-writing-area {
    min-height: calc(100vh - 2 * var(--editor-padding));
    min-height: calc(100dvh - 2 * var(--editor-padding));
}
.editor-expanded .post-editor { flex: 1 0 12rem; }
.editor-expanded .post_content { min-height: 12rem; resize: none; }
.editor-expanded .live-preview-panel { position: relative; min-height: 12rem; }
.editor-expanded .live-preview-panel iframe { position: absolute; inset: 0; min-height: 0; }

@media (max-width: 850px) {
    .editor-expanded .post-editor.has-preview { grid-template-rows: repeat(2, minmax(10rem, 1fr)); }
    .editor-expanded .post-editor.has-preview :is(.post_content, .live-preview-panel) { min-height: 0; }
}

.post-import [hidden] { display: none; }
.post-import #posts-file { display: block; margin: 1rem 0; }
.post-import #posts label { display: block; padding: .25rem 0; }
.post-import .btn:disabled { opacity: .5; cursor: default; }
