:root {
    --background: #f3f4f6;
    --card: #ffffff;
    --text: #18181b;
    --muted: #666b74;
    --border: #d9dce1;
    --dark: #141414;
    --red: #b5121b;
    --red-dark: #8e0e15;
    --green: #24733c;
    --green-light: #e8f5ec;
    --yellow-light: #fff7dc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.site-header {
    min-height: 76px;
    padding: 14px 28px;
    background: var(--dark);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 4px solid var(--red);
}

.brand {
    font-size: 1.32rem;
    font-weight: 800;
}

.subtitle {
    margin-top: 2px;
    color: #b7bbc2;
    font-size: 0.88rem;
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-header a,
.link-button {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.site-header form {
    margin: 0;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    font: inherit;
}

.page {
    width: min(1500px, calc(100% - 32px));
    margin: 28px auto 50px;
}

.page-heading {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.page-heading h1 {
    margin: 0 0 6px;
    font-size: 1.85rem;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
}

.heading-actions {
    display: flex;
    gap: 10px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}

.card {
    margin-bottom: 22px;
    padding: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.card h2 {
    margin: 0 0 8px;
    font-size: 1.14rem;
}

.card p {
    color: var(--muted);
}

.card-header {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.card-header p {
    margin: 0;
}

.gram-editor {
    width: 100%;
    min-height: 650px;
    resize: vertical;
    padding: 18px;
    color: #111;
    background: #fbfbfc;
    border: 1px solid #c9ccd2;
    border-radius: 7px;
    font-family: "Courier New", Courier, monospace;
    font-size: 15px;
    line-height: 1.6;
}

.editor-footer {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.save-note {
    color: var(--muted);
    font-size: 0.9rem;
}

button {
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.primary,
.approve,
.secondary {
    padding: 10px 17px;
}

.primary {
    color: white;
    background: var(--red);
    border: 1px solid var(--red);
}

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

.approve {
    color: white;
    background: var(--green);
    border: 1px solid var(--green);
}

.secondary {
    color: #25272b;
    background: white;
    border: 1px solid #bfc3ca;
}

.status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-draft {
    color: #775a00;
    background: var(--yellow-light);
}

.status-approved,
.status-sent {
    color: #165c2c;
    background: var(--green-light);
}

.status-failed {
    color: #8e0e15;
    background: #fde9ea;
}

.details {
    display: grid;
    grid-template-columns: 105px 1fr;
    gap: 10px;
}

.details dt {
    color: var(--muted);
    font-weight: 700;
}

.details dd {
    margin: 0;
}

.history-list a {
    padding: 12px 0;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    border-top: 1px solid #eceef1;
}

.message {
    margin-bottom: 18px;
    padding: 13px 16px;
    border-radius: 7px;
    font-weight: 600;
}

.message.success {
    color: #165c2c;
    background: var(--green-light);
}

.message.error {
    color: #8e0e15;
    background: #fde9ea;
}

.login-card {
    width: min(440px, 100%);
    margin: 70px auto;
    padding: 30px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.login-card label {
    margin: 15px 0 6px;
    display: block;
    font-weight: 700;
}

.login-card input {
    width: 100%;
    padding: 11px;
    border: 1px solid #bfc3ca;
    border-radius: 6px;
}

.full-width {
    width: 100%;
    margin-top: 20px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--red);
    text-decoration: none;
    font-weight: 700;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .gram-editor {
        min-height: 500px;
    }
}

@media (max-width: 620px) {
    .site-header {
        padding: 13px 16px;
    }

    .site-header nav a {
        display: none;
    }

    .page {
        width: calc(100% - 20px);
        margin-top: 18px;
    }

    .page-heading,
    .card-header,
    .editor-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .heading-actions form,
    .heading-actions button,
    .editor-footer button {
        width: 100%;
    }

    .card {
        padding: 16px;
    }
}

/* Gram publishing controls */

.card-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.post-button {
    padding: 10px 17px;
    color: white;
    background: var(--green);
    border: 1px solid var(--green);
}

.post-button:hover:not(:disabled) {
    filter: brightness(0.9);
}

.post-button:disabled,
.post-button.disabled {
    color: #70747a;
    background: #d8dadd;
    border-color: #c6c9ce;
    cursor: not-allowed;
    opacity: 1;
}

.post-button.posted {
    color: #46604d;
    background: #dcecdf;
    border-color: #b7d3bd;
}

.facebook-error {
    margin-top: 12px;
    padding: 10px 12px;
    color: #8a1f1f;
    background: #fff1f1;
    border: 1px solid #e6b8b8;
    border-radius: 6px;
    font-size: 0.9rem;
}

@media (max-width: 700px) {
    .card-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .card-header-actions form,
    .card-header-actions button {
        width: 100%;
    }
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (max-width: 620px) {
    .editor-actions {
        width: 100%;
        flex-direction: column;
    }

    .editor-actions button {
        width: 100%;
    }
}

.facebook-access-status {
    margin-bottom: 16px;
    padding: 10px 12px;
    color: #34373c;
    background: #f0f1f3;
    border: 1px solid #d1d4d9;
    border-radius: 6px;
    font-size: 0.92rem;
}

.facebook-access-status a {
    margin-left: 6px;
    font-weight: 700;
}

.facebook-access-status.facebook-access-healthy {
    color: #155724;
    background: #dff3e4;
    border-color: #acd7b7;
}

.facebook-access-status.facebook-access-warning {
    color: #725500;
    background: #fff4c2;
    border-color: #e8cf70;
}

.facebook-access-status.facebook-access-danger {
    color: #8a1f1f;
    background: #ffe1e1;
    border-color: #e7aaaa;
}

.facebook-management-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
}

.facebook-management-actions form {
    margin: 0;
}

.button-link {
    display: inline-block;
    padding: 10px 17px;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.primary-link {
    color: white;
    background: var(--red);
    border: 1px solid var(--red);
}

.primary-link:hover {
    color: white;
    background: var(--red-dark);
}

@media (max-width: 620px) {
    .facebook-management-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .facebook-management-actions form,
    .facebook-management-actions button,
    .facebook-management-actions .button-link {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
}

    .spelling-item-actions {
        flex-direction: column;
    }

    .spelling-item-actions button {
        width: 100%;
    }
}

/* Gram information drawer */
.page-heading {
    position: relative;
}

.gram-menu-button {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
}

.gram-menu-button span {
    display: block;
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: #111827;
}

.layout {
    grid-template-columns: minmax(0, 1fr);
}

.gram-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.45);
}

.gram-info-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    width: min(390px, 92vw);
    height: 100vh;
    padding: 22px;
    overflow-y: auto;
    background: #ffffff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.22);
    transform: translateX(105%);
    transition: transform 0.22s ease;
}

.gram-info-drawer.is-open {
    transform: translateX(0);
}

.gram-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.gram-drawer-header h2,
.drawer-section h3 {
    margin: 0;
}

.gram-drawer-close {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #f3f4f6;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.drawer-section {
    padding: 4px 0 24px;
}

.drawer-section + .drawer-section {
    padding-top: 22px;
    border-top: 1px solid #e5e7eb;
}

.drawer-section h3 {
    margin-bottom: 16px;
}

.gram-info-drawer .history-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

body.gram-drawer-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .page-heading {
        align-items: flex-start;
    }

    .gram-info-drawer {
        width: min(360px, 94vw);
        padding: 18px;
    }
}

.gram-drawer-nav {
    display: grid;
    gap: 8px;
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid #e5e7eb;
}

.gram-drawer-nav a,
.gram-drawer-nav button {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 8px;
    background: #f3f4f6;
    color: #111827;
    font: inherit;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.gram-drawer-nav a:hover,
.gram-drawer-nav button:hover {
    background: #e5e7eb;
}

.gram-drawer-nav form {
    margin: 0;
}

/* Correct top-bar hamburger appearance */
.site-header .gram-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
}

.site-header .gram-menu-button span {
    display: block;
    width: auto;
    height: auto;
    background: none;
    color: inherit;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
}

.site-header .gram-menu-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* iPhone Safari drawer fixes */
.gram-info-drawer {
    height: 100vh;
    height: 100dvh;
    -webkit-overflow-scrolling: touch;
}

.site-header .gram-menu-button {
    position: relative;
    z-index: 1001;
    touch-action: manipulation;
}

@supports (-webkit-touch-callout: none) {
    .gram-info-drawer {
        max-height: -webkit-fill-available;
    }
}

.gram-info-details summary {
    position: relative;
    padding: 12px 38px 12px 14px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #111827;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.gram-info-details summary::-webkit-details-marker {
    display: none;
}

.gram-info-details summary::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    font-size: 22px;
    line-height: 1;
}

.gram-info-details[open] summary::after {
    content: "−";
}

.gram-info-details .details {
    margin-top: 16px;
}

/* Red, white and blue Daily Sports Gram theme */
:root {
    --xss-navy: #0a1f44;
    --xss-blue: #174ea6;
    --xss-red: #c81d25;
    --xss-light: #f4f7fb;
    --xss-border: #d7deea;
}

body {
    background:
        linear-gradient(
            180deg,
            #eef3f9 0,
            #ffffff 260px
        );
    color: #172033;
}

.site-header {
    background:
        linear-gradient(
            90deg,
            var(--xss-navy),
            var(--xss-blue)
        );
    border-bottom: 4px solid var(--xss-red);
}

.site-branding {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-logo {
    display: block;
    width: 72px;
    height: 46px;
    object-fit: contain;
}

.site-header .brand {
    color: #ffffff;
}

.site-header .subtitle {
    color: #dbe7ff;
}

.card {
    border: 1px solid var(--xss-border);
    box-shadow: 0 8px 24px rgba(10, 31, 68, 0.08);
}

.primary,
.post-button {
    background: var(--xss-red);
    border-color: var(--xss-red);
    color: #ffffff;
}

.primary:hover,
.post-button:hover:not(:disabled) {
    background: #a9151c;
    border-color: #a9151c;
}

.secondary {
    border-color: var(--xss-blue);
    color: var(--xss-blue);
}

.secondary:hover {
    background: #eef4ff;
}

a {
    color: var(--xss-blue);
}

.status {
    border-color: rgba(23, 78, 166, 0.25);
}

.gram-info-drawer {
    border-left: 5px solid var(--xss-red);
}

.gram-drawer-header {
    background:
        linear-gradient(
            90deg,
            var(--xss-navy),
            var(--xss-blue)
        );
    margin: -22px -22px 20px;
    padding: 18px 22px;
    color: #ffffff;
}

.gram-drawer-header h2 {
    color: #ffffff;
}

.gram-drawer-close {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.gram-drawer-nav a,
.gram-drawer-nav button,
.gram-info-details summary {
    background: #eef3f9;
    border-left: 4px solid var(--xss-blue);
}

.gram-drawer-nav a:hover,
.gram-drawer-nav button:hover,
.gram-info-details summary:hover {
    background: #e2eaf5;
}

.gram-drawer-nav form button {
    border-left-color: var(--xss-red);
}

.history-list a {
    border-left: 3px solid var(--xss-red);
}

@media (max-width: 640px) {
    .site-logo {
        width: 58px;
        height: 38px;
    }

    .site-header .brand {
        font-size: 1rem;
    }

    .site-header .subtitle {
        font-size: 0.78rem;
    }
}

.gram-drawer-logout {
    margin-top: 4px;
    margin-bottom: 0;
    padding-top: 22px;
    padding-bottom: 0;
    border-top: 1px solid #d7deea;
    border-bottom: 0;
}

/* Sports Gram / News Gram environment selector */
.environment-switcher {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.environment-switcher details {
    width: 100%;
}

.environment-switcher summary {
    position: relative;
    padding: 13px 42px 13px 14px;
    border: 1px solid var(--xss-border);
    border-left: 5px solid var(--xss-red);
    border-radius: 8px;
    background: #ffffff;
    color: var(--xss-navy);
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.environment-switcher summary::-webkit-details-marker {
    display: none;
}

.environment-switcher summary::after {
    content: "▾";
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    font-size: 18px;
}

.environment-switcher details[open] summary::after {
    content: "▴";
}

.environment-options {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.environment-options a {
    display: block;
    padding: 12px 14px;
    border-radius: 8px;
    background: #eef3f9;
    color: #111827;
    font-weight: 700;
    text-decoration: none;
}

.environment-options a:hover {
    background: #e2eaf5;
}

.environment-options a.is-current {
    border-left: 5px solid var(--xss-red);
    background: #dfe9f7;
    color: var(--xss-navy);
}
