:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #dbe2ec;
    --radius: 12px;
    --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

/* In @layer base so Tailwind @layer utilities can override (public nav/footer/search). */
@layer base {
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

/* 100vw full-bleed sections are wider than the layout when a vertical scrollbar is present. */
/* Reserve vertical scrollbar width even when the page is short, so centered layouts (e.g. nav) */
/* don’t shift between home (no scrollbar) and long pages (scrollbar). */
html {
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.55;
}

.site-shell {
    max-width: 1140px;
    margin: 0 auto;
    padding: 18px;
}

.site-header,
.site-main,
.site-footer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.site-header {
    padding: 18px 22px;
    margin-bottom: 14px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

h1, h2, h3, h4 {
    margin-top: 0;
    color: #0f172a;
}

h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
}

.site-main {
    padding: 22px;
    overflow-x: auto;
}

.site-footer {
    margin-top: 14px;
    padding: 14px 22px;
    color: var(--muted);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
}

/*
 * Legacy pill-style nav for embedded / admin chrome — not the Tailwind public header.
 * Unlayered rules here previously overrode @layer utilities on `.public-primary-nav`.
 */
nav:not(.public-primary-nav):not(.admin-sidebar-nav) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

nav:not(.public-primary-nav):not(.admin-sidebar-nav) a {
    background: var(--accent-100, #eef4ff);
    border: 1px solid var(--accent-200, #d9e7ff);
    color: var(--accent-800, #1e40af);
    padding: 8px 12px;
    border-radius: 0;
    font-size: 0.92rem;
}

nav:not(.public-primary-nav):not(.admin-sidebar-nav) a:hover {
    background: var(--accent-200, #dbeafe);
}

}

/* Unlayered: must beat Tailwind when used on the same element as utilities. */
.admin-link {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
}

.admin-link:hover {
    color: #fff;
    background: var(--primary-dark);
}

#admin-sidebar nav {
    margin: 0;
    flex-wrap: nowrap;
    gap: 0.35rem;
}

#admin-sidebar nav a.sidebar-nav-item {
    background: none;
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
    box-shadow: none;
    outline: none;
}

#admin-sidebar nav a.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

#admin-sidebar nav a.sidebar-nav-item-active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 600;
}

#admin-sidebar nav a.sidebar-nav-item-active:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

#admin-sidebar nav a.sidebar-nav-item:focus,
#admin-sidebar nav a.sidebar-nav-item:focus-visible {
    outline: none;
}

#admin-sidebar nav a.admin-sidebar-logout {
    color: #fda4af;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 0.75rem;
    padding-top: 12px;
}

#admin-sidebar nav a.admin-sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffe4e6;
}

#admin-sidebar button.js-admin-menu-toggle {
    border-radius: 0;
    outline: none;
    box-shadow: none;
}

#admin-sidebar button.js-admin-menu-toggle:focus,
#admin-sidebar button.js-admin-menu-toggle:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Floating Menu + sidebar × use .admin-btn (display:inline-flex). That overrides Tailwind hidden/lg:hidden — force visibility rules below. */
@media (min-width: 1024px) {
    button.admin-mobile-menu-toggle {
        display: none !important;
    }

    #admin-sidebar button.js-admin-menu-toggle.admin-btn--compact {
        display: none !important;
    }
}

.admin-mobile-menu-toggle.hidden {
    display: none !important;
}

.admin-mobile-menu-toggle {
    min-height: 2.25rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border-color: #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
}

.admin-mobile-menu-toggle:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.admin-mobile-menu-toggle:focus,
.admin-mobile-menu-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), 0 6px 18px rgba(15, 23, 42, 0.18);
}

table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

th, td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 10px 12px;
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: #0f172a;
}

tr:last-child td {
    border-bottom: none;
}

body.admin-body {
    background: #f1f5f9;
}

.admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
    border-style: solid;
    border-width: 1px;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.admin-btn:active {
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.05);
    transform: translateY(1px);
}

.admin-btn:focus,
.admin-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.admin-btn-primary {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.admin-btn-primary:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1e40af;
}

/* Save buttons (submit) */
button.admin-btn-primary,
input[type="submit"].admin-btn-primary {
    background: #ecfdf5;
    border-color: #86efac;
    color: #15803d;
}

button.admin-btn-primary:hover,
input[type="submit"].admin-btn-primary:hover {
    background: #dcfce7;
    border-color: #4ade80;
    color: #166534;
}

/* Edit action links */
.admin-btn-edit {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #a16207;
}

.admin-btn-edit:hover {
    background: #fef3c7;
    border-color: #fbbf24;
    color: #854d0e;
}

.admin-btn-muted {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

.admin-btn-muted:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.admin-btn-danger {
    background: #fff1f2;
    border-color: #fda4af;
    color: #be123c;
}

.admin-btn-danger:hover {
    background: #ffe4e6;
    border-color: #fb7185;
    color: #9f1239;
}

.admin-btn.w-full {
    width: 100%;
}

.admin-btn--compact {
    min-height: 2.125rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.8125rem;
}

.admin-main {
    font-size: 0.9375rem;
}

.admin-main table {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
}

.admin-main thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.admin-main tbody td {
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.admin-main tbody tr:last-child td {
    border-bottom: none;
}

.admin-main tbody tr:hover td {
    background: #fafafa;
}

.admin-main .admin-panel-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 1.25rem 1.5rem;
}

.admin-main .admin-form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.admin-main .admin-form-field > label {
    display: block;
    margin-bottom: 0.35rem;
}

.admin-main .admin-form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.8125rem;
    color: #334155;
    cursor: pointer;
}

.admin-main .admin-form-check input[type='checkbox'],
.admin-main .admin-form-check input[type='radio'] {
    width: auto;
    margin: 0;
}

.admin-main .admin-form-hint {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #64748b;
}

.admin-main .admin-form-actions {
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
}

.admin-alert-error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    padding: 0.65rem 0.9rem;
    font-size: 0.875rem;
    line-height: 1.45;
}

.admin-html-preview {
    overflow-x: auto;
}

.admin-html-preview img {
    max-width: 100%;
    height: auto;
}

.admin-main .tox-tinymce {
    border: 1px solid #cbd5e1 !important;
    border-radius: 0 !important;
}

.admin-main form {
    max-width: 44rem;
}

.admin-main input[type="text"],
.admin-main input[type="email"],
.admin-main input[type="password"],
.admin-main input[type="number"],
.admin-main input[type="url"],
.admin-main input[type="search"],
.admin-main input[type="tel"],
.admin-main input[type="date"],
.admin-main input[type="datetime-local"],
.admin-main select,
.admin-main textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.65rem 0.9rem;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-main select {
    cursor: pointer;
    padding-right: 2rem;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 1rem;
    appearance: none;
}

.admin-main textarea {
    min-height: 9rem;
    resize: vertical;
}

.admin-main input::placeholder,
.admin-main textarea::placeholder {
    color: #94a3b8;
}

.admin-main input:hover,
.admin-main select:hover,
.admin-main textarea:hover {
    border-color: #94a3b8;
}

.admin-main input:focus,
.admin-main select:focus,
.admin-main textarea:focus {
    outline: none;
    border-color: #c026d3;
    box-shadow: 0 0 0 3px rgba(192, 38, 211, 0.18);
}

.admin-main input:disabled,
.admin-main select:disabled,
.admin-main textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: #f1f5f9;
}

.admin-main input[type="file"] {
    width: 100%;
    padding: 0.75rem 0.9rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #94a3b8;
    border-radius: 0;
    cursor: pointer;
    box-shadow: none;
}

.admin-main input[type="file"]:hover {
    border-color: #64748b;
    background: #f1f5f9;
}

.admin-main input[type="file"]:focus {
    border-style: solid;
    border-color: #c026d3;
    box-shadow: 0 0 0 3px rgba(192, 38, 211, 0.18);
}

.admin-main input[type="checkbox"],
.admin-main input[type="radio"] {
    width: auto;
    margin: 0;
    accent-color: #c026d3;
    box-shadow: none;
}

.admin-main label:not([class*="sr-only"]) {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #334155;
}

.admin-main label + input,
.admin-main label + select,
.admin-main label + textarea {
    margin-top: 0.35rem;
}

.admin-main label input,
.admin-main label select,
.admin-main label textarea {
    margin-top: 0.35rem;
    font-weight: 400;
}

.admin-main button[type="submit"]:not(.admin-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.5rem;
    margin-top: 0.25rem;
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
    background: #c026d3;
    border: 1px solid #86198f;
    border-radius: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-main button[type="submit"]:not(.admin-btn):hover {
    background: #a21caf;
    border-color: #701a75;
    color: #fff;
}

.admin-main button[type="submit"]:not(.admin-btn):focus,
.admin-main button[type="submit"]:not(.admin-btn):focus-visible {
    outline: none;
}

.admin-main button[type="submit"]:not(.admin-btn):active {
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.admin-auth input[type="email"],
.admin-auth input[type="password"],
.admin-auth input[type="text"] {
    display: block;
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: #0f172a;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-auth input:hover {
    border-color: #94a3b8;
}

.admin-auth input:focus {
    outline: none;
    border-color: #c026d3;
    box-shadow: 0 0 0 3px rgba(192, 38, 211, 0.18);
}

.admin-auth label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #334155;
}

@layer base {

form {
    max-width: 760px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

p {
    margin: 0 0 12px;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}

    /* Public post/page: metadata & attachments only — do not fight .prose typography */
    article > p {
        margin-top: 0;
        margin-bottom: 0.5rem;
    }

    article .attachment ul,
    article .attachment ol {
        list-style-position: inside;
    }

    article .attachment ul {
        list-style-type: disc;
    }

    article .attachment ol {
        list-style-type: decimal;
    }

    article .attachment li {
        margin-bottom: 0.5rem;
        line-height: 1.6;
    }

    article .attachment ul ul,
    article .attachment ol ol,
    article .attachment ul ol,
    article .attachment ol ul {
        margin-top: 0.4rem;
    }

    th,
    td {
        text-align: right;
    }

}

@media (max-width: 768px) {
    .site-shell {
        padding: 12px;
    }

    .site-header,
    .site-main,
    .site-footer {
        border-radius: 10px;
    }

    .site-main {
        padding: 16px;
    }

    .brand-row {
        flex-direction: column;
        align-items: flex-start;
    }

    table {
        font-size: 0.92rem;
    }
}

/* Public gallery (Dhivehi fonts — markup uses .waheed / .faruma in gallery.php). */
.gallery-page {
    text-align: right;
}

.gallery-page .gallery-pagination {
    justify-content: flex-start;
}

.gallery-page .gallery-pagination a {
    font-family: faruma, inherit;
    font-variant-numeric: tabular-nums;
}

.gallery-page .gallery-article img {
    border-radius: 0.5rem;
}

.public-site-nav-mobile > summary {
    list-style: none;
}

.public-site-nav-mobile > summary::-webkit-details-marker {
    display: none;
}

/* Search results page + WebKit search field chrome (matches nav dropdown behavior). */
#search-page-q::-webkit-search-decoration,
#search-page-q::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.admin-main label input {
    padding: 0.65rem 0.9rem;
    font-size: 0.9375rem;
    border: 1px solid #cbd5e1;
    border-radius: 0;
}

.admin-main label + select {
    padding-right: 30px!important;
    font-family: faruma;
}

/* Prose rich HTML: let Tailwind Typography win over global th/td from @layer base */
article .prose th,
article .prose td {
    text-align: start;
}