:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-soft: #f8f9fc;
    --text: #182033;
    --muted: #687086;
    --border: #e1e5ee;
    --brand: #4f46e5;
    --brand-dark: #3930bd;
    --brand-soft: #eeedff;
    --danger: #b42318;
    --shadow: 0 14px 40px rgba(36, 45, 78, 0.08);
    --radius-large: 22px;
    --radius-medium: 14px;
    --page-width: 1120px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button,
input,
textarea,
select {
    font: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(225, 229, 238, 0.88);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
}

.nav-shell {
    width: min(var(--page-width), calc(100% - 36px));
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand,
.main-nav,
.author-link,
.detail-actions,
.form-actions,
.comment-head {
    display: flex;
    align-items: center;
}

.brand {
    gap: 10px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: white;
}

.main-nav {
    gap: 20px;
    font-size: 0.95rem;
    font-weight: 650;
}

.inline-form {
    display: inline;
    margin: 0;
}

.nav-button,
.danger-link {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.nav-button {
    color: var(--text);
    font-weight: 650;
}

.page-shell {
    width: min(var(--page-width), calc(100% - 36px));
    margin: 0 auto;
    padding: 46px 0 72px;
}

.hero-panel,
.profile-header {
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: linear-gradient(135deg, #ffffff 0%, #f4f2ff 100%);
    box-shadow: var(--shadow);
}

.hero-panel {
    padding: 46px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 36px;
}

.hero-panel h1,
.detail-card h1,
.form-card h1,
.profile-header h1 {
    margin: 4px 0 12px;
    letter-spacing: -0.04em;
    line-height: 1.12;
}

.hero-panel h1 {
    max-width: 710px;
    font-size: clamp(2.1rem, 4vw, 4rem);
}

.hero-copy {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.eyebrow {
    margin: 0;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--brand);
    border-radius: 12px;
    background: var(--brand);
    color: white;
    font-weight: 750;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    border-color: var(--brand-dark);
    background: var(--brand-dark);
    color: white;
}

.button-small {
    min-height: 38px;
    padding: 7px 14px;
}

.button-secondary {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.button-secondary:hover {
    border-color: #c7cbe0;
    background: var(--surface-soft);
    color: var(--text);
}

.content-grid {
    margin-top: 34px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 28px;
    align-items: start;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px auto auto;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: var(--surface);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #d7dce7;
    border-radius: 11px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

input,
select {
    min-height: 44px;
    padding: 9px 12px;
}

textarea {
    padding: 12px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.clear-link,
.text-action {
    align-self: center;
    color: var(--brand);
    font-weight: 700;
}

.section-heading {
    margin: 34px 0 16px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
}

.section-heading h2 {
    margin: 4px 0 0;
    font-size: 1.55rem;
    letter-spacing: -0.025em;
}

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

.post-list {
    display: grid;
    gap: 14px;
}

.post-card,
.sidebar-card,
.detail-card,
.comments-card,
.form-card,
.profile-feed {
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 7px 24px rgba(36, 45, 78, 0.045);
}

.post-card {
    padding: 24px;
    border-radius: var(--radius-medium);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(36, 45, 78, 0.08);
}

.post-card-topline,
.post-footer,
.post-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.category-pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 0.76rem;
    font-weight: 800;
}

.category-question { background: #fff0e8; color: #a64712; }
.category-resource { background: #e9f7ef; color: #187747; }
.category-project { background: #eaf2ff; color: #1d5fad; }
.category-discussion { background: #f1ecff; color: #6642b8; }

.post-title {
    margin: 14px 0 7px;
    font-size: 1.28rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.post-excerpt {
    margin: 0;
    color: #4c556c;
}

.post-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.author-link {
    gap: 9px;
    font-size: 0.91rem;
    font-weight: 650;
}

.avatar {
    width: 31px;
    height: 31px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #20263a;
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
}

.avatar-large {
    width: 42px;
    height: 42px;
}

.post-stats {
    color: var(--muted);
    font-size: 0.86rem;
}

.sidebar-card {
    position: sticky;
    top: 96px;
    padding: 24px;
    border-radius: var(--radius-medium);
}

.sidebar-card h3 {
    margin: 6px 0 12px;
}

.clean-list {
    margin: 0;
    padding-left: 19px;
    color: var(--muted);
}

.clean-list li + li {
    margin-top: 10px;
}

.empty-state,
.login-callout {
    padding: 32px;
    border: 1px dashed #cfd5e2;
    border-radius: var(--radius-medium);
    background: var(--surface-soft);
    text-align: center;
    color: var(--muted);
}

.empty-state h3 {
    margin: 0 0 6px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
}

.compact {
    padding: 22px;
}

.detail-layout {
    width: min(850px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 20px;
}

.detail-card,
.comments-card,
.form-card,
.profile-feed {
    border-radius: var(--radius-large);
}

.detail-card {
    padding: clamp(28px, 5vw, 52px);
}

.detail-card h1 {
    margin-top: 18px;
    font-size: clamp(2rem, 4vw, 3.3rem);
}

.detail-card > .author-link {
    margin-top: 24px;
}

.post-body {
    margin-top: 34px;
    font-size: 1.05rem;
}

.post-body p {
    margin: 0 0 1em;
}

.detail-actions {
    gap: 18px;
    margin-top: 34px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.detail-actions form {
    margin: 0;
}

.danger-link {
    color: var(--danger);
    font-weight: 700;
}

.comments-card {
    padding: clamp(24px, 4vw, 38px);
}

.comments-card .section-heading {
    margin-top: 0;
}

.stacked-form p {
    margin: 0 0 18px;
}

.stacked-form label {
    display: block;
    margin-bottom: 7px;
    font-weight: 750;
}

.stacked-form .helptext,
.stacked-form ul {
    color: var(--muted);
    font-size: 0.84rem;
}

.stacked-form ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.errorlist {
    color: var(--danger) !important;
    font-weight: 650;
}

.comment-form {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.comment-list {
    display: grid;
}

.comment {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.comment:last-child {
    border-bottom: 0;
}

.comment-head {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.form-card {
    padding: clamp(28px, 5vw, 48px);
}

.narrow-card,
.auth-card {
    width: min(680px, 100%);
    margin: 0 auto;
}

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

.form-card h1 {
    font-size: 2.25rem;
}

.stacked-form {
    margin-top: 28px;
}

.form-actions {
    gap: 18px;
}

.form-footnote {
    margin: 24px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.form-footnote a,
.login-callout a {
    color: var(--brand);
    font-weight: 750;
}

.profile-header {
    padding: 36px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.profile-avatar {
    width: 82px;
    height: 82px;
    font-size: 1.8rem;
}

.profile-header h1 {
    font-size: 2.35rem;
}

.profile-header p:last-child {
    margin: 0;
}

.profile-feed {
    margin-top: 26px;
    padding: 28px;
}

.profile-feed .section-heading {
    margin-top: 0;
}

@media (max-width: 820px) {
    .main-nav {
        gap: 12px;
    }
    .main-nav > a:not(.button),
    .main-nav .nav-button {
        display: none;
    }
    .hero-panel {
        padding: 32px;
        align-items: start;
        flex-direction: column;
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
    .sidebar-card {
        position: static;
    }
    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 560px) {
    .page-shell,
    .nav-shell {
        width: min(100% - 24px, var(--page-width));
    }
    .page-shell {
        padding-top: 24px;
    }
    .brand span:last-child {
        display: none;
    }
    .filter-bar {
        grid-template-columns: 1fr;
    }
    .hero-panel,
    .post-card,
    .detail-card,
    .comments-card,
    .form-card,
    .profile-feed {
        border-radius: 16px;
    }
    .hero-panel {
        padding: 25px;
    }
    .post-footer,
    .post-card-topline,
    .comment-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .profile-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ============= HOUSE STYLES (LOCKED AT FILE BOTTOM, NO SYNTAX ERRORS) ============= */
.house-container-main {
    margin-bottom: 28px;
    border: 2px solid var(--danger);
    padding: 24px;
    border-radius: var(--radius-medium);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.house-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.house-main-title {
    margin: 4px 0 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
}
.muted-text {
    color: var(--muted);
    font-size: 0.875rem;
}
.house-grid-four {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    text-align: center;
}
.house-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.house-image-frame {
    width: 135px;
    height: 135px;
    border: 3px solid transparent;
    border-radius: var(--radius-medium);
    display: grid;
    place-items: center;
    background-color: var(--surface);
    transition: transform 160ms ease, box-shadow 160ms ease;
}
.house-image-frame:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}
.house-crest-img {
    width: 86%;
    height: 86%;
    object-fit: contain;
}
.no-image-text {
    color: var(--muted);
    font-size: 0.9rem;
}
.house-name-label {
    font-size: 1.22rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text);
}
.house-point-value {
    font-size: 1.18rem;
    font-weight: 700;
}
.empty-house-notice {
    grid-column: 1 / -1;
    padding: 32px;
    color: var(--muted);
}
.house-blue .house-image-frame { border-color: #0066ff; }
.house-blue .house-point-value { color: #0066ff; }
.house-green .house-image-frame { border-color: #00b840; }
.house-green .house-point-value { color: #00b840; }
.house-red .house-image-frame { border-color: var(--danger); }
.house-red .house-point-value { color: var(--danger); }
.house-yellow .house-image-frame { border-color: #ffbc00; }
.house-yellow .house-point-value { color: #ffbc00; }
@media (max-width: 920px) {
    .house-grid-four { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
    .house-grid-four { grid-template-columns: 1fr; }
}