:root {
  --paper: #f7f3ec;
  --paper-strong: #eee7dc;
  --card: #fffdf8;
  --ink: #17221d;
  --muted: #65706a;
  --line: #dcd5ca;
  --green: #0c6548;
  --green-dark: #084a35;
  --green-soft: #dceade;
  --coral: #e76243;
  --coral-soft: #f8ded4;
  --yellow: #edb934;
  --shadow: 0 18px 60px rgba(30, 43, 36, 0.11);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.wordmark { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 24px; font-weight: 700; }
.logo-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ink); color: var(--paper); font-style: italic; }
.wordmark.compact { font-size: 21px; }
.wordmark.compact .logo-mark { width: 36px; height: 36px; font-size: 18px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.25fr .75fr; }
.auth-copy { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 42px clamp(40px, 7vw, 112px) 60px; background: var(--paper); }
.auth-copy::before { content: ""; position: absolute; width: 520px; height: 520px; border: 1px solid rgba(12,101,72,.12); border-radius: 50%; top: -280px; right: -170px; box-shadow: 0 0 0 80px rgba(12,101,72,.025), 0 0 0 160px rgba(12,101,72,.02); }
.auth-pitch { max-width: 760px; margin: auto 0 48px; padding-top: 80px; }
.auth-pitch h1 { max-width: 720px; margin: 0; font: 500 clamp(52px, 6vw, 88px)/.98 Georgia, serif; letter-spacing: -.04em; }
.auth-pitch h1 em { color: var(--coral); font-weight: 500; }
.lede { max-width: 580px; margin: 28px 0 0; color: var(--muted); font-size: 20px; line-height: 1.55; }
.sample-card { width: min(570px, 100%); padding: 25px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 16px 45px rgba(36,45,39,.08); transform: rotate(-1deg); }
.sample-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.sample-card h2 { margin: 18px 0 26px; font: 600 25px/1.25 Georgia, serif; }
.odds-row { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 14px; }
.odds-row strong { color: var(--green); }
.odds-track { height: 8px; overflow: hidden; border-radius: 10px; background: var(--coral-soft); }
.odds-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.sample-action { display: flex; align-items: center; gap: 10px; margin-top: 22px; color: var(--muted); font-size: 13px; }
.auth-panel { display: grid; place-items: center; padding: 48px; background: var(--green); }
.auth-form { width: min(390px, 100%); padding: 42px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.auth-form h2 { margin: 0 0 12px; font: 600 36px/1.12 Georgia, serif; }
.auth-form > div > p:last-child { margin: 0 0 32px; color: var(--muted); line-height: 1.5; }
.auth-form label, .stack-form label { display: grid; gap: 8px; color: var(--ink); font-size: 13px; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: none; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input { height: 48px; padding: 0 14px; }
textarea { resize: vertical; padding: 12px 14px; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(12,101,72,.1); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 43px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-size: 14px; font-weight: 750; transition: transform .12s, background .12s, opacity .12s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: var(--line); background: var(--card); }
.button-secondary:hover { background: var(--paper-strong); }
.button-danger { background: var(--coral-soft); color: #8c2e1b; }
.button-large { width: 100%; min-height: 52px; margin-top: 18px; justify-content: space-between; padding: 0 18px; }
.button-full { width: 100%; }
.join-hint { margin: 15px 0 0; color: var(--green); font-size: 12px; text-align: center; }

.topbar { position: sticky; z-index: 20; top: 0; height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(247,243,236,.92); backdrop-filter: blur(14px); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.balance-pill { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 13px; }
.balance-pill strong { font-size: 14px; }
.balance-pill span:last-child { color: var(--muted); }
.coin-dot { width: 13px; height: 13px; border: 3px solid #b78005; border-radius: 50%; background: var(--yellow); }
.avatar { flex: 0 0 auto; display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 800; }
.avatar-ink { width: 38px; height: 38px; cursor: pointer; background: var(--ink); color: #fff; }
.avatar-coral { background: var(--coral-soft); color: #8c2e1b; }

.workspace { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 68px; height: calc(100vh - 68px); display: flex; flex-direction: column; padding: 28px 18px 22px; border-right: 1px solid var(--line); }
.sidebar-label { padding: 0 10px 10px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.group-list { display: grid; gap: 4px; }
.group-link { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 9px 10px; border: 0; border-radius: 11px; cursor: pointer; background: transparent; text-align: left; }
.group-link:hover { background: var(--paper-strong); }
.group-link.active { background: var(--green-soft); }
.group-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--card); color: var(--green); font-family: Georgia, serif; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(12,101,72,.12); }
.group-link.active .group-icon { background: var(--green); color: #fff; }
.group-link strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.group-link small { color: var(--muted); font-size: 11px; }
.group-link > small { padding: 2px 6px; border-radius: 9px; background: rgba(255,255,255,.65); }
.sidebar-add { margin-top: 9px; padding: 10px; border: 0; cursor: pointer; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; }
.sidebar-add span { margin-right: 8px; color: var(--green); font-size: 18px; }
.sidebar-note { display: flex; gap: 9px; margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.42); color: var(--muted); font-size: 11px; line-height: 1.45; }
.sidebar-note p { margin: 0; }
.sidebar-note strong { color: var(--ink); }
.spark { color: var(--coral); }

.content { width: min(100%, 1120px); margin: 0 auto; padding: 48px clamp(28px, 5vw, 72px) 80px; }
.group-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.group-header h1 { margin: 0; font: 600 clamp(36px, 5vw, 52px)/1.05 Georgia, serif; letter-spacing: -.025em; }
.group-meta { margin: 11px 0 0; color: var(--muted); font-size: 13px; }
.group-actions { display: flex; gap: 10px; }
.tabs { display: flex; gap: 28px; margin: 42px 0 0; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 0 1px 14px; border: 0; cursor: pointer; background: none; color: var(--muted); font-size: 13px; font-weight: 750; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--green); }
.panel { padding-top: 24px; }

.market-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.section-break { grid-column: 1 / -1; margin: 20px 0 0; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.market-card { position: relative; display: flex; flex-direction: column; min-height: 246px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--card); transition: transform .15s, box-shadow .15s, border-color .15s; }
.market-card:hover { transform: translateY(-2px); border-color: #c7bfb3; box-shadow: 0 12px 35px rgba(30,43,36,.08); }
.market-card.resolved { min-height: 210px; background: rgba(255,253,248,.62); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.status { padding: 5px 8px; border-radius: 7px; background: var(--green-soft); color: var(--green); }
.status.closed { background: #ece8df; color: #675e53; }
.status.resolved { background: var(--ink); color: #fff; }
.status.void { background: var(--coral-soft); color: #8c2e1b; }
.market-card h2 { margin: 19px 0 26px; font: 600 23px/1.25 Georgia, serif; }
.probability { margin-top: auto; }
.probability-values { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.probability-values strong { color: var(--green); font: 700 25px Georgia, serif; }
.probability-values span { color: var(--muted); font-size: 12px; }
.probability-track { height: 7px; overflow: hidden; border-radius: 8px; background: var(--coral-soft); }
.probability-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.card-footer { display: flex; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: 11px; }
.position-chip { color: var(--green); font-weight: 800; }
.list-empty { grid-column: 1 / -1; padding: 70px 20px; border: 1px dashed #cfc7ba; border-radius: var(--radius); text-align: center; }
.list-empty .big-mark { display: block; margin-bottom: 15px; color: var(--coral); font: italic 54px Georgia, serif; }
.list-empty h2 { margin: 0; font: 600 25px Georgia, serif; }
.list-empty p { margin: 10px auto 22px; color: var(--muted); }

.empty-state { display: grid; place-items: center; min-height: 68vh; text-align: center; }
.empty-state h1 { margin: 0; font: 600 clamp(38px, 5vw, 56px)/1.05 Georgia, serif; }
.empty-state > p:not(.eyebrow) { margin: 18px 0 26px; color: var(--muted); }
.empty-illustration { position: relative; width: 190px; height: 115px; margin-bottom: 35px; }
.empty-illustration span { position: absolute; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; font: italic 34px Georgia, serif; box-shadow: 0 8px 28px rgba(30,43,36,.12); }
.empty-illustration span:nth-child(1) { left: 5px; top: 25px; background: var(--coral-soft); color: var(--coral); transform: rotate(-10deg); }
.empty-illustration span:nth-child(2) { left: 60px; top: 0; background: var(--green-soft); color: var(--green); z-index: 2; }
.empty-illustration span:nth-child(3) { right: 0; top: 31px; background: var(--ink); color: #fff; transform: rotate(10deg); }

.activity-list { max-width: 760px; }
.activity-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.activity-item p { margin: 0; font-size: 13px; line-height: 1.45; }
.activity-item p strong { font-weight: 800; }
.activity-item small { color: var(--muted); font-size: 11px; }
.activity-question { color: var(--muted); }
.leaderboard { max-width: 780px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.leader-row { display: grid; grid-template-columns: 45px 1fr 120px 120px; align-items: center; min-height: 68px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.leader-row:last-child { border-bottom: 0; }
.leader-row.header { min-height: 42px; background: var(--paper-strong); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.leader-rank { font: italic 20px Georgia, serif; }
.leader-name { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 750; }
.leader-profit { color: var(--green); font-weight: 800; }
.leader-profit.negative { color: var(--coral); }

.dialog { width: min(580px, calc(100vw - 28px)); max-height: calc(100vh - 36px); overflow: auto; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(18,29,24,.55); backdrop-filter: blur(4px); }
.dialog-small { width: min(440px, calc(100vw - 28px)); }
.dialog h2 { margin: 0 0 24px; font: 600 34px/1.15 Georgia, serif; }
.dialog-close { position: absolute; top: 17px; right: 18px; width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer; background: var(--paper-strong); font-size: 22px; line-height: 1; }
.dialog-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 22px; border-radius: 10px; background: var(--paper-strong); }
.dialog-tabs button { flex: 1; height: 38px; border: 0; border-radius: 8px; cursor: pointer; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.dialog-tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(30,43,36,.08); }
.stack-form { display: grid; gap: 18px; }
.optional { color: var(--muted); font-weight: 500; }

.market-dialog { width: min(760px, calc(100vw - 28px)); }
.detail-status { display: inline-flex; margin-bottom: 15px; }
.market-dialog h2 { max-width: 660px; margin-bottom: 12px; font-size: clamp(30px, 5vw, 43px); }
.detail-description { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px 18px; padding-bottom: 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.detail-odds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0; }
.odds-box { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.odds-box span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; }
.odds-box strong { display: block; margin-top: 5px; font: 700 30px Georgia, serif; }
.odds-box.yes strong { color: var(--green); }
.odds-box.no strong { color: var(--coral); }
.trade-box { padding: 22px; border-radius: 16px; background: var(--ink); color: #fff; }
.trade-box h3 { margin: 0 0 16px; font: 600 21px Georgia, serif; }
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-toggle button { height: 46px; border: 1px solid rgba(255,255,255,.17); border-radius: 10px; cursor: pointer; background: rgba(255,255,255,.07); color: #fff; font-weight: 800; }
.side-toggle button.active.yes { border-color: #8ac7aa; background: #1d785a; }
.side-toggle button.active.no { border-color: #efa28e; background: #9e422c; }
.amount-label { display: block; margin: 18px 0 8px; color: #b9c1bd; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.amounts button { height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; cursor: pointer; background: transparent; color: #fff; font-size: 12px; font-weight: 750; }
.amounts button.active { background: #fff; color: var(--ink); }
.quote-line { min-height: 38px; margin: 14px 0 0; color: #c9d0cc; font-size: 12px; line-height: 1.45; }
.trade-submit { width: 100%; margin-top: 4px; background: var(--paper); color: var(--ink); }
.position-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; }
.position-actions { display: flex; gap: 7px; }
.mini-button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--card); font-size: 11px; font-weight: 750; }
.rule-box { margin-top: 22px; padding: 15px 17px; border-left: 3px solid var(--yellow); background: #fbf5df; color: #645a3c; font-size: 12px; line-height: 1.5; }
.rule-box strong { display: block; margin-bottom: 4px; color: var(--ink); }
.resolution-box { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.resolution-box h3 { margin: 0 0 12px; font: 600 20px Georgia, serif; }
.resolution-actions { display: flex; gap: 8px; }
.comment-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.comment-section h3 { margin: 0 0 16px; font: 600 21px Georgia, serif; }
.comment { display: grid; grid-template-columns: 30px 1fr; gap: 10px; margin-bottom: 15px; }
.comment p { margin: 1px 0 3px; font-size: 13px; line-height: 1.45; }
.comment small { color: var(--muted); font-size: 10px; }
.comment-form { display: flex; gap: 8px; margin-top: 18px; }
.comment-form input { flex: 1; }
.outcome-banner { margin: 20px 0; padding: 18px; border-radius: 13px; background: var(--green-soft); color: var(--green); text-align: center; font: 700 22px Georgia, serif; }
.outcome-banner.void { background: var(--coral-soft); color: #8c2e1b; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; max-width: min(440px, calc(100vw - 28px)); padding: 12px 17px; border-radius: 10px; pointer-events: none; opacity: 0; transform: translate(-50%, 12px); background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; transition: opacity .18s, transform .18s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8c2e1b; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-copy { min-height: 60vh; padding: 30px 30px 46px; }
  .auth-pitch { margin: 90px 0 40px; padding: 0; }
  .sample-card { display: none; }
  .auth-panel { padding: 30px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: block; padding: 12px 20px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-label, .sidebar-note { display: none; }
  .group-list { display: flex; }
  .group-link { width: auto; min-width: max-content; grid-template-columns: 30px 1fr; }
  .group-link > small { display: none; }
  .group-icon { width: 30px; height: 30px; }
  .sidebar-add { display: inline-block; margin: 0; white-space: nowrap; }
  .content { padding: 36px 24px 70px; }
}

@media (max-width: 650px) {
  .topbar { padding: 0 16px; }
  .wordmark.compact > span:last-child { display: none; }
  .group-header { align-items: flex-start; flex-direction: column; }
  .group-actions { width: 100%; }
  .group-actions .button { flex: 1; }
  .market-list { grid-template-columns: 1fr; }
  .market-card { min-height: 225px; }
  .leader-row { grid-template-columns: 35px 1fr 85px; padding: 0 13px; }
  .leader-row > :last-child { display: none; }
  .dialog { padding: 29px 21px 24px; }
  .amounts { grid-template-columns: repeat(2, 1fr); }
  .position-panel { align-items: flex-start; flex-direction: column; }
  .resolution-actions { flex-wrap: wrap; }
}
