/* Newslettr Publisher Server — stylesheet
   Separate from reader (green accent) and admin (amber accent).
   Publisher uses indigo so authors immediately know which site they're on.
*/

/* ── Theme: Lite ──────────────────────────────────────────────────────────── */
:root,
[data-theme="lite"] {
    --bg:              #fafaf8;
    --bg-card:         #ffffff;
    --bg-input:        #ffffff;
    --bg-header:       #ffffff;
    --bg-th:           #f0f0f8;
    --bg-code:         #f0ede8;
    --bg-toolbar:      #f0f0f8;
    --bg-flash-success:#d4edda;
    --bg-flash-error:  #f8d7da;
    --bg-flash-info:   #d1ecf1;
    --bg-flash-warning:#fff3cd;

    --text:            #1a1a1a;
    --text-muted:      #777777;
    --text-dimmer:     #aaaaaa;
    --text-nav:        #555555;
    --text-label:      #333333;
    --text-excerpt:    #444444;

    --border:          #e0ddd8;
    --border-input:    #cccccc;
    --border-header:   #e0ddd8;

    /* Publisher accent: indigo */
    --accent:          #4338ca;
    --accent-hover:    #2d27a0;
    --accent-bg:       #eef2ff;
    --accent-bg-hover: #e0e7ff;

    --danger:          #c0392b;
    --danger-hover:    #922b21;

    --flash-success-text: #155724;
    --flash-success-border: #c3e6cb;
    --flash-error-text:   #721c24;
    --flash-error-border: #f5c6cb;
    --flash-info-text:    #0c5460;
    --flash-info-border:  #bee5eb;
    --flash-warning-text: #856404;
    --flash-warning-border:#ffeeba;

    --shadow-focus:    rgba(67, 56, 202, 0.15);
    --btn-secondary-bg:#ffffff;
    --btn-secondary-hover:#f0f0f8;
    --pagination-border:#cccccc;
}

/* ── Theme: Dark ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg:              #18181b;
    --bg-card:         #27272a;
    --bg-input:        #1f1f23;
    --bg-header:       #1c1c1f;
    --bg-th:           #2a2a3a;
    --bg-code:         #2a2a2f;
    --bg-toolbar:      #2a2a3a;
    --bg-flash-success:#1a3a25;
    --bg-flash-error:  #3a1a1a;
    --bg-flash-info:   #1a2e35;
    --bg-flash-warning:#2e2510;

    --text:            #e8e8e4;
    --text-muted:      #9ca3af;
    --text-dimmer:     #6b7280;
    --text-nav:        #a1a1aa;
    --text-label:      #d1d5db;
    --text-excerpt:    #c4c4bc;

    --border:          #3f3f46;
    --border-input:    #52525b;
    --border-header:   #3f3f46;

    --accent:          #818cf8;
    --accent-hover:    #a5b4fc;
    --accent-bg:       #1e1b4b;
    --accent-bg-hover: #2a2570;

    --danger:          #f87171;
    --danger-hover:    #fca5a5;

    --flash-success-text: #86efac;
    --flash-success-border:#166534;
    --flash-error-text:   #fca5a5;
    --flash-error-border: #7f1d1d;
    --flash-info-text:    #7dd3fc;
    --flash-info-border:  #0c4a6e;
    --flash-warning-text: #fcd34d;
    --flash-warning-border:#78350f;

    --shadow-focus:    rgba(129, 140, 248, 0.2);
    --btn-secondary-bg:#27272a;
    --btn-secondary-hover:#3f3f46;
    --pagination-border:#52525b;
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    margin: 0;
    font-family: "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: underline; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin: 1.5rem 0 0.75rem;
    color: var(--text);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */

.site-header {
    background: var(--bg-header);
    border-bottom: 3px solid var(--accent);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.site-header .brand .badge {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
}

.site-header nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex: 1;
}

.site-header nav a {
    font-size: 0.9rem;
    color: var(--text-nav);
    text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a.active { color: var(--accent); }

.site-header .header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.header-user {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-content {
    max-width: 820px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4rem;
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */

.theme-toggle {
    background: none;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-nav);
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Flash messages ───────────────────────────────────────────────────────── */

.flash-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }

.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash.success { background: var(--bg-flash-success); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }
.flash.error   { background: var(--bg-flash-error);   color: var(--flash-error-text);   border: 1px solid var(--flash-error-border); }
.flash.info    { background: var(--bg-flash-info);    color: var(--flash-info-text);    border: 1px solid var(--flash-info-border); }
.flash.warning { background: var(--bg-flash-warning); color: var(--flash-warning-text); border: 1px solid var(--flash-warning-border); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.5;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary { background: var(--btn-secondary-bg); color: var(--text); border-color: var(--border-input); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.4rem; font-size: 1rem; }

.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-label);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-input);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--shadow-focus);
}

.form-control.error { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 120px; }

.field-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.3rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    align-items: center;
}

/* ── Topic badge ──────────────────────────────────────────────────────────── */

.topic-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--accent-bg);
    color: var(--accent);
    text-decoration: none;
    vertical-align: middle;
}

.topic-badge:hover { background: var(--accent-bg-hover); color: var(--accent-hover); }

/* ── Post/link list ───────────────────────────────────────────────────────── */

.post-list { list-style: none; padding: 0; margin: 0; }

.post-list-item {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
}

.post-list-item:last-child { border-bottom: none; }

.post-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.post-title a { color: var(--text); text-decoration: none; }
.post-title a:hover { color: var(--accent); }

.post-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ── Page headers and digest flow ─────────────────────────────────────────── */

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0.1rem 0 0.35rem;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lede {
    max-width: 42rem;
    margin: 0;
    color: var(--text-muted);
}

.digest-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.digest-panel-header,
.section-heading-row,
.newsletter-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.digest-panel-header h2,
.section-heading-row h2 {
    margin-top: 0;
}

.digest-plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.9rem;
}

.digest-plan-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    background: var(--bg);
}

.digest-plan-card.is-due {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--shadow-focus);
}

.digest-card-topline,
.digest-counts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.digest-plan-card h3 {
    margin: 0.7rem 0 0.25rem;
    font-size: 1rem;
}

.digest-timing {
    min-height: 2.8rem;
    color: var(--text-muted);
    font-size: 0.86rem;
    margin-bottom: 0.9rem;
}

.digest-counts {
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.digest-counts span,
.status-pill,
.cadence-pill,
.muted-count {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.digest-counts span {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    background: var(--bg-card);
}

.digest-counts strong {
    color: var(--text);
}

.status-pill,
.cadence-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    color: var(--text-muted);
    background: var(--bg-card);
    white-space: nowrap;
}

.status-due {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

.muted-count {
    color: var(--text-muted);
    padding-top: 0.25rem;
}

.newsletter-section {
    margin-top: 2rem;
}

.newsletter-row {
    align-items: center;
}

.email-preview-shell {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    padding: 0.75rem;
}

.email-preview-frame {
    width: 100%;
    min-height: 720px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
}

/* ── Compose toolbar ──────────────────────────────────────────────────────── */

.compose-toolbar {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    background: var(--bg-toolbar);
    border: 1px solid var(--border-input);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.compose-toolbar button {
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border-input);
    border-radius: 3px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
}

.compose-toolbar button:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

#post-body {
    border-radius: 0 0 4px 4px;
    min-height: 320px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1rem;
    line-height: 1.75;
}

.char-counter {
    text-align: right;
    font-size: 0.78rem;
    color: var(--text-dimmer);
    margin-top: 0.25rem;
}

.char-counter.over { color: var(--danger); font-weight: 600; }

/* ── Draft badge ──────────────────────────────────────────────────────────── */

.draft-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--bg-th);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    vertical-align: middle;
}

/* ── Newsletter preview ───────────────────────────────────────────────────── */

.newsletter-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2rem 2.5rem;
    max-width: 640px;
    margin: 0 auto;
}

.newsletter-preview h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
}

.newsletter-preview .issue-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.newsletter-preview .entry + .entry {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

/* ── Rendered AML content ─────────────────────────────────────────────────── */

.post-body .colorblock,
.aml-preview .colorblock,
.newsletter-preview .colorblock {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    max-width: 100%;
    margin: 0 0.1rem;
    border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
    border-radius: 6px;
    padding: 0.03rem 0.4rem;
    background: color-mix(in srgb, currentColor 9%, transparent);
    color: var(--aml-gray);
    vertical-align: baseline;
}

.post-body .colorblock .sigil,
.aml-preview .colorblock .sigil,
.newsletter-preview .colorblock .sigil {
    flex: 0 0 auto;
    font-size: 0.8em;
    line-height: 1;
}

.post-body .colortext-content,
.aml-preview .colortext-content,
.newsletter-preview .colortext-content {
    color: var(--text);
}

.color-red,
.post-body .colorblock.color-red,
.aml-preview .colorblock.color-red,
.newsletter-preview .colorblock.color-red { color: var(--aml-red); }
.color-orange,
.post-body .colorblock.color-orange,
.aml-preview .colorblock.color-orange,
.newsletter-preview .colorblock.color-orange { color: var(--aml-orange); }
.color-yellow,
.color-quote,
.post-body .colorblock.color-yellow,
.post-body .colorblock.color-quote,
.aml-preview .colorblock.color-yellow,
.aml-preview .colorblock.color-quote,
.newsletter-preview .colorblock.color-yellow,
.newsletter-preview .colorblock.color-quote { color: var(--aml-yellow); }
.color-green,
.post-body .colorblock.color-green,
.aml-preview .colorblock.color-green,
.newsletter-preview .colorblock.color-green { color: var(--aml-green); }
.color-teal,
.post-body .colorblock.color-teal,
.aml-preview .colorblock.color-teal,
.newsletter-preview .colorblock.color-teal { color: var(--aml-teal); }
.color-blue,
.post-body .colorblock.color-blue,
.aml-preview .colorblock.color-blue,
.newsletter-preview .colorblock.color-blue { color: var(--aml-blue); }
.color-violet,
.post-body .colorblock.color-violet,
.aml-preview .colorblock.color-violet,
.newsletter-preview .colorblock.color-violet { color: var(--aml-violet); }
.color-mogue,
.post-body .colorblock.color-mogue,
.aml-preview .colorblock.color-mogue,
.newsletter-preview .colorblock.color-mogue { color: var(--aml-mogue); }
.color-gray,
.post-body .colorblock.color-gray,
.aml-preview .colorblock.color-gray,
.newsletter-preview .colorblock.color-gray { color: var(--aml-gray); }
.color-hazel,
.post-body .colorblock.color-hazel,
.aml-preview .colorblock.color-hazel,
.newsletter-preview .colorblock.color-hazel { color: #8a5a2b; }
.color-xantham,
.post-body .colorblock.color-xantham,
.aml-preview .colorblock.color-xantham,
.newsletter-preview .colorblock.color-xantham { color: var(--aml-xantham); }

.mlq {
    border-left: 3px solid currentColor;
    margin: 1rem 0;
    padding: 0.75rem 0 0.75rem 0.85rem;
    color: var(--text-muted);
    background: color-mix(in srgb, currentColor 7%, transparent);
}

.mlq-collapse {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: currentColor;
    padding: 0.1rem 0.45rem;
    margin-bottom: 0.5rem;
}

.mlq-content {
    color: var(--text);
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-th);
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-label);
}

.data-table td {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-th); }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Channel access editor (radio access level + grant checkboxes) ────────── */
.radio-option, .checkbox-option {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.3rem 0;
}
.radio-option input, .checkbox-option input { margin: 0; }
.grant-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-height: 18rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}
.checkbox-option .muted { color: var(--text-muted); font-size: 0.85rem; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */

.auth-wrap {
    display: flex;
    min-height: calc(100vh - 56px);
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2rem 2.5rem;
}

.auth-card h1 { font-size: 1.4rem; margin-top: 0; }

.auth-card .auth-alt {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}

/* Separates the password form from the OAuth button, with "or" over the rule. */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.btn-oauth { display: block; text-align: center; }

/* ── Pagination ───────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 2rem;
    list-style: none;
    padding: 0;
    font-size: 0.88rem;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--pagination-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { color: var(--text-dimmer); cursor: not-allowed; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .site-header { padding: 0 1rem; }
    .main-content { padding: 0 1rem; }
    .page-header,
    .digest-panel-header,
    .section-heading-row,
    .newsletter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .newsletter-preview { padding: 1.25rem 1rem; }
    .email-preview-frame { min-height: 620px; }
    .auth-wrap { align-items: flex-start; padding-top: 3rem; }
}

/* ===========================================================================
   AML content colors + composer
   These are the *semantic content* colors (post body markup), distinct from
   the indigo UI accent. Each color renders as a left-bordered block with a
   leading sigil. Tuned for both lite and dark themes.
   =========================================================================== */
:root, [data-theme="lite"] {
  --aml-xantham: #b1003e;  /* infra-red: sarcastic */
  --aml-red:     #b3261e;  /* forceful opinion */
  --aml-orange:  #b35a00;  /* counterpoint */
  --aml-yellow:  #8a6d00;  /* quotes */
  --aml-green:   #1a6b3c;  /* technical / meta */
  --aml-teal:    #0f7a86;  /* LLM output */
  --aml-blue:    #1f5fbf;  /* voice from beyond */
  --aml-violet:  #6b2fb3;  /* serious */
  --aml-mogue:   #8a2be2;  /* ultra-violet: actions taken */
  --aml-gray:    #6b6b6b;  /* past stories */
}
[data-theme="dark"] {
  --aml-xantham: #ff6b9d;
  --aml-red:     #ff6b5e;
  --aml-orange:  #ffa040;
  --aml-yellow:  #e6c84d;
  --aml-green:   #4ade80;
  --aml-teal:    #4dd0e1;
  --aml-blue:    #6ea8ff;
  --aml-violet:  #c08bff;
  --aml-mogue:   #d08bff;
  --aml-gray:    #b0b0b0;
}

/* Two-pane composer: editor + live preview */
.compose-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .compose-split { grid-template-columns: 1fr; }
}
.compose-pane h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.aml-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  min-height: 18rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.aml-preview .placeholder { color: var(--text-dimmer); font-style: italic; }

/* A colored AML block */
.aml-color {
  display: block;
  border-left: 3px solid currentColor;
  padding-left: 0.6rem;
  margin: 0.35rem 0;
}
.aml-color > .sigil { margin-right: 0.4rem; opacity: 0.9; }
.aml-color > .body  { color: var(--text); }

.aml-xantham { color: var(--aml-xantham); }
.aml-red     { color: var(--aml-red); }
.aml-orange  { color: var(--aml-orange); }
.aml-yellow  { color: var(--aml-yellow); }
.aml-green   { color: var(--aml-green); }
.aml-teal    { color: var(--aml-teal); font-family: "Comic Sans MS", "Comic Sans", cursive; }
.aml-blue    { color: var(--aml-blue); }
.aml-violet  { color: var(--aml-violet); }
.aml-mogue   { color: var(--aml-mogue); }
.aml-gray    { color: var(--aml-gray); }

/* Block quote (<<< >>>) and inline literal (<< >>) */
.aml-preview blockquote {
  border-left: 3px solid var(--border-input);
  margin: 0.5rem 0;
  padding: 0.25rem 0 0.25rem 0.75rem;
  color: var(--text-excerpt);
}
.aml-literal { color: var(--text-muted); }
.aml-wikilink { color: var(--accent); border-bottom: 1px dotted var(--accent); }
.aml-preview hr { border: 0; border-top: 1px solid var(--border); margin: 0.9rem 0; }

/* Color-scheme legend */
.aml-legend {
  list-style: none;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.15rem 1rem;
  font-size: 0.82rem;
}
.aml-legend li { display: flex; gap: 0.4rem; align-items: baseline; }
.aml-legend code { font-weight: 600; }
.aml-legend .desc { color: var(--text-muted); }

/* ── Related-post references (flat "see also" links on a post page) ────────── */
.post-references { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--border); }
.post-references h2 { font-size: 1rem; color: var(--text-muted); margin: 0 0 0.5em; }
.post-references ul { margin: 0; padding-left: 1.2em; }

/* ── Quotes (list, editor, and post-attached display) ─────────────────────── */
.post-quotes { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--border); }
.post-quotes h2 { font-size: 1rem; color: var(--text-muted); margin: 0 0 0.5em; }
.quote { margin: 0 0 1em; }
.quote-text { margin: 0; font-style: italic; border-left: 3px solid var(--border); padding-left: 0.8em; }
.quote-cite { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.3em; }
.quote-actions { display: flex; gap: 1em; align-items: center; font-size: 0.85rem; }
.quote-actions form { display: inline; margin: 0; }
.quote-usage { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--border); }
.quote-usage h2 { font-size: 1rem; color: var(--text-muted); margin: 0 0 0.5em; }
.quote-usage .topic-badge { margin-left: 0.5em; }
.filter-form { display: flex; gap: 0.5em; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1em; }
.filter-form .form-group { margin: 0; }
.link-button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.link-button:hover { color: var(--color-red, currentColor); }
.empty-state { color: var(--text-muted); font-style: italic; }

/* ── Images (library grid, cards, and the editor preview) ─────────────────── */
.image-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}
.image-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}
.image-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg, #eee);
}
.image-card-body { padding: 0.75rem 0.9rem; }
.image-caption { margin: 0 0 0.4rem; font-weight: 600; }
.image-caption.needs-caption { font-weight: 400; font-style: italic; }
.image-caption.needs-caption a { color: var(--color-red, var(--accent)); }
.image-preview { margin: 0 0 1.5rem; }
.image-preview-img {
  max-width: 100%;
  max-height: 24rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}
.image-preview figcaption { margin-top: 0.4rem; }

/* ── Collections (galleries: dropzone, sortable photo grid, cards) ────────── */
.collection-create { margin-bottom: 2rem; }
.collection-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}
.collection-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}
.collection-cover-link { display: block; }
.collection-cover {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background: var(--bg, #eee);
}
.collection-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
}
.collection-name { margin: 0 0 0.4rem; font-weight: 600; }
.collection-settings { margin-top: 2rem; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-card);
  transition: border-color 0.15s ease, background-color 0.15s ease;
  margin-bottom: 0.5rem;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone-over {
  border-color: var(--accent);
  background: var(--btn-secondary-bg, var(--bg-card));
}
.dropzone-busy { opacity: 0.6; pointer-events: none; }
.dropzone-title { margin: 0 0 0.25rem; font-weight: 600; }
.dropzone-hint { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
/* Visually hidden but still form-submittable for the no-JS fallback. */
.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.photo-grid {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.9rem;
}
.photo-cell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
  cursor: grab;
}
.photo-cell:active { cursor: grabbing; }
.photo-cell-dragging { opacity: 0.45; outline: 2px dashed var(--accent); }
.photo-cell-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bg, #eee);
  pointer-events: none;
}
.photo-cell-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.5rem;
  background: rgba(0, 0, 0, 0.55);
}
.photo-cell-edit { color: #fff; font-size: 0.8rem; text-decoration: none; }
.photo-cell-edit:hover { text-decoration: underline; color: #fff; }
.photo-cell-remove {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}
.photo-cell-remove:hover { color: var(--danger, #f66); }
