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

.portal-shell {
    min-height: 70vh;
    padding: 1.5rem 0 5rem;
    background:
        radial-gradient(circle at 6% 4%, rgba(201, 164, 99, 0.16), transparent 28%),
        radial-gradient(circle at 94% 10%, rgba(106, 123, 94, 0.12), transparent 24%),
        #f6efe5;
}

.portal-container {
    width: min(calc(100% - 2.5rem), 1280px);
}

.portal-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    min-height: 76px;
    padding: 0.8rem 1rem 0.8rem 1.2rem;
    border: 1px solid rgba(74, 58, 44, 0.12);
    border-radius: 20px;
    background: rgba(255, 252, 247, 0.86);
    box-shadow: 0 12px 35px rgba(60, 45, 28, 0.08);
    backdrop-filter: blur(16px);
}

.portal-brand,
.portal-brand > span:last-child,
.portal-nav,
.portal-nav form {
    display: flex;
    align-items: center;
}

.portal-brand {
    gap: 0.75rem;
}

.portal-brand > span:last-child {
    align-items: flex-start;
    flex-direction: column;
    line-height: 1.25;
}

.portal-brand strong {
    font-family: "Fraunces", serif;
    font-size: 1.15rem;
}

.portal-brand small {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.portal-brand-mark {
    display: inline-grid;
    flex: 0 0 42px;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--moss), #738265);
    color: #fff;
    font-family: "Fraunces", serif;
    font-size: 1.35rem;
    box-shadow: 0 8px 18px rgba(59, 74, 51, 0.22);
}

.portal-nav {
    gap: 0.3rem;
}

.portal-nav a,
.portal-nav button {
    padding: 0.6rem 0.85rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 750;
    cursor: pointer;
}

.portal-nav a:hover,
.portal-nav button:hover {
    background: var(--sage-light);
    color: var(--moss-deep);
}

.portal-page-heading {
    padding: 4rem 0 2.25rem;
}

.portal-page-heading h1,
.portal-editor-heading h1 {
    font-size: clamp(2.5rem, 4.5vw, 4rem);
}

.portal-page-heading p:last-child {
    max-width: 700px;
}

.portal-heading-row {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-end;
}

.portal-heading-row .button {
    flex-shrink: 0;
}

.portal-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-stat-card {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 0.3rem;
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 252, 247, 0.84);
    box-shadow: var(--shadow-sm);
}

.portal-stat-card::after {
    content: "";
    position: absolute;
    top: -22px;
    right: -15px;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: rgba(201, 164, 99, 0.14);
}

.portal-stat-draft::after {
    background: rgba(160, 104, 64, 0.14);
}

.portal-stat-published::after {
    background: rgba(106, 123, 94, 0.18);
}

.portal-stat-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.portal-stat-card strong {
    font-family: "Fraunces", serif;
    font-size: 2.2rem;
}

.portal-panel,
.portal-editor-card,
.portal-publish-card,
.portal-editor-tip,
.portal-confirm-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 252, 247, 0.92);
    box-shadow: var(--shadow);
}

.portal-panel {
    overflow: hidden;
}

.portal-panel-heading {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.portal-panel-heading h2,
.portal-panel-heading p,
.portal-card-heading h2,
.portal-card-heading p {
    margin-bottom: 0;
}

.portal-search {
    display: flex;
    gap: 0.45rem;
    padding: 0.35rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
}

.portal-search input {
    width: min(240px, 35vw);
    min-height: 38px;
    padding: 0 0.8rem;
    border: 0;
    outline: 0;
    background: transparent;
}

.portal-search button {
    min-height: 38px;
    padding: 0 1rem;
    border: 0;
    border-radius: 999px;
    background: var(--moss);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.portal-post-list {
    display: grid;
}

.portal-post-row {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr) auto;
    gap: 1.2rem;
    align-items: center;
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.portal-post-row:last-child {
    border-bottom: 0;
}

.portal-post-row:hover {
    background: rgba(106, 123, 94, 0.035);
}

.portal-post-thumbnail {
    overflow: hidden;
    display: grid;
    place-items: center;
    width: 86px;
    height: 67px;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--moss), #8b785a);
    color: #fff;
    font-family: "Fraunces", serif;
    font-size: 1.5rem;
}

.portal-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portal-post-summary {
    min-width: 0;
}

.portal-post-title-line {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.portal-post-summary h3 {
    overflow: hidden;
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-post-summary h3 a:hover {
    color: var(--moss);
}

.portal-post-summary p {
    overflow: hidden;
    margin: 0 0 0.25rem;
    font-size: 0.86rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-post-summary small {
    color: #847668;
    font-size: 0.73rem;
}

.portal-status {
    display: inline-flex;
    flex-shrink: 0;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.portal-status-draft {
    background: #fff0ca;
    color: #76551b;
}

.portal-status-published {
    background: #e3f0de;
    color: #355734;
}

.portal-post-actions {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.portal-post-actions a {
    padding: 0.5rem 0.7rem;
    border-radius: 9px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.portal-post-actions a:hover {
    background: var(--sage-light);
    color: var(--moss);
}

.portal-post-actions .portal-action-primary {
    background: var(--moss);
    color: #fff;
}

.portal-post-actions .portal-action-danger:hover {
    background: #fae5e2;
    color: #a2312b;
}

.portal-empty {
    padding: 4rem 2rem;
    text-align: center;
}

.portal-empty-icon,
.portal-confirm-icon {
    display: inline-grid;
    place-items: center;
    width: 60px;
    height: 60px;
    margin-bottom: 1.2rem;
    border-radius: 18px;
    background: var(--sage-light);
    color: var(--moss);
    font-family: "Fraunces", serif;
    font-size: 1.8rem;
}

.portal-empty p {
    max-width: 540px;
    margin-right: auto;
    margin-left: auto;
}

.portal-empty .button,
.portal-empty .button-secondary {
    margin-top: 0.8rem;
}

/* Site-native login */

.portal-login-page {
    min-height: 68vh;
    padding: 5rem 0;
    background:
        radial-gradient(circle at 12% 12%, rgba(201, 164, 99, 0.2), transparent 35%),
        radial-gradient(circle at 88% 8%, rgba(106, 123, 94, 0.14), transparent 30%),
        linear-gradient(145deg, #f9f2e8, #eee2d2);
}

.portal-login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 480px);
    gap: clamp(3rem, 7vw, 7rem);
    align-items: center;
}

.portal-login-story h1 {
    max-width: 690px;
    font-size: clamp(3rem, 6vw, 5.5rem);
}

.portal-login-story > p:last-of-type {
    max-width: 620px;
    font-size: 1.08rem;
}

.portal-login-points {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 2rem;
}

.portal-login-points span {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.48);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.portal-login-card {
    padding: clamp(1.5rem, 4vw, 2.4rem);
    border: 1px solid rgba(74, 58, 44, 0.14);
    border-radius: 28px;
    background: rgba(255, 252, 247, 0.94);
    box-shadow: 0 28px 80px rgba(60, 45, 28, 0.14);
}

.portal-login-heading {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.4rem;
}

.portal-login-heading h2,
.portal-login-heading p {
    margin-bottom: 0;
}

.portal-login-form {
    display: grid;
    gap: 1.15rem;
    margin-top: 1.5rem;
}

.portal-login-button {
    width: 100%;
    margin-top: 0.25rem;
}

.portal-return-link {
    display: block;
    margin-top: 1.4rem;
    color: var(--moss);
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}

/* Editor */

.portal-editor-heading {
    padding: 2.8rem 0 1.8rem;
}

.portal-back {
    display: inline-block;
    margin-bottom: 1.6rem;
    color: var(--moss);
    font-size: 0.82rem;
    font-weight: 800;
}

.portal-editor-title-line {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-end;
}

.portal-editor-title-line h1,
.portal-editor-title-line p {
    margin-bottom: 0;
}

.portal-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 1.5rem;
    align-items: start;
}

.portal-editor-main {
    display: grid;
    gap: 1.5rem;
}

.portal-editor-card,
.portal-publish-card,
.portal-editor-tip {
    padding: clamp(1.25rem, 3vw, 2rem);
}

.portal-card-heading,
.portal-card-heading-copy {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.portal-card-heading {
    margin-bottom: 1.6rem;
}

.portal-card-heading-action {
    justify-content: space-between;
    align-items: center;
}

.portal-step {
    display: inline-grid;
    flex: 0 0 38px;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--sage-light);
    color: var(--moss);
    font-weight: 850;
}

.portal-field,
.portal-field-grid {
    display: grid;
    gap: 0.45rem;
}

.portal-field + .portal-field,
.portal-field-grid + .portal-field,
.portal-field + .portal-field-grid {
    margin-top: 1.15rem;
}

.portal-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.portal-field label {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 850;
}

.portal-field label span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.portal-field input[type="text"],
.portal-field input[type="email"],
.portal-field input[type="password"],
.portal-field input[type="url"],
.portal-field textarea,
.portal-search input {
    font-family: "Manrope", sans-serif;
}

.portal-field input[type="text"],
.portal-field input[type="email"],
.portal-field input[type="password"],
.portal-field input[type="url"],
.portal-field textarea {
    width: 100%;
    min-height: 50px;
    padding: 0.8rem 0.95rem;
    border: 1px solid rgba(74, 58, 44, 0.2);
    border-radius: 12px;
    outline: 0;
    background: #fff;
    color: var(--text);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.portal-field textarea {
    resize: vertical;
}

.portal-field input:focus,
.portal-field textarea:focus {
    border-color: var(--sage);
    box-shadow: 0 0 0 4px rgba(106, 123, 94, 0.12);
}

.portal-story-editor {
    min-height: 430px;
    font-family: "Fraunces", Georgia, serif !important;
    font-size: 1.08rem;
    line-height: 1.75;
}

.portal-field small {
    color: var(--muted);
    font-size: 0.75rem;
}

.portal-field-file input[type="file"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px dashed rgba(74, 58, 44, 0.3);
    border-radius: 12px;
    background: #fff;
}

.portal-field-file input[type="file"]::file-selector-button {
    margin-right: 0.8rem;
    padding: 0.6rem 0.9rem;
    border: 0;
    border-radius: 9px;
    background: var(--sage-light);
    color: var(--moss);
    font-weight: 800;
    cursor: pointer;
}

.portal-featured-preview {
    width: 100%;
    max-height: 390px;
    margin-bottom: 1.2rem;
    border-radius: 16px;
    object-fit: cover;
}

.portal-add-media {
    flex-shrink: 0;
    padding: 0.65rem 0.9rem;
    border: 1px solid rgba(106, 123, 94, 0.28);
    border-radius: 999px;
    background: var(--sage-light);
    color: var(--moss);
    font-size: 0.78rem;
    font-weight: 850;
    cursor: pointer;
}

.portal-media-list {
    display: grid;
    gap: 1rem;
}

.portal-media-row {
    position: relative;
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fffdfa;
}

.portal-media-row.is-removed {
    display: none;
}

.portal-media-preview,
.portal-media-placeholder {
    width: 150px;
    height: 126px;
    border-radius: 12px;
    object-fit: cover;
}

.portal-media-placeholder {
    display: grid;
    place-items: center;
    border: 1px dashed rgba(74, 58, 44, 0.24);
    background: #f3ece2;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.portal-video-placeholder {
    background: linear-gradient(145deg, #4b5c43, #79866f);
    color: #fff;
    font-size: 1.6rem;
}

.portal-media-fields {
    min-width: 0;
}

.portal-delete-field {
    display: none;
}

.portal-remove-media {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    padding: 0.35rem 0.55rem;
    border: 0;
    border-radius: 8px;
    background: #fae8e5;
    color: #9e352f;
    font-size: 0.68rem;
    font-weight: 850;
    cursor: pointer;
}

.portal-editor-sidebar {
    position: sticky;
    top: 145px;
    display: grid;
    gap: 1rem;
}

.portal-publish-card {
    background: linear-gradient(160deg, #fffdfa, #eef4ea);
}

.portal-publish-actions {
    display: grid;
    gap: 0.7rem;
    margin-top: 1.4rem;
}

.portal-publish-actions button {
    width: 100%;
}

.portal-preview-button {
    border-color: var(--sage);
    color: var(--moss);
}

.portal-publish-meta {
    display: grid;
    gap: 0.1rem;
    margin-top: 1.3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
}

.portal-publish-meta strong {
    color: var(--text);
}

.portal-editor-tip strong {
    font-family: "Fraunces", serif;
    font-size: 1.05rem;
}

.portal-editor-tip ol {
    margin: 0.8rem 0 0;
    padding-left: 1.25rem;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.8;
}

.portal-form-alert {
    display: grid;
    gap: 0.15rem;
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid #e7b2ac;
    border-radius: 12px;
    background: #fff0ee;
    color: #812f2a;
    font-size: 0.82rem;
}

.portal-form-alert-page {
    margin-bottom: 1.5rem;
}

.errorlist {
    margin: 0.2rem 0 0;
    padding: 0;
    color: #a2312b;
    font-size: 0.75rem;
    font-weight: 750;
    list-style: none;
}

.portal-confirm-card {
    max-width: 620px;
    margin: 5rem auto 1rem;
    padding: clamp(2rem, 5vw, 3.5rem);
    text-align: center;
}

.portal-confirm-icon {
    background: #fae5e2;
    color: #a2312b;
}

.portal-confirm-card p {
    max-width: 500px;
    margin-right: auto;
    margin-left: auto;
}

.portal-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 1.6rem;
}

.portal-danger-button {
    min-height: 50px;
    padding: 0 1.4rem;
    border: 0;
    border-radius: 999px;
    background: #a93c35;
    color: #fff;
    font-weight: 850;
    cursor: pointer;
}

@media (max-width: 980px) {
    .portal-login-layout,
    .portal-editor-layout {
        grid-template-columns: 1fr;
    }

    .portal-login-story {
        text-align: center;
    }

    .portal-login-story h1,
    .portal-login-story > p:last-of-type {
        margin-right: auto;
        margin-left: auto;
    }

    .portal-login-points {
        justify-content: center;
    }

    .portal-editor-sidebar {
        position: static;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .portal-post-row {
        grid-template-columns: 70px minmax(0, 1fr);
    }

    .portal-post-thumbnail {
        width: 70px;
        height: 58px;
    }

    .portal-post-actions {
        grid-column: 2;
    }
}

@media (max-width: 700px) {
    .portal-container {
        width: min(calc(100% - 1.25rem), 1280px);
    }

    .portal-topbar,
    .portal-heading-row,
    .portal-panel-heading,
    .portal-editor-title-line,
    .portal-card-heading-action {
        align-items: stretch;
        flex-direction: column;
    }

    .portal-topbar {
        display: flex;
    }

    .portal-nav {
        justify-content: space-between;
        border-top: 1px solid var(--line);
        padding-top: 0.65rem;
    }

    .portal-page-heading {
        padding-top: 2.6rem;
    }

    .portal-heading-row {
        display: flex;
    }

    .portal-heading-row .button {
        align-self: flex-start;
    }

    .portal-stats {
        grid-template-columns: 1fr;
    }

    .portal-panel-heading {
        display: flex;
    }

    .portal-search,
    .portal-search input {
        width: 100%;
    }

    .portal-post-row {
        grid-template-columns: 56px minmax(0, 1fr);
        gap: 0.8rem;
        padding: 1rem;
    }

    .portal-post-thumbnail {
        width: 56px;
        height: 52px;
    }

    .portal-post-title-line {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.2rem;
    }

    .portal-post-summary p {
        white-space: normal;
    }

    .portal-post-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
        border-top: 1px solid var(--line);
        padding-top: 0.7rem;
    }

    .portal-editor-sidebar,
    .portal-field-grid {
        grid-template-columns: 1fr;
    }

    .portal-card-heading-action,
    .portal-editor-title-line {
        display: flex;
    }

    .portal-add-media {
        align-self: flex-start;
        margin-left: 3.35rem;
    }

    .portal-media-row {
        grid-template-columns: 1fr;
        padding-top: 2.7rem;
    }

    .portal-media-preview,
    .portal-media-placeholder {
        width: 100%;
        height: 180px;
    }

    .portal-confirm-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .portal-confirm-actions form,
    .portal-danger-button,
    .portal-confirm-actions .button-secondary {
        width: 100%;
    }
}

