@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    --bg: #f8f4ee;
    --bg-soft: #f1e9dd;
    --ink: #1f2933;
    --ink-soft: #52606d;
    --accent: #0e7c6b;
    --accent-strong: #0a5f52;
    --warm: #d98e04;
    --card: #fffaf2;
    --danger: #9b1c31;
    --ok: #156f52;
    --border: #e5d6bd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Roboto', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 6%, #f8e8c9 0, rgba(248, 232, 201, 0) 34%),
        radial-gradient(circle at 90% 92%, #b0e7d5 0, rgba(176, 231, 213, 0) 28%),
        linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
    position: relative;
    overflow-x: hidden;
}

.bg-shape {
    position: fixed;
    width: 340px;
    height: 340px;
    border-radius: 43% 57% 70% 30% / 30% 45% 55% 70%;
    opacity: 0.26;
    filter: blur(2px);
    pointer-events: none;
    animation: drift 10s ease-in-out infinite alternate;
}

.bg-shape-a {
    top: -90px;
    right: -70px;
    background: #e8cf9d;
}

.bg-shape-b {
    bottom: -120px;
    left: -90px;
    background: #55c1aa;
    animation-delay: 0.8s;
}

@keyframes drift {
    from {
        transform: translateY(0) rotate(0deg);
    }
    to {
        transform: translateY(24px) rotate(8deg);
    }
}

.container {
    width: min(1040px, calc(100% - 2rem));
    margin: 2.2rem auto 3rem;
    position: relative;
    z-index: 1;
}

.site-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid #d9cdb7;
    border-radius: 16px;
    background: rgba(255, 250, 242, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 8px 20px rgba(73, 55, 18, 0.08);
    margin-bottom: 0.9rem;
}

.menu-link {
    text-decoration: none;
    color: #2b4454;
    font-weight: 700;
    padding: 0.52rem 0.88rem;
    border-radius: 12px;
    border: 1px solid transparent;
    letter-spacing: 0.01em;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.menu-link:hover {
    background: #e8f4f1;
    color: #0f5d4f;
    border-color: #b7d7cc;
    transform: translateY(-1px);
}

.menu-link.is-active {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    border-color: #0b6052;
    color: #fff;
    box-shadow: 0 8px 16px rgba(10, 95, 82, 0.28);
}

.hero {
    margin-bottom: 1.2rem;
    animation: rise 0.5s ease-out both;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--accent-strong);
    font-weight: 700;
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
}

h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: #10384a;
}

h2 {
    font-size: clamp(1.2rem, 2.6vw, 1.7rem);
    color: #163e35;
}

.hero p:last-child {
    max-width: 60ch;
    color: var(--ink-soft);
}

.card {
    background: color-mix(in srgb, var(--card) 88%, white 12%);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: 0 18px 46px rgba(77, 58, 21, 0.08);
    margin: 1.1rem 0;
    animation: rise 0.5s ease-out both;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-grid {
    display: grid;
    gap: 0.85rem;
}

label span {
    display: block;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: #244353;
}

input[type='text'],
input[type='password'],
textarea,
input[type='file'] {
    width: 100%;
    border: 1px solid #d9c7ab;
    border-radius: 12px;
    padding: 0.72rem 0.85rem;
    font-size: 0.98rem;
    font-family: inherit;
    background: #fffdf8;
}

textarea {
    resize: vertical;
}

button,
.actions a,
.download,
.back {
    border: 0;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    padding: 0.72rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover,
.actions a:hover,
.download:hover,
.back:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.section-head p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 600;
}

.mag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.85rem;
}

.mag-card {
    border: 1px solid #e9dac4;
    border-radius: 16px;
    padding: 0.95rem;
    background: #fff8ef;
    display: grid;
    gap: 0.6rem;
}

.mag-card p {
    margin: 0;
    color: #465363;
}

.mag-card small {
    color: #65768a;
}

.issue-month {
    width: max-content;
    padding: 0.22rem 0.55rem;
    border-radius: 10px;
    border: 1px solid #c9d8d2;
    background: #e8f4f0;
    color: #1d6b5c;
    font-size: 0.79rem;
    font-weight: 700;
    text-transform: capitalize;
}

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

.actions a {
    flex: 1 1 auto;
    min-width: 110px;
    text-align: center;
}

.download-menu {
    position: relative;
    flex: 1 1 auto;
    min-width: 110px;
}

.menu-trigger {
    width: 100%;
    border: 0;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    padding: 0.72rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    min-width: 190px;
    list-style: none;
    margin: 0;
    padding: 0.35rem;
    background: #fffaf2;
    border: 1px solid #d8c8ac;
    border-radius: 12px;
    box-shadow: 0 14px 26px rgba(31, 35, 40, 0.16);
    z-index: 10;
}

.menu-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: #194a3f;
    border-radius: 9px;
    padding: 0.55rem 0.7rem;
    text-align: left;
    font: inherit;
    text-decoration: none;
    display: block;
    cursor: pointer;
}

.menu-item:hover {
    background: #e8f4f1;
}

.menu-item.is-copied {
    color: #0f6e4f;
    font-weight: 700;
}

.copy-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    padding: 0.62rem 0.86rem;
    border-radius: 11px;
    border: 1px solid transparent;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 12px 26px rgba(17, 20, 22, 0.26);
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 50;
}

.copy-toast.is-success {
    background: #0d6f51;
    border-color: #0a5b42;
}

.copy-toast.is-error {
    background: #a2263d;
    border-color: #8b1f34;
}

.copy-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    margin-bottom: 0.9rem;
    font-weight: 600;
}

.alert-success {
    background: #ddf5ea;
    color: var(--ok);
    border: 1px solid #a7dfc8;
}

.alert-error {
    background: #fde7ec;
    color: var(--danger);
    border: 1px solid #f6b9c8;
}

.empty {
    color: #5f6671;
}

.search-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-row input[type='text'] {
    flex: 1 1 320px;
}

.download.ghost {
    background: #e8f0ec;
    color: #175a4c;
    border: 1px solid #b8d6cb;
}

.numbers-hero p:last-child {
    max-width: 72ch;
}

.viewer-page {
    width: min(1200px, calc(100% - 1.4rem));
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.topbar strong {
    color: #1a3a49;
    font-size: 1.1rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.admin-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1px solid #8fcfbf;
    background: #e6f7f1;
    color: #166a5b;
    font-size: 0.84rem;
    font-weight: 700;
}

.inline-form {
    margin: 0;
}

.inline-form button {
    padding: 0.6rem 0.85rem;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 5rem);
}

.auth-card {
    width: min(500px, 100%);
}

.auth-help {
    color: #4f5f6b;
}

.cover-preview {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid #d9ccb3;
    margin: 0.4rem 0 0.8rem;
}

.welcome-cover {
    min-height: calc(100vh - 9rem);
    border-radius: 24px;
    border: 1px solid #dbcdb6;
    background:
        linear-gradient(120deg, rgba(15, 52, 43, 0.2), rgba(12, 53, 44, 0.32)),
        radial-gradient(circle at 20% 10%, #f3dcc1 0, rgba(243, 220, 193, 0) 38%),
        linear-gradient(160deg, #e7d7bf, #d7c4a8);
    background-size: cover;
    background-position: center;
    box-shadow: 0 18px 44px rgba(56, 43, 16, 0.18);
    padding: clamp(1.3rem, 2.5vw, 2.2rem);
    display: flex;
    align-items: end;
    margin-bottom: 1.2rem;
}

.welcome-cover.has-image {
    border-color: rgba(250, 241, 224, 0.35);
    background:
        linear-gradient(120deg, rgba(12, 58, 49, 0.42), rgba(7, 36, 30, 0.55)),
        url('/cover-image');
    background-size: cover;
    background-position: center;
}

.welcome-cover-content {
    width: min(760px, 100%);
    background: rgba(255, 248, 237, 0.82);
    border: 1px solid rgba(216, 197, 167, 0.8);
    border-radius: 18px;
    padding: clamp(1rem, 2vw, 1.4rem);
    backdrop-filter: blur(2px);
}

.welcome-cover-content .actions {
    margin-top: 0.8rem;
}

.welcome-cover-content p {
    margin: 0.4rem 0 0;
    color: #2f3f4d;
}

.back-link {
    color: #1b5f7a;
    text-decoration: none;
    font-weight: 700;
}

.viewer-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1rem;
}

.viewer-head p {
    margin: 0.2rem 0 0;
    color: #53636f;
}

.viewer-wrap {
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(71, 59, 30, 0.15);
}

iframe {
    width: 100%;
    height: 80vh;
    border: 0;
    background: white;
}

@media (max-width: 820px) {
    .site-menu {
        flex-wrap: wrap;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .viewer-head {
        grid-template-columns: 1fr;
    }

    .welcome-cover {
        min-height: 62vh;
        align-items: end;
    }

    .download,
    .back {
        width: max-content;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-row input[type='text'] {
        flex: initial;
    }

    .menu-list {
        left: 0;
        right: auto;
    }

    iframe {
        height: 68vh;
    }
}
