:root {
    --purple-dark: #1D0024;
    --purple-soft: #6C5BA7;
    --bg-light: #F7F6FB;
    --teal-pill: #C4EEE7;
    --text-main: #242424;
    --text-muted: #777777;
    --white: #ffffff;
    --border-soft: #e2deef;
    --green-upvote: #2ecc71;
    --blue-downvote: #3498db;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
}

/* NAVBAR */

.site-header {
    background-color: var(--purple-dark);
    color: var(--white);
}

.nav-bar {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--white);
}

.logo-mark {
    font-size: 1.5rem;
    margin-right: 6px;
}

.logo-text {
    font-weight: 700;
    font-size: 1.2rem;
}

.nav-right .nav-btn {
    margin-left: 12px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.5);
    background: transparent;
    color: var(--white);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-right .nav-btn.nav-register {
    background: var(--white);
    color: var(--purple-dark);
    border-color: var(--white);
}

/* MAIN LAYOUT */

.site-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

/* HOMEPAGE HERO */

.hero {
    background-color: #f1ecff;
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.hero-text {
    flex: 1 1 260px;
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.hero-slogan {
    font-weight: 600;
    color: var(--purple-soft);
    margin-bottom: 12px;
}

.hero-extra {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* SEARCH + CONDITIONS */

.search-section {
    margin-bottom: 18px;
}

.search-label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    font-size: 0.95rem;
}

.conditions-section {
    margin-top: 8px;
}

.conditions-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.conditions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.condition-pill {
    background-color: var(--teal-pill);
    color: var(--purple-dark);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid rgba(0,0,0,0.03);
}

/* TOPIC PAGE */

.topic-header {
    margin-bottom: 16px;
}

.topic-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.topic-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.topic-tabs {
    margin-top: 16px;
    display: inline-flex;
    border-radius: 999px;
    background: #ece7ff;
    padding: 2px;
}

.topic-tab {
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--purple-dark);
}

.topic-tab.active {
    background: var(--white);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* POSTS LIST */

.posts-list {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-card {
    display: flex;
    background-color: var(--white);
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    align-items: flex-start;
    gap: 12px;
}

/* Vote bar (left) */

.vote-bar {
    width: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.vote-arrow {
    cursor: pointer;
    font-size: 1.2rem;
    user-select: none;
}

.vote-arrow.up {
    color: var(--green-upvote);
}

.vote-arrow.down {
    color: var(--blue-downvote);
}

.vote-score {
    font-weight: 600;
}

/* Post content */

.post-content {
    flex: 1;
}

.post-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.post-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.tag-chip {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f1f0ff;
    color: var(--purple-dark);
}

/* AUTH FORMS */

.auth-section {
    max-width: 400px;
    margin: 24px auto;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    padding: 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.auth-form label {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-form input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    font-size: 0.9rem;
}

.auth-form textarea,
.auth-form select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    font-size: 0.9rem;
}

.primary-btn {
    margin-top: 4px;
    padding: 8px 14px;
    border-radius: 999px;
    border: none;
    background: var(--purple-dark);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
}

.primary-btn:hover {
    opacity: 0.95;
}

.alert {
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.alert-error {
    background: #ffe5e5;
    color: #b30000;
}

.auth-switch {
    margin-top: 10px;
    font-size: 0.9rem;
}

.nav-username {
    margin-right: 8px;
    font-size: 0.9rem;
}

/* FOOTER */

.site-footer {
    border-top: 1px solid var(--border-soft);
    padding: 16px;
    margin-top: 40px;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

.footer-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.footer-links a {
    color: var(--purple-soft);
    text-decoration: none;
    font-size: 0.85rem;
}

.footer-links a + a {
    margin-left: 8px;
}

/* RESPONSIVE */

@media (max-width: 768px) {
    .hero {
        flex-direction: column;
    }
}

/* User dropdown */

.user-dropdown {
    position: relative;
    display: inline-block;
    margin-left: 12px;
}

.user-dropdown-toggle {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 6px 10px;
}

/* menu panel hidden by default */
.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 36px;
    background: #ffffff;
    padding: 8px 0;
    border-radius: 8px;
    min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 1000;
}

.user-dropdown-menu a {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
    white-space: nowrap;
}

.user-dropdown-menu a:hover {
    background: #f3eefb;
}

/* PURE CSS: when anything inside .user-dropdown has focus, show the menu */
.user-dropdown:focus-within .user-dropdown-menu {
    display: block;
}

/* Search autocomplete suggestions */
.search-form {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    z-index: 1000;
    display: none;
    max-height: 320px;
    overflow-y: auto;
}

.search-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
}

.search-suggestion-item:hover {
    background: #f3eefb;
}

.search-suggestion-item .suggestion-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.search-suggestion-item .suggestion-meta {
    font-size: 0.8rem;
    color: #666;
}


.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #4e2a8e;
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}

.link-button:hover {
    text-decoration: none;
}

.rep-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: #f2ebff;
    color: #4e2a8e;
}


