/* ──────────────────────────────────────────────────────────────────────────
   BrokerThreads — forum-style theme
   Palette: warm orange + neutral grays, dense layout, IBM Plex Sans
────────────────────────────────────────────────────────────────────────── */
:root {
    --bg:           #f5f5f3;
    --bg-soft:      #fafaf8;
    --surface:      #ffffff;
    --ink:          #1a1a1c;
    --ink-soft:     #4a4a4e;
    --muted:        #777a82;
    --rule:         #e2e2dd;
    --rule-soft:    #ededea;
    --orange:       #ff5a1f;
    --orange-soft:  #ffe9dd;
    --orange-dark:  #d8410d;
    --green:        #1ea061;
    --green-soft:   #d8f1e3;
    --red:          #cc3232;
    --red-soft:     #fbe1de;
    --blue:         #1d6cf0;
    --gold:         #c79c1f;
    --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
    --shadow:       0 6px 18px rgba(0,0,0,0.08);
    --shadow-lg:    0 24px 48px rgba(0,0,0,0.16);
    --r:            6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.muted-link {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 6px 8px;
    border-radius: var(--r);
    transition: background .12s, color .12s;
}
.muted-link:hover { background: var(--rule-soft); color: var(--ink); }

/* ────────────────── Top bar ────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
}
.topbar-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    max-width: 1400px;
    margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-icon {
    width: 32px; height: 32px;
    background: var(--orange);
    border-radius: 8px;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(255, 90, 31, 0.3);
}
.brand-icon svg { width: 18px; height: 18px; }
.brand-name {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}
.topbar-search {
    display: flex;
    flex: 1;
    max-width: 600px;
}
.topbar-search input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 100px;
    padding: 9px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, background .15s;
    color: var(--ink);
}
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search input:focus { border-color: var(--orange); background: var(--surface); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.auth-area { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
.user-chip {
    background: var(--orange-soft);
    color: var(--orange-dark);
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
}

/* ────────────────── Buttons ────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 100px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s, border-color .15s, transform .1s;
    color: var(--ink);
    background: transparent;
    line-height: 1.2;
}
.btn-orange {
    background: var(--orange);
    color: white;
    border-color: var(--orange);
}
.btn-orange:hover { background: var(--orange-dark); border-color: var(--orange-dark); transform: translateY(-1px); }
.btn-ghost {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--rule);
}
.btn-ghost:hover { border-color: var(--ink); background: var(--bg); }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.btn-link {
    background: transparent;
    color: var(--orange-dark);
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 4px 0;
    border: none;
}
.btn-link:hover { color: var(--ink); }

/* ────────────────── Layout ────────────────── */
.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 28px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
}
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-self: start;
    position: sticky;
    top: 70px;
}
.side-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 14px 16px;
}
.side-card h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 700;
}

/* Sort tabs */
.sort-tabs { display: flex; flex-direction: column; gap: 2px; }
.sort-tab {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    transition: background .12s, color .12s;
}
.sort-tab:hover { background: var(--bg); color: var(--ink); }
.sort-tab.active {
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-weight: 700;
}

/* Tags */
.tag-list { display: flex; flex-direction: column; gap: 4px; }
.tag-btn {
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--ink-soft);
    padding: 6px 12px;
    border-radius: 100px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    transition: background .12s, border-color .12s, color .12s;
}
.tag-btn:hover { border-color: var(--ink-soft); }
.tag-btn.active {
    background: var(--ink);
    color: white;
    border-color: var(--ink);
}
.tag-btn.tag-positive.active { background: var(--green); border-color: var(--green); }
.tag-btn.tag-neutral.active  { background: var(--gold);  border-color: var(--gold); }
.tag-btn.tag-critical.active { background: var(--red);   border-color: var(--red); }

/* Broker side list */
.broker-side-list { display: flex; flex-direction: column; gap: 1px; max-height: 300px; overflow-y: auto; }
.broker-side {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-soft);
    transition: background .12s, color .12s;
    text-align: left;
}
.broker-side:hover { background: var(--bg); color: var(--ink); }
.broker-side.active {
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-weight: 700;
}
.broker-side-count {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 100px;
}
.broker-side.active .broker-side-count { background: var(--surface); color: var(--orange-dark); }

/* Side meta */
.side-card-cta { background: linear-gradient(135deg, var(--orange-soft), #fff); border-color: var(--orange-soft); }
.side-card-cta p { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.side-meta p { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.side-meta-links a { color: var(--orange-dark); }

/* ────────────────── Feed ────────────────── */
.feed-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 12px;
    gap: 16px;
}
.feed-count {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.feed-search {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 100px;
    padding: 7px 14px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 260px;
    color: var(--ink);
}
.feed-search:focus { border-color: var(--orange); }

.threads {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Thread card */
.thread {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    display: grid;
    grid-template-columns: 56px 1fr;
    transition: border-color .12s;
    overflow: hidden;
}
.thread:hover { border-color: var(--ink-soft); }

/* Vote column */
.vote-col {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 4px;
    gap: 2px;
    border-right: 1px solid var(--rule);
}
.vote-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    border-radius: 4px;
    transition: color .12s, background .12s;
}
.vote-btn:hover { background: var(--surface); }
.vote-btn.up.active { color: var(--orange); }
.vote-btn.down.active { color: var(--blue); }
.vote-score {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    padding: 2px 0;
}

/* Thread body */
.thread-body { padding: 10px 14px 12px; min-width: 0; }
.thread-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.thread-broker {
    background: var(--bg);
    color: var(--ink);
    padding: 2px 9px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 12px;
}
.tag-pill {
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag-pill.positive { background: var(--green-soft); color: var(--green); }
.tag-pill.neutral  { background: #fbeed1;          color: var(--gold); }
.tag-pill.critical { background: var(--red-soft);  color: var(--red); }
.thread-author {
    color: var(--ink-soft);
    font-weight: 500;
}
.thread-author::before { content: 'by '; color: var(--muted); }
.thread-verified {
    background: var(--green-soft);
    color: var(--green);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 100px;
    font-weight: 700;
    text-transform: uppercase;
}

.thread-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    margin-bottom: 6px;
    cursor: pointer;
    letter-spacing: -0.005em;
}
.thread-title:hover { color: var(--orange-dark); }

.thread-stars {
    color: var(--orange);
    letter-spacing: 1px;
    font-size: 13px;
    margin-bottom: 2px;
}
.thread-stars .empty { color: var(--rule); }

.thread-actions {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
    font-weight: 600;
}
.thread-action {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background .12s, color .12s;
    font-weight: 600;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.thread-action:hover { background: var(--bg); color: var(--ink); }

/* Expanded thread */
.thread.expanded .thread-body-text {
    display: block;
    margin-top: 10px;
    padding: 12px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--rule-soft);
    border-radius: var(--r);
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.65;
}
.thread-body-text { display: none; }
.thread-byline-extra {
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
    font-family: 'IBM Plex Mono', monospace;
}

.comments-section {
    margin-top: 14px;
    padding: 14px;
    background: var(--bg-soft);
    border-top: 1px solid var(--rule-soft);
    border-radius: 0 0 var(--r) var(--r);
}
.comments-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 12px;
}
.comment {
    border-left: 2px solid var(--rule);
    padding: 10px 14px;
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: 0 var(--r) var(--r) 0;
}
.comment-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    font-size: 12px;
}
.comment-author { font-weight: 700; color: var(--ink); }
.comment-author.staff { color: var(--orange-dark); }
.comment-author.staff::after {
    content: 'STAFF';
    background: var(--orange);
    color: white;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 100px;
    margin-left: 6px;
    letter-spacing: 0.05em;
    font-weight: 800;
}
.comment-author.mod::after {
    content: 'MOD';
    background: var(--blue);
    color: white;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 100px;
    margin-left: 6px;
    letter-spacing: 0.05em;
    font-weight: 800;
}
.comment-time { color: var(--muted); font-size: 11px; }
.comment-score {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}
.comment-score.positive { color: var(--green); }
.comment-score.negative { color: var(--red); }
.comment-text {
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.55;
}
.comments-empty {
    color: var(--muted);
    font-size: 13px;
    padding: 16px;
    text-align: center;
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
}
.empty-state strong { display: block; font-size: 18px; color: var(--ink); margin-bottom: 6px; font-weight: 700; }
.empty-state p { color: var(--muted); font-size: 14px; }

.pagination {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

/* ────────────────── Footer ────────────────── */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--rule);
    margin-top: 50px;
}
.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
}
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--ink-soft); }
.footer-links a:hover { color: var(--orange-dark); }

/* ────────────────── Modals ────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(3px);
    z-index: 100;
    padding: 24px;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
}
.modal.open { display: flex; }
.modal-inner {
    background: var(--surface);
    padding: 28px;
    max-width: 440px;
    width: 100%;
    margin: 60px auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    border: 1px solid var(--rule);
}
.modal-close {
    position: absolute;
    top: 12px; right: 12px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    width: 32px; height: 32px;
    border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-inner h2 {
    font-size: 22px;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
    font-weight: 700;
}
.modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

#loginForm, #registerForm, #reviewForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#loginForm label, #registerForm label, #reviewForm label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 700;
}
#loginForm input, #registerForm input,
#reviewForm input, #reviewForm select, #reviewForm textarea {
    background: var(--bg-soft);
    border: 1px solid var(--rule);
    color: var(--ink);
    padding: 10px 12px;
    font-size: 14px;
    border-radius: 6px;
    font-family: inherit;
    outline: none;
    font-weight: 400;
    transition: border-color .15s, box-shadow .15s;
}
#loginForm input:focus, #registerForm input:focus,
#reviewForm input:focus, #reviewForm select:focus, #reviewForm textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 90, 31, 0.16);
}
.checkbox-row {
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 10px !important;
    font-weight: 400 !important;
    font-size: 13px !important;
    color: var(--ink-soft) !important;
    line-height: 1.5;
}
.checkbox-row input { margin-top: 2px; accent-color: var(--orange); }
.checkbox-row a { color: var(--orange-dark); text-decoration: underline; }
.form-error {
    color: var(--red);
    background: var(--red-soft);
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
    border: 1px solid var(--red);
    border-color: rgba(204, 50, 50, 0.3);
}
.form-error.visible { display: block; }
.form-switch { text-align: center; font-size: 13px; color: var(--muted); }
.form-switch a { color: var(--orange-dark); font-weight: 600; }
.form-disclaimer { font-size: 12px; color: var(--muted); text-align: center; }

.star-input { display: flex; gap: 4px; font-size: 28px; cursor: pointer; color: var(--rule); }
.star-input span { transition: color .1s; }
.star-input span.active, .star-input span.hover { color: var(--orange); }

/* Moderation popup */
.moderation-inner { text-align: center; }
.moderation-inner h2 { font-size: 22px; margin-bottom: 10px; }
.moderation-inner p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.mod-icon {
    width: 76px; height: 76px;
    background: var(--orange-soft);
    border-radius: 50%;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.moderation-info {
    background: var(--bg);
    border-left: 3px solid var(--orange);
    padding: 10px 14px;
    text-align: left;
    margin: 8px 0 18px;
    font-size: 13px;
}
.auth-required-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

/* ────────────────── Toast ────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--ink);
    color: white;
    padding: 11px 20px;
    border-radius: 100px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    transition: transform .3s;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ────────────────── Static page ────────────────── */
.static-page {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r);
    padding: 32px 40px;
    max-width: 760px;
    margin: 24px auto;
}
.static-page h1 {
    font-size: 32px;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.static-page .last-updated {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-bottom: 28px;
}
.static-page h2 {
    font-size: 20px;
    font-weight: 700;
    margin-top: 28px;
    margin-bottom: 10px;
}
.static-page h3 {
    font-size: 15px;
    font-weight: 700;
    margin-top: 18px;
    margin-bottom: 8px;
}
.static-page p, .static-page li {
    font-size: 14.5px;
    color: var(--ink-soft);
    line-height: 1.65;
    margin-bottom: 12px;
}
.static-page ul, .static-page ol { margin: 0 0 14px 22px; }
.static-page li { margin-bottom: 4px; }
.static-page a { color: var(--orange-dark); text-decoration: underline; text-underline-offset: 2px; }
.static-page strong { color: var(--ink); font-weight: 700; }

/* ────────────────── Responsive ────────────────── */
@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .topbar-search { display: none; }
}
@media (max-width: 640px) {
    .topbar-inner { padding: 8px 14px; }
    .layout { padding: 16px 14px; gap: 16px; }
    .feed-search { width: 160px; font-size: 12px; }
    .thread { grid-template-columns: 44px 1fr; }
    .vote-col { padding: 8px 2px; }
    .modal-inner { padding: 22px; margin: 20px auto; }
    .footer-inner { flex-direction: column; gap: 12px; }
}
