/* ============================================================
    Microblog
   ============================================================ */

:root {
    --bg:           #f5f2eb;
    --surface:      #ffffff;
    --border:       #d4cfc5;
    --text:         #1a1814;
    --text-muted:   #6b6560;
    --accent:       #3d5a3e;
    --accent-hover: #2c4130;
    --danger:       #8b2e2e;
}

*, *::before, *::after {
    box-sizing: border-box;
}


html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 20px;
    line-height: 1.6;
    background: transparent;
    color: var(--text);
}

h1, h2, h3 {
    line-height: 1.3;
}

a {
    color: var(--accent);
}

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

/* ------------------------------------------------------------------
   Focus visibility — applies everywhere, no exceptions
   ------------------------------------------------------------------ */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
   Sticky top nav
   ------------------------------------------------------------------ */

.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
}

.site-name {
font-weight: 700;
font-size: 1.05rem;
letter-spacing: -0.01em;
text-decoration: none;
color: var(--text);
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.site-icon {
width: 28px;
height: 28px;
border-radius: 50%;
object-fit: cover;
flex-shrink: 0;
}

.topnav nav a {
    margin-left: 0.25rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.nav-icon {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.15em;
    fill: currentColor;
}

.nav-sep {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.topnav nav a:hover {
    color: var(--text);
}

/* ------------------------------------------------------------------
   Main content wrapper
   ------------------------------------------------------------------ */

main {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}


/* ------------------------------------------------------------------
   Compose / New Post area
   ------------------------------------------------------------------ */

.compose-wrapper {
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--site-post-color, var(--surface));
    overflow: hidden;
}

.compose-toggle {
    display: block;
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    list-style: none;       /* Firefox */
    user-select: none;
}

/* Hide the default disclosure triangle in all browsers */
.compose-toggle::-webkit-details-marker { display: none; }
.compose-toggle::marker               { content: ""; }

.compose-wrapper[open] .compose-toggle {
    border-bottom: 1px solid var(--border);
}

.compose-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem 1rem 1rem;
}

.compose-form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    resize: vertical;
    min-height: 90px;
    background: var(--bg);
    color: var(--text);
}

.compose-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(61, 90, 62, 0.18);
}

.media-field-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.compose-form input[type="file"],
.media-edit-block input[type="file"] {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.visibility-options {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.visibility-options label {
    font-weight: 400;
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.unlisted-badge {
    color: var(--accent);
    font-size: 0.78rem;
}

.private-badge {
    color: var(--danger);
    font-size: 0.78rem;
}

.unlisted-badge,
.private-badge,
.public-badge {
    text-decoration: none;
}

.public-badge {
    color: var(--text-muted);
}

.unlisted-badge:hover,
.private-badge:hover,
.public-badge:hover {
    opacity: 0.75;
}

/* ------------------------------------------------------------------
   Edit form extras
   ------------------------------------------------------------------ */

.edit-wrapper {
    padding: 1rem 1rem 1.25rem;
}

.edit-wrapper h1 {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
}

.media-edit-block {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}

.media-edit-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.media-edit-item label {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.media-preview {
    width: 90px;
    height: 70px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* ------------------------------------------------------------------
   Feed container
   ------------------------------------------------------------------ */

.feed-empty {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-muted);
}

.tag-filter-banner {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.tag-filter-banner a {
    color: var(--accent);
}

/* ------------------------------------------------------------------
   Post card
   ------------------------------------------------------------------ */

.post-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.post-private {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--site-post-color, var(--surface));
}

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

/* Author avatar + name block (links to profile) */
.post-author {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
    min-width: 0;           /* allow truncation of long usernames */
}

.post-author:hover .username {
    text-decoration: underline;
}

/* Real avatar image */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Fallback initial circle when no avatar has been uploaded yet */
.avatar-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    user-select: none;
}

.post-author-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.username {
    font-family: "Courier New", Courier, monospace;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tagline {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.05rem;
}

/* Post body text */
.post-body {
    word-break: break-word;
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.post-body a {
    color: var(--accent);
    font-weight: 600;
}


.post-body > *:first-child {
    margin-top: 0;
}
.post-body > *:last-child {
    margin-bottom: 0;
}
.post-body p {
    margin: 0.5em 0;
}
.post-body ul, .post-body ol {
    margin: 0.5em 0 0.5em 1.5em;
    padding-left: 0;
}
.post-body li {
    margin-bottom: 0.2em;
}
.post-body li:last-child {
    margin-bottom: 0;
}

/* Timestamp row — also holds Edit/Delete for authors */
.post-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.post-meta time {
    font-family: "Courier New", Courier, monospace;
}

/* Author-only action links */
.post-actions {
    display: flex;
    gap: 0.6rem;
    flex-shrink: 0;
}

.post-actions a {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
}

.post-actions a:hover { color: var(--text); }

.delete-form {
    display: inline;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
}

.link-button:hover,
.danger-link:hover {
    color: var(--danger);
}

/* ------------------------------------------------------------------
   Tag pills
   ------------------------------------------------------------------ */

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
}

.tag-pill {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
    text-decoration: none;
}

.tag-pill:hover {
    background: rgba(0, 0, 0, 0.16);
}

/* ------------------------------------------------------------------
   Post media
   ------------------------------------------------------------------ */

.post-media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    border-radius: 4px;
    overflow: hidden;
}

.post-media-gallery img,
.post-media-gallery video {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    border-radius: 3px;
}

/* Single item: full width, taller */
.post-media-gallery:has(> :only-child) img,
.post-media-gallery:has(> :only-child) video {
    height: auto;
    max-height: 480px;
    object-fit: contain;
    background: #111;
}

.post-media img,
.post-media video {
    width: 100%;
    border-radius: 3px;
    margin-bottom: 0.6rem;
}

/* ------------------------------------------------------------------
   Secret link block (private post owner view)
   ------------------------------------------------------------------ */

.secret-link-block {
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
    margin-bottom: 0.6rem;
}

.secret-link-fallback {
    font-family: "Courier New", Courier, monospace;
    font-size: 0.78rem;
    word-break: break-all;
    margin: 0.4rem 0 0;
}

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */

button {
    font-family: inherit;
}

.btn-primary {
    align-self: flex-start;
    padding: 0.5rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.25rem;
    transition: background-color 0.15s;
}

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


/* ------------------------------------------------------------------
   Profile header (public profile page)
   ------------------------------------------------------------------ */

.profile-header {
    position: relative;
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    text-align: left;
}
.profile-username {
    margin: 0;
    font-family: "Courier New", Courier, monospace;
    font-size: 1.5rem;
    text-align: center;
    width: 100%;
}
.profile-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
}
.profile-left {
flex: 0 0 33.333%;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 0.5rem;
}
.profile-right {
flex: 1;
display: flex;
align-items: center;
}
.profile-avatar {
width: 120px;
height: 120px;
border-radius: 50%;
object-fit: cover;
font-size: 2.5rem;
}
.profile-avatar.avatar-initial {
width: 120px;
height: 120px;
}
.profile-tagline {
margin: 0;
color: var(--text-muted);
max-width: 100%;
}
@media (max-width: 600px) {
.profile-content {
flex-direction: column;
text-align: center;
}
.profile-left {
flex: none;
width: 100%;
}
.profile-right {
width: 100%;
justify-content: center;
}
}

.profile-avatar {
width: 120px;
height: 120px;
border-radius: 50%;
object-fit: cover;
font-size: 2.5rem;
}
.profile-avatar.avatar-initial {
width: 120px;
height: 120px;
}
.profile-username {
margin: 0;
font-family: "Courier New", Courier, monospace;
font-size: 1.5rem;
}
.profile-tagline {
margin: 0;
color: var(--text-muted);
max-width: 100%;
}
@media (max-width: 600px) {
.profile-header {
flex-direction: column;
text-align: center;
}
.profile-left {
flex: none;
width: 100%;
}
.profile-right {
width: 100%;
justify-content: center;
}
}

/* ------------------------------------------------------------------
   Avatar editor (profile settings)
   ------------------------------------------------------------------ */

.avatar-edit-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.85rem;
    margin-bottom: 0.4rem;
}

.avatar-preview {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    font-size: 1.5rem;
}

.avatar-preview.avatar-initial {
    width: 72px;
    height: 72px;
}

/* ------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------ */

.pagination {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 1.5rem 0 0;
}

.pagination a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.pagination a:hover { color: var(--text); }

/* ------------------------------------------------------------------
   Generic forms (register, login, profile, compose, edit)
   ------------------------------------------------------------------ */

form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 380px;
}

.compose-form,
.media-edit-block + .compose-footer,
form[action^="/profile"],
form[action^="/admin/site-info"],
form[action^="/admin/settings"] {
max-width: none;
}

form + p { margin-top: 0.75rem; }

label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-top: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="color"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}

input[type="color"] {
    padding: 0.3rem;
    height: 2.6rem;
    cursor: pointer;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(61, 90, 62, 0.18);
}

.font-preview {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0.3rem 0 0.6rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 3px;
    background: var(--bg);
}

/* Inline validation / status messages */
.field-error {
    color: var(--danger);
    font-size: 0.82rem;
    margin: 0.1rem 0 0;
}

.flash-success {
    color: var(--accent);
    font-size: 0.875rem;
    background: rgba(61, 90, 62, 0.08);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 0.5rem 0.75rem;
    margin: 0 0 0.75rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ------------------------------------------------------------------
   Error pages (404, 403, 500)
   ------------------------------------------------------------------ */

.error-page {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5rem 1rem;
}

.error-page h1 {
    margin-bottom: 0.4rem;
}

/* ------------------------------------------------------------------
Settings page sections
------------------------------------------------------------------ */
.settings-section {
background: var(--site-post-color, var(--bg));
border: 1px solid var(--border);
border-radius: 4px;
padding: 1.25rem;
margin-bottom: 1.5rem;
}
.settings-section h2 {
margin: 0 0 1rem;
font-size: 1.1rem;
border-bottom: 1px solid var(--border);
padding-bottom: 0.5rem;
}
.settings-section h3 {
margin: 1.5rem 0 0.5rem;
font-size: 0.95rem;
color: var(--text-muted);
}
.color-input-row {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.5rem;
}

.remove-checkbox {
font-size: 0.85rem;
color: var(--danger);
display: inline-flex;
align-items: center;
gap: 0.3rem;
cursor: pointer;
margin-top: 0.25rem;
}
.remove-checkbox input {
cursor: pointer;
}

/* ------------------------------------------------------------------
Background image preview with X-to-delete
------------------------------------------------------------------ */
.bg-preview-container {
position: relative;
display: inline-block;
margin-bottom: 0.75rem;
}
.bg-preview-container:has(input[type="checkbox"]:checked) {
    display: none;
}
.bg-preview-thumb {
width: 160px;
height: 90px;
object-fit: cover;
border-radius: 4px;
border: 1px solid var(--border);
display: block;
}
.remove-x-btn {
position: absolute;
top: -8px;
right: -8px;
width: 22px;
height: 22px;
background: var(--danger, #e74c3c);
color: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 14px;
font-weight: bold;
line-height: 1;
border: 2px solid var(--surface, #fff);
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
padding: 0;
}
.remove-x-btn input[type="checkbox"] {
position: absolute;
opacity: 0;
width: 100%;
height: 100%;
top: 0;
left: 0;
cursor: pointer;
margin: 0;
}
.remove-x-btn:hover {
background: #c0392b;
}

/* ------------------------------------------------------------------
Background image editor (side-by-side preview + controls)
------------------------------------------------------------------ */
.bg-image-row {
display: flex;
gap: 1rem;
align-items: flex-start;
margin-bottom: 1rem;
}
.bg-image-row .bg-preview-container {
flex-shrink: 0;
}
.bg-image-controls {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.5rem;
min-width: 0;
}
.bg-image-controls label {
font-size: 0.85rem;
margin-top: 0;
}
.bg-image-controls input[type="file"] {
font-size: 0.85rem;
}
.bg-image-controls input[type="range"] {
width: 100%;
margin-top: 0.2rem;
}
/* When there's no preview, controls take full width */
.bg-image-row:has(.bg-preview-container) .bg-image-controls {
flex: 1;
}
.bg-image-row:not(:has(.bg-preview-container)) .bg-image-controls {
flex: 1;
}

/* ------------------------------------------------------------------
Inline opacity slider row
------------------------------------------------------------------ */
.opacity-row {
display: flex;
align-items: center;
gap: 0.75rem;
margin-top: 0.25rem;
}
.opacity-row label {
margin-top: 0;
white-space: nowrap;
flex-shrink: 0;
}
.opacity-row input[type="range"] {
flex: 1;
margin-top: 0;
}
/* ------------------------------------------------------------------
Site settings sections (reuse user settings styles)
------------------------------------------------------------------ */
.settings-section h2 {
margin: 0 0 1rem;
font-size: 1.1rem;
border-bottom: 1px solid var(--border);
padding-bottom: 0.5rem;
}

.bg-image-row {
display: flex;
gap: 1rem;
align-items: flex-start;
margin-bottom: 1rem;
}

.bg-image-row .bg-preview-container {
flex-shrink: 0;
}

.bg-image-controls {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.5rem;
min-width: 0;
}

.bg-image-controls label {
font-size: 0.85rem;
margin-top: 0;
}

.bg-image-controls input[type="file"] {
font-size: 0.85rem;
}

.bg-image-controls input[type="range"] {
width: 100%;
margin-top: 0.2rem;
}


.icon-preview-thumb {
width: 160px;
height: 90px;
object-fit: contain;
border-radius: 4px;
border: 1px solid var(--border);
display: block;
background: var(--bg);
}

.favicon-preview-thumb {
width: 160px;
height: 90px;
object-fit: contain;
border-radius: 4px;
border: 1px solid var(--border);
display: block;
background: var(--bg);
}


/* ------------------------------------------------------------------
Admin panel tables
------------------------------------------------------------------ */
.admin-table-wrapper {
    overflow-x: auto;
    margin-top: 0.75rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table thead th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

.admin-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.admin-table a {
    color: var(--accent);
    text-decoration: none;
}

.admin-table a:hover {
    text-decoration: underline;
}

.admin-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ------------------------------------------------------------------
Admin dashboard cards
------------------------------------------------------------------ */
.admin-dashboard {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
margin-top: 1rem;
}
.admin-dashboard-card {
display: block;
background: var(--site-post-color, var(--bg));
border: 1px solid var(--border);
border-radius: 4px;
padding: 1.25rem;
text-decoration: none;
color: var(--text);
transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-dashboard-card:hover {
border-color: var(--accent);
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.admin-dashboard-card h2 {
margin: 0 0 0.4rem;
font-size: 1.1rem;
border-bottom: none;
padding-bottom: 0;
color: var(--accent);
}
.admin-dashboard-card p {
margin: 0;
font-size: 0.875rem;
color: var(--text-muted);
}
.admin-show-all-bar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.75rem;
font-size: 0.875rem;
color: var(--text-muted);
}
.admin-show-all-bar a {
white-space: nowrap;
}

.admin-table tr.error-row td {
    background: rgba(139, 46, 46, 0.05);
    color: var(--danger);
    font-weight: 600;
}
html[data-theme="dark"] .admin-table tr.error-row td {
    background: rgba(212, 112, 112, 0.1);
}

/* ============================================================
   Theme toggle + text size toggle
   ============================================================ */

/* ---- Dark mode variables ----------------------------------- */
html[data-theme="dark"] {
  --bg:           #1a1814;
  --surface:      #262320;
  --border:       #3d3832;
  --text:         #e8e4dc;
  --text-muted:   #9a948c;
  --accent:       #7fa882;
  --accent-hover: #9bc29e;
  --danger:       #d47070;
  color-scheme:   dark;
}

/* ---- Dark mode: override inline styles --------------------- */
/* ---- Dark mode: override inline styles --------------------- */
html[data-theme="dark"] body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 24, 20, 0.75);
    z-index: -1;
    pointer-events: none;
}

html[data-theme="dark"] body::before {
    filter: none !important;
}

html[data-theme="dark"] .topnav {
  background-color: #262320 !important;
  border-bottom-color: #3d3832 !important;
}

/* Post cards: override inline background-color from user preferences */
html[data-theme="dark"] .post-card {
    background-color: color-mix(in srgb, var(--post-bg, #f0ece4) 40%, #1a1814 60%) !important;
    border-color: #3d3832 !important;
    border-left-color: color-mix(in srgb, var(--post-border, #a8a49e) 40%, #1a1814 60%) !important;
}

/* Darken post card background images in dark mode */
html[data-theme="dark"] .post-card::before {
    filter: brightness(0.4) !important;
}

/* Profile page: tint the user's custom profile/post color */
html[data-theme="dark"] .profile-header {
    background-color: color-mix(in srgb, var(--profile-bg, #f0ece4) 40%, #1a1814 60%) !important;
    border-color: #3d3832 !important;
    border-left-color: color-mix(in srgb, var(--profile-border, #a8a49e) 40%, #1a1814 60%) !important;
}

/* Profile page: override inline background-color */

html[data-theme="dark"] .profile-header {
  background-color: #262320 !important;
  border-color: #3d3832 !important;
}
/* ---- Dark mode: element-specific overrides ----------------- */
html[data-theme="dark"] .tag-pill {
  background: rgba(255, 255, 255, 0.10);
}
html[data-theme="dark"] .tag-pill:hover {
  background: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .post-media-gallery:has(> :only-child) img,
html[data-theme="dark"] .post-media-gallery:has(> :only-child) video {
  background: #000;
}

html[data-theme="dark"] .flash-success {
  background: rgba(127, 168, 130, 0.12);
  border-color: var(--accent);
}

html[data-theme="dark"] .admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .admin-dashboard-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .signin-bar {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .compose-wrapper {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .compose-form textarea {
  background: var(--bg);
  border-color: var(--border);
}

html[data-theme="dark"] .compose-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(127, 168, 130, 0.18);
}

html[data-theme="dark"] .settings-section {
  background: var(--bg);
  border-color: var(--border);
}

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="color"] {
  background: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] input[type="text"]:focus,
html[data-theme="dark"] input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(127, 168, 130, 0.18);
}

html[data-theme="dark"] .font-preview {
  background: var(--bg);
  border-color: var(--border);
}

html[data-theme="dark"] .bg-preview-thumb,
html[data-theme="dark"] .icon-preview-thumb,
html[data-theme="dark"] .favicon-preview-thumb {
  background: var(--site-post-color, var(--bg));
  border-color: var(--border);
}

html[data-theme="dark"] .remove-x-btn {
  border-color: var(--surface);
}

html[data-theme="dark"] .avatar-initial {
  background: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .post-private {
  background: var(--surface);
}

html[data-theme="dark"] .admin-table thead th {
  background: var(--surface);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .admin-dashboard-card {
  background: var(--bg);
  border-color: var(--border);
}



html[data-theme="dark"] .media-preview {
  border-color: var(--border);
}

html[data-theme="dark"] .secret-link-block {
  border-top-color: var(--border);
}

html[data-theme="dark"] .edit-wrapper {
  border-color: var(--border);
}

html[data-theme="dark"] .media-edit-block {
  border-top-color: var(--border);
}

html[data-theme="dark"] .compose-wrapper[open] .compose-toggle {
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .avatar-edit-block {
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .settings-section h2 {
  border-bottom-color: var(--border);
}

.nav-link-item {
margin-bottom: 8px;
padding: 8px;
background: var(--surface);
border: 1px solid var(--border);
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
}

/* ---- Toggle buttons ---------------------------------------- */
.nav-controls {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.4rem;

  padding: 0.35rem;
}



.theme-toggle,
.text-toggle {
  background: transparent;
  border: 0px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.theme-toggle:hover,
.text-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .text-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

html:not([data-theme="dark"]) .theme-toggle:hover,
html:not([data-theme="dark"]) .text-toggle:hover {
  background: rgba(0, 0, 0, 0.04);
}

.theme-toggle {
  font-size: 1rem;
}

.theme-toggle .icon-sun  { display: none;  }
.theme-toggle .icon-moon { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-sun  { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none;  }

.text-toggle {
  font-weight: 700;
  font-size: 0.82rem;
  font-family: inherit;
  letter-spacing: -0.02em;
}

html.text-enlarged .text-toggle {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---- Text enlargement (+25%) ------------------------------- */
html.text-enlarged {
font-size: 125%;
}
html.text-enlarged body {
font-size: 25px;
}

/* ---- Diagonal wipe transition ------------------------------ */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  animation: diagonal-wipe 2.0s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes diagonal-wipe {
  from {
    clip-path: circle(0%   at var(--tx, 100%) var(--ty, 0%));
  }
  to {
    clip-path: circle(150% at var(--tx, 100%) var(--ty, 0%));
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) {
    animation: none;
  }
}
