:root {
    --primary: #363636;
    --primary-dark: #363636;
    --secondary: #666;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --light: #fff;
    --dark: #4a4a4a;
    --border: #e2e8f0;
    --accent-color: #C2FF00;
    --accent-color-active: #aee000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    line-height: 1.6;
    color: var(--dark);
    background-color: var(--light);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Restore heading sizes (Bulma resets them to 100% outside .content) */
h1 {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.4rem;
    color: var(--primary);
}

h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

h5 {
    font-size: 1rem;
    font-weight: 600;
}

h6 {
    font-size: 0.875rem;
    font-weight: 600;
}

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: currentColor;
}

a:hover {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--accent-color);
    text-decoration-thickness: 3px;
    text-underline-offset: 2px;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

nav.navbar>.container {
    padding-left: 0;
    padding-right: 0;
}

@media screen and (min-width: 1024px) {

    .container,
    .container:not(.is-max-desktop),
    .container:not(.is-max-desktop):not(.is-max-widescreen) {
        max-width: 900px;
    }

    nav.navbar>.container {
        flex-grow: 0;
        width: 100%;
    }
}

/* ── Navbar (Bulma native) ─────────────────────────────── */
nav.navbar {
    background-color: rgba(255, 255, 255, 0.9);
    position: sticky;
    top: 0;
    z-index: 30;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

/* Vertically center the burger within the taller navbar-brand */
.navbar-burger {
    align-self: center;
}

/* Mobile menu overlays page instead of pushing content down */
@media screen and (max-width: 1023px) {
    .navbar-menu.is-active {
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

/* Logo image in navbar */
nav.navbar .navbar-item img {
    height: 3rem;
    width: auto;
    max-height: none;
}

/* Navbar links: dark text, no underline (override global a rules and Bulma) */
a.navbar-item,
a.navbar-item.is-active {
    color: var(--dark);
    text-decoration: none;
}

a.navbar-item:hover,
a.navbar-item:focus {
    background-color: transparent;
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--accent-color);
    text-decoration-thickness: 3px;
    text-underline-offset: 2px;
}

/* Logout ghost button in navbar */
.navbar .button.is-ghost {
    color: var(--dark);
    padding: 0;
    height: auto;
    text-decoration: none;
    font-size: 1rem;
}

.navbar .button.is-ghost:hover {
    background: none;
    color: var(--primary);
    text-decoration: none;
}

/* Visually hidden (for accessibility) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Legacy .logo used on error pages */
.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.logo img {
    height: 36px;
    width: auto;
    vertical-align: middle;
}

/* ── Main ──────────────────────────────────────────────── */
main {
    padding: 2rem 0;
    flex: 1;
}

/* ── Footer ────────────────────────────────────────────── */
footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    color: var(--dark);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-logo img {
    height: 32px;
    width: auto;
}

.footer-links {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--dark);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
    text-decoration-color: var(--accent-color);
    text-decoration-thickness: 3px;
    text-underline-offset: 2px;
}

.footer-social {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.footer-social a {
    color: #000;
    text-decoration: none;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.footer-social a:hover {
    color: var(--primary);
    text-decoration: none;
}

.footer-social svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

@media (max-width: 640px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-links a {
        display: inline-block;
        padding: 0.25rem 0;
    }
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    padding: 0 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.12s;
    white-space: nowrap;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.form-actions {
    text-align: center;
}

.form-actions .btn {
    min-width: 320px;
    max-width: 90%;
    width: auto;
    display: inline-block;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

@media (max-width: 480px) {
    .form-actions .btn {
        min-width: 100%;
        max-width: 100%;
    }
}

.search-row {
    width: 66%;
    display: block;
}

.search-row>div {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-row .form-control {
    flex: 1 1 auto;
}

.search-row .btn {
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .search-row {
        width: 100%;
    }
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Keep button text white even when a:hover would change it */
a.btn-primary,
a.btn-primary:hover,
a.btn-secondary,
a.btn-secondary:hover,
a.btn-success,
a.btn-success:hover,
a.btn-danger,
a.btn-danger:hover {
    color: white;
    text-decoration: none;
}

.btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
    filter: brightness(0.98);
    text-decoration: none;
}

.btn:active {
    transform: scale(1.0);
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
}

.btn:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: #f5f5f5;
    color: var(--dark);
}

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group label + .help-text {
    margin-top: -0.35rem;
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
    font-family: inherit;
    accent-color: var(--primary);
}

select.form-control {
    background-color: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(54, 54, 54, 0.1);
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.form-check-input {
    margin-top: 0.25rem;
    accent-color: var(--primary);
}

input[type="checkbox"],
input[type="radio"],
input[type="range"],
progress {
    accent-color: var(--primary);
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 1.5rem;
    margin-bottom: 1rem;
    color: inherit;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-subtitle {
    color: var(--secondary);
    margin-bottom: 1rem;
}

/* ── Alerts ────────────────────────────────────────────── */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger,
.alert-error {
    background: #fff5f5;
    color: #7f1d1d;
    border: 1px solid #fee2e2;
}

.alert-danger ul {
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding-left: 1.5rem;
}

.alert-danger li {
    margin-bottom: 0.25rem;
}

.alert-warning {
    background: #fefce8;
    color: #854d0e;
    border: 1px solid #fef08a;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ── Badges ────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fefce8;
    color: #854d0e;
}

.badge-danger {
    background: #fef2f2;
    color: #991b1b;
}

.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* ── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--dark);
}

.pagination a:hover {
    background: #f5f5f5;
    color: var(--dark);
    text-decoration: none;
}

.pagination a:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.pagination .current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Word counter ──────────────────────────────────────── */
.word-counter {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

.word-counter.warning {
    color: var(--warning);
}

.word-counter.error {
    color: var(--danger);
}

/* ── Fieldset ──────────────────────────────────────────── */
fieldset {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

legend {
    font-size: 1.5rem;
    font-weight: 700;
}

@media (max-width: 640px) {
    legend {
        font-size: 1.2rem;
    }
}

legend + .help-text {
    margin-bottom: 1rem;
}

fieldset > p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* ── Visibility tags ───────────────────────────────────── */
.tag-public {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.tag-internal {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    background: #fff3e0;
    color: #e65100;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 0.25rem;
}

/* ── Error/help text ───────────────────────────────────── */
.errorlist {
    color: var(--danger);
    list-style: none;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--secondary);
    margin-top: 0.25rem;
}

/* ── Error pages ───────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 6rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.error-page h2 {
    font-size: 1.5rem;
    color: var(--dark);
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--secondary);
    margin-bottom: 1rem;
}

.error-page .btn {
    margin-top: 1rem;
}

/* ── Landing page ──────────────────────────────────────── */
.landing {
    text-align: center;
    padding: 4rem 0;
}

.landing h1 {
    font-size: 3rem;
    line-height: 1.1;
}

.landing-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 700px;
    margin: 3rem auto 0;
}

.landing-card {
    display: block;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.landing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.12), 0 0 0 3px var(--accent-color);
    border-color: var(--accent-color);
    color: inherit;
    text-decoration: none;
}

.landing-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.landing-card p {
    color: var(--secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.landing-card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

@media (max-width: 540px) {
    .landing-cards {
        grid-template-columns: 1fr;
    }
}

/* ── Utility classes ───────────────────────────────────── */
.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--secondary);
}

.text-large {
    font-size: 1.25rem;
}

.max-w-700 {
    max-width: 700px;
}

.icon-large {
    font-size: 4rem;
    color: var(--primary);
}

.border-top {
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2.5rem;
}

.mt-5 {
    margin-top: 4rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* ── Tooltips ──────────────────────────────────────────── */

/* Block-level tooltip wrapper for form fields */
.tooltip-field {
    position: relative;
    display: block;
}

.tooltip-field input[readonly],
input.form-control[readonly] {
    background-color: #f0f0f0;
    color: var(--secondary);
    cursor: not-allowed;
}

.tooltip-field::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--dark);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: normal;
    max-width: 250px;
    width: max-content;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1000;
    font-weight: normal;
}

.tooltip-field::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--dark);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1000;
}

.tooltip-field:hover::before,
.tooltip-field:hover::after {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .tooltip-field::before {
        left: 0;
        transform: none;
        max-width: 200px;
    }

    .tooltip-field::after {
        left: 1rem;
        transform: none;
    }
}

.tooltip-trigger,
.tooltip-help {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--secondary);
    text-decoration: none;
}

.tooltip-help {
    display: inline-block;
    width: 1em;
    height: 1em;
    line-height: 1;
    text-align: center;
    font-weight: bold;
    color: var(--secondary);
    border: 1px solid var(--secondary);
    border-radius: 50%;
    font-size: 0.875rem;
    margin-left: 0.25rem;
    border-bottom: none;
}

.tooltip-trigger::before,
.tooltip-help::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--dark);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    white-space: normal;
    max-width: 250px;
    width: max-content;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1000;
    font-weight: normal;
}

.tooltip-trigger::after,
.tooltip-help::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--dark);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1000;
}

.tooltip-trigger:hover::before,
.tooltip-trigger:hover::after,
.tooltip-help:hover::before,
.tooltip-help:hover::after,
.tooltip-trigger:focus::before,
.tooltip-trigger:focus::after,
.tooltip-help:focus::before,
.tooltip-help:focus::after {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {

    .tooltip-trigger::before,
    .tooltip-help::before {
        left: 0;
        transform: none;
        max-width: 200px;
    }

    .tooltip-trigger::after,
    .tooltip-help::after {
        left: 1rem;
        transform: none;
    }
}