:root {
    --bg: #090909;
    --bg-elevated: #141114;
    --panel: rgba(22, 16, 20, 0.88);
    --ink: #ece2d0;
    --muted: #b7a994;
    --accent: #8d1f2d;
    --accent-soft: #c97866;
    --line: rgba(236, 226, 208, 0.14);
    --shadow: rgba(0, 0, 0, 0.45);
    --success: #2d8d2d;
    --error: #8d2d2d;
    --art-ruby: rgba(141, 31, 45, 0.34);
    --art-ember: rgba(201, 120, 102, 0.24);
    --art-frost: rgba(236, 226, 208, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    color: var(--ink);
    font-family: "Cormorant Garamond", Georgia, serif;
    background:
        radial-gradient(circle at top, rgba(141, 31, 45, 0.16), transparent 34%),
        linear-gradient(180deg, #040404 0%, #0f0a0d 48%, #050505 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 12% 18%, var(--art-ruby), transparent 34%),
        radial-gradient(circle at 88% 10%, var(--art-ember), transparent 28%),
        radial-gradient(circle at 82% 82%, rgba(201, 120, 102, 0.15), transparent 30%),
        radial-gradient(circle at 16% 84%, rgba(141, 31, 45, 0.18), transparent 30%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(236, 226, 208, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(236, 226, 208, 0.03) 1px, transparent 1px);
    background-size: 120px 120px;
    opacity: 0.32;
    pointer-events: none;
    z-index: 0;
}

body > * {
    position: relative;
    z-index: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: 0.02em;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin: 0.5em 0;
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin: 0.6em 0;
}

h3 {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    margin: 0.7em 0;
}

p {
    font-size: 1.08rem;
    line-height: 1.7;
    margin: 0 0 1.2em 0;
}

a {
    color: var(--accent-soft);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--ink);
}

/* Layout */
.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    padding: 2rem 0 1rem;
    text-align: center;
    border-bottom: 1px solid var(--line);
    position: relative;
}

.site-header::after {
    content: "";
    display: block;
    width: min(560px, 84%);
    height: 1px;
    margin: 1.2rem auto 0;
    background: linear-gradient(90deg, transparent, var(--art-ember), transparent);
    box-shadow: 0 0 18px rgba(201, 120, 102, 0.28);
}

.crest {
    display: inline-block;
    margin: 0 0 0.5rem 0;
    color: var(--accent-soft);
    font-family: "UnifrakturCook", serif;
    font-size: clamp(2.3rem, 6vw, 4.3rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-shadow: 0 0 18px rgba(141, 31, 45, 0.28);
}

.tagline {
    margin: 0.15rem 0 1.5rem;
    color: var(--muted);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.5rem 0 0 0;
    padding: 0;
    list-style: none;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.25s ease;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(141, 31, 45, 0.08);
}

.main-nav a:hover {
    color: var(--ink);
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(141, 31, 45, 0.14);
}

.main-nav a.active {
    color: var(--ink);
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.25);
    box-shadow: 0 10px 24px rgba(141, 31, 45, 0.14);
}

.user-nav {
    margin-left: auto;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.user-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-info span {
    font-size: 0.95rem;
    color: var(--muted);
}

/* Forms */
.form-container {
    max-width: 450px;
    margin: 3rem auto;
    padding: 2.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
}

.form-container::before,
.dashboard-card::before,
.profile-section::before,
.announcement::before,
.mission-callout::before {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    left: -110px;
    top: -120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--art-ember), transparent 70%);
    pointer-events: none;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--ink);
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 0.35rem;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-soft);
    background: rgba(0, 0, 0, 0.5);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    width: 100%;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    background-color: #090909;
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 0.35rem;
    transition: border-color 0.3s ease;
    color-scheme: dark;
}

select:focus {
    outline: none;
    border-color: var(--accent-soft);
    background-color: #0d0d0d;
}

select option {
    background-color: #090909;
    color: var(--ink);
}

/* Buttons */
.button, button {
    padding: 0.8rem 2rem;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.button, button[type="submit"] {
    background: var(--accent);
    color: var(--ink);
}

.button:hover, button[type="submit"]:hover {
    background: var(--accent-soft);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--shadow);
}

.button.secondary {
    background: transparent;
    border: 2px solid var(--accent-soft);
    color: var(--accent-soft);
}

.button.secondary:hover {
    background: var(--accent);
    color: var(--ink);
    border-color: var(--accent);
}

button[type="button"] {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
    padding: 0.6rem 1.5rem;
}

button[type="button"]:hover {
    border-color: var(--accent-soft);
    color: var(--accent-soft);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.35rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert.success {
    background: rgba(45, 141, 45, 0.15);
    border-left-color: var(--success);
    color: #90ee90;
}

.alert.error {
    background: rgba(141, 45, 45, 0.15);
    border-left-color: var(--error);
    color: #ff9999;
}

.alert.info {
    background: rgba(141, 31, 45, 0.15);
    border-left-color: var(--accent);
    color: var(--accent-soft);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.dashboard-title {
    margin: 0;
}

.member-rank {
    padding: 0.5rem 1.2rem;
    background: rgba(141, 31, 45, 0.3);
    border: 1px solid var(--accent);
    border-radius: 0.35rem;
    color: var(--accent-soft);
    font-size: 0.95rem;
    font-weight: 600;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.dashboard-card {
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.dashboard-card:hover {
    border-color: var(--accent-soft);
    box-shadow: 0 8px 24px var(--shadow);
}

.dashboard-card h3 {
    margin-top: 0;
    color: var(--accent-soft);
}

.dashboard-card p {
    font-size: 1rem;
}

.announcements {
    margin-top: 2rem;
}

.announcement {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: rgba(141, 31, 45, 0.1);
    border-left: 3px solid var(--accent);
    border-radius: 0.35rem;
    position: relative;
    overflow: hidden;
}

.announcement-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--accent-soft);
}

.announcement-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.announcement-content {
    margin: 0;
    line-height: 1.6;
}

/* Forum */
.forum-shell {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.forum-sidebar {
    position: sticky;
    top: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.forum-channel-link {
    display: block;
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.65rem 0.95rem;
    background: rgba(141, 31, 45, 0.08);
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.forum-channel-link:hover {
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(141, 31, 45, 0.14);
}

.forum-channel-link.active {
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.24);
    box-shadow: 0 10px 24px rgba(141, 31, 45, 0.14);
}

.forum-channel-link.locked {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
    box-shadow: none;
}

.forum-channel-link-title {
    display: block;
    color: var(--ink);
    font-weight: 600;
    line-height: 1.25;
}

.forum-channel-link-meta {
    display: block;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.forum-main {
    min-width: 0;
}

.forum-topic-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.forum-topic-list {
    padding: 1rem;
    position: sticky;
    top: 1rem;
}

.forum-topic-list h3 {
    margin: 0 0 0.8rem;
    color: var(--accent-soft);
}

.forum-topic-item {
    display: block;
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: rgba(8, 8, 8, 0.32);
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.65rem;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.forum-topic-item:last-child {
    margin-bottom: 0;
}

.forum-topic-item:hover {
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.18);
    transform: translateY(-1px);
}

.forum-topic-item.active {
    border-color: rgba(201, 120, 102, 0.58);
    background: rgba(141, 31, 45, 0.24);
    box-shadow: 0 8px 20px rgba(141, 31, 45, 0.14);
}

.forum-topic-title {
    display: block;
    color: var(--ink);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3;
}

.forum-topic-meta,
.forum-topic-stats {
    display: block;
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.forum-topic-snippet {
    display: block;
    margin-top: 0.45rem;
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.35;
}

.forum-topic-thread {
    min-width: 0;
}

.forum-post-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: nowrap;
}

.forum-post-actions form {
    margin: 0;
}

.forum-action-button {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.84rem !important;
    line-height: 1.15;
    white-space: nowrap;
    margin: 0 !important;
}

.forum-action-danger {
    background: var(--error, #8d2d2d);
    color: var(--ink);
}

.members-library-frame {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
}

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

.library-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 0.5rem;
}

.library-card-link > div {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.library-card-link:hover > div {
    transform: translateY(-2px);
    border-color: rgba(201, 120, 102, 0.58);
    box-shadow: 0 10px 24px rgba(141, 31, 45, 0.14);
}

.library-open-button {
    display: inline-block;
    padding: 0.5rem 0.85rem;
    font-size: 0.88rem;
}

/* Profile */
.profile-section {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
}

.profile-field {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.profile-field:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.profile-label {
    font-weight: 600;
    color: var(--accent-soft);
}

.profile-value {
    color: var(--ink);
}

.profile-value a {
    color: var(--accent-soft);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -90px;
    top: -80px;
    border: 1px solid rgba(201, 120, 102, 0.3);
    border-radius: 28% 72% 46% 54% / 41% 34% 66% 59%;
    background: linear-gradient(135deg, rgba(201, 120, 102, 0.14), rgba(141, 31, 45, 0.04));
    transform: rotate(20deg);
    pointer-events: none;
}

.hero::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    left: -80px;
    bottom: -70px;
    border: 1px solid rgba(236, 226, 208, 0.16);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(236, 226, 208, 0.08), transparent 68%);
    pointer-events: none;
}

.hero h1 {
    color: var(--ink);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.mission-callout {
    margin: 2.75rem 0 0;
    padding: clamp(1.4rem, 3.2vw, 2.2rem);
    border: 1px solid rgba(201, 120, 102, 0.36);
    border-radius: 0.65rem;
    background:
        linear-gradient(120deg, rgba(141, 31, 45, 0.22), rgba(14, 12, 14, 0.9)),
        var(--panel);
    box-shadow: 0 14px 34px var(--shadow);
    position: relative;
    overflow: hidden;
}

.mission-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--accent-soft);
    font-size: 0.95rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.mission-callout h2 {
    margin-top: 0;
}

.mission-callout p + p {
    margin-top: 0.8rem;
}

.mission-emphasis {
    color: var(--ink);
    font-size: 1.2rem;
    font-style: italic;
}

.signup-context {
    margin: 0.8rem 0 1.3rem;
    padding: 1rem;
    border: 1px solid rgba(201, 120, 102, 0.28);
    border-radius: 0.45rem;
    background: rgba(141, 31, 45, 0.1);
}

.signup-context h3 {
    margin: 0 0 0.45rem;
    color: var(--accent-soft);
    font-size: 1.2rem;
}

.signup-context p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ink);
}

.signup-context p + p {
    margin-top: 0.6rem;
}

/* Links */
.form-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    font-size: 1rem;
}

.form-footer a {
    color: var(--accent-soft);
    font-weight: 600;
}

.form-footer a:hover {
    color: var(--ink);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.95rem;
}

/* Loading & States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .forum-shell {
        grid-template-columns: 1fr;
    }

    .forum-sidebar {
        position: static;
    }

    .forum-topic-layout {
        grid-template-columns: 1fr;
    }

    .forum-topic-list {
        position: static;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .main-nav {
        gap: 1rem;
        font-size: 0.95rem;
    }

    .profile-field {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

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

@media (max-width: 1100px) {
    .library-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
