:root {
  --yes: #22c55e;
  --yes-dark: #16a34a;
  --yes-soft: rgba(34, 197, 94, .14);
  --no: #ef4444;
  --no-dark: #dc2626;
  --no-soft: rgba(239, 68, 68, .14);
  --accent: #22c55e;
  --radius: 12px;
  --radius-lg: 16px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body.dark {
  --bg: #0f1115;
  --bg-2: #14161c;
  --panel: #171a21;
  --panel-2: #1f232c;
  --panel-3: #2a2f3a;
  --border: #262b36;
  --border-2: #333a47;
  --text: #f5f6f8;
  --text-2: #c3c9d4;
  --muted: #8b93a7;
  --input: #1f232c;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
body.light {
  --bg: #f7f8fa;
  --bg-2: #eef0f4;
  --panel: #ffffff;
  --panel-2: #f4f5f7;
  --panel-3: #e8eaef;
  --border: #e6e8ec;
  --border-2: #d6dae1;
  --text: #12141a;
  --text-2: #3d4350;
  --muted: #6b7280;
  --input: #ffffff;
  --shadow: 0 12px 32px rgba(16, 24, 40, .12);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  line-height: 1.5; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.center-loading { color: var(--muted); text-align: center; padding: 120px 0; font-weight: 600; }
.empty-sm { color: var(--muted); padding: 40px 0; text-align: center; font-size: .9rem; }

/* ============ Topbar ============ */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 18px;
  height: 64px; padding: 0 22px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0ea55f);
  display: inline-flex; align-items: center; justify-content: center;
  color: #06210f; font-size: 16px; font-weight: 900;
}
.logo b { color: var(--accent); }
.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 8px 13px; border-radius: 9px; font-weight: 600; font-size: .92rem; color: var(--muted);
}
.topnav a:hover { background: var(--panel-2); color: var(--text); }
.topnav a.active { background: var(--panel-2); color: var(--text); }

.searchbox { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.searchbox svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; opacity: .55; }
.searchbox input {
  width: 100%; padding: 10px 14px 10px 40px;
  background: var(--input); border: 1px solid var(--border); border-radius: 999px;
  outline: none; font-size: .93rem;
}
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--yes-soft); }

.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .88rem;
  background: var(--yes-soft); color: var(--yes); border: 1px solid transparent;
}
.pill-btn:hover { filter: brightness(1.08); }
.pill-btn .lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.ico-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.ico-btn:hover { background: var(--panel-3); color: var(--text); }
.avatar-wrap { position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel-3); color: var(--text); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.dropdown {
  position: absolute; right: 0; top: 46px; min-width: 210px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: none; flex-direction: column; overflow: hidden; z-index: 70;
}
.dropdown.open { display: flex; }
.dropdown .head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.dropdown .head b { display: block; }
.dropdown .head span { color: var(--muted); font-size: .8rem; }
.dropdown a, .dropdown button {
  padding: 11px 14px; text-align: left; background: none; border: none; font-weight: 600; color: var(--text);
}
.dropdown a:hover, .dropdown button:hover { background: var(--panel-2); }

/* ============ Category bar ============ */
.catbar {
  position: sticky; top: 64px; z-index: 50;
  display: flex; gap: 6px; align-items: center;
  padding: 10px 22px; background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.catbar::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .87rem; color: var(--muted);
  border: 1px solid transparent; background: transparent;
}
.cat:hover { color: var(--text); background: var(--panel-2); }
.cat.active { color: var(--text); background: var(--panel-2); border-color: var(--border); }
.cat .cnt { font-size: .72rem; opacity: .6; }

/* ============ Layout ============ */
.app { max-width: 1440px; margin: 0 auto; padding: 22px 22px 70px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: .88rem; }

/* ============ Feed ============ */
.feed {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.event-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, transform .1s;
}
.event-card:hover { border-color: var(--border-2); }
.event-head { display: flex; gap: 11px; align-items: flex-start; }
.event-head img {
  width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: 0 0 auto;
  background: var(--panel-2);
}
.event-title {
  flex: 1; font-weight: 700; font-size: 1rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.event-title:hover { color: var(--accent); cursor: pointer; }
.event-vol { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.event-markets { display: flex; flex-direction: column; }
.market-line {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.market-line:first-child { border-top: none; }
.market-line .q {
  flex: 1; font-size: .87rem; color: var(--text-2); font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.market-line .q:hover { color: var(--accent); cursor: pointer; }
.market-btns { display: flex; gap: 6px; }
.buy-btn {
  min-width: 74px; padding: 7px 10px; border-radius: 9px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  font-weight: 800; transition: background .12s, color .12s;
}
.buy-btn .lbl { font-size: .62rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; opacity: .85; }
.buy-btn .px { font-size: .95rem; }
.buy-btn.yes { background: var(--yes-soft); color: var(--yes); }
.buy-btn.yes:hover { background: var(--yes); color: #fff; }
.buy-btn.no { background: var(--no-soft); color: var(--no); }
.buy-btn.no:hover { background: var(--no); color: #fff; }
.event-foot { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .74rem; flex-wrap: wrap; }
.tag {
  background: var(--panel-2); border-radius: 6px; padding: 2px 8px; font-weight: 700; font-size: .7rem;
  color: var(--muted); text-transform: capitalize;
}
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 24px; }
.pager span { color: var(--muted); font-size: .88rem; }

/* ============ Buttons ============ */
.btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-weight: 700;
}
.btn:hover { background: var(--panel-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06210f; }
.btn.primary:hover { background: var(--yes-dark); }
.btn.yes { background: var(--yes); border-color: var(--yes); color: #fff; }
.btn.no { background: var(--no); border-color: var(--no); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--no-soft); color: var(--no); border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ Event detail ============ */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .detail-grid { grid-template-columns: 1fr; } .sticky-col { position: static !important; } }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 1.03rem; font-weight: 700; margin-bottom: 12px; }
.sticky-col { position: sticky; top: 140px; }
.event-hero { display: flex; gap: 14px; align-items: flex-start; }
.event-hero img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--panel-2); }
.event-hero h1 { font-size: 1.4rem; font-weight: 800; line-height: 1.3; letter-spacing: -.02em; }
.meta { color: var(--muted); font-size: .83rem; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chart-head .big { font-size: 1.5rem; font-weight: 800; }
.chart-head .chg { font-weight: 700; font-size: .9rem; }
.range-tabs { display: flex; gap: 4px; margin-top: 10px; }
.range-tabs button {
  padding: 5px 12px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: .8rem;
}
.range-tabs button:hover { background: var(--panel-2); color: var(--text); }
.range-tabs button.active { background: var(--panel-2); color: var(--text); }

.market-list { display: flex; flex-direction: column; }
.market-list .row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--border);
}
.market-list .row:first-child { border-top: none; }
.market-list .row .info { flex: 1; min-width: 0; }
.market-list .row .info .q { font-weight: 700; font-size: .95rem; }
.market-list .row .info .m { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.market-list .row.resolved { opacity: .65; }

/* Trade panel */
.trade-outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.outcome {
  padding: 12px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; font-weight: 800; color: var(--text-2);
}
.outcome .lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; opacity: .8; }
.outcome .px { font-size: 1.25rem; }
.outcome.sel.yes { background: var(--yes); border-color: var(--yes); color: #fff; }
.outcome.sel.no { background: var(--no); border-color: var(--no); color: #fff; }
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.side-tabs button { padding: 8px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; }
.side-tabs button.on-buy { background: var(--yes); color: #fff; }
.side-tabs button.on-sell { background: var(--no); color: #fff; }

.field-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.input-money {
  width: 100%; padding: 12px 14px; background: var(--input); border: 1px solid var(--border);
  border-radius: 10px; outline: none; font-size: 1.1rem; font-weight: 700;
}
.input-money:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--yes-soft); }
.quick-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick-row button {
  flex: 1; min-width: 52px; padding: 6px 4px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text-2); font-weight: 700; font-size: .8rem;
}
.quick-row button:hover { border-color: var(--accent); color: var(--accent); }
.summary { background: var(--panel-2); border-radius: 10px; padding: 12px; margin: 14px 0; font-size: .88rem; }
.summary .r { display: flex; justify-content: space-between; padding: 3px 0; }
.summary .r .k { color: var(--muted); }
.trade-submit { width: 100%; padding: 13px; border: none; border-radius: 10px; font-weight: 800; font-size: 1rem; }
.trade-submit.buy { background: var(--yes); color: #fff; }
.trade-submit.buy:hover { background: var(--yes-dark); }
.trade-submit.sell { background: var(--no); color: #fff; }
.trade-submit.sell:hover { background: var(--no-dark); }
.position-box { background: var(--yes-soft); border-radius: 10px; padding: 11px 12px; font-size: .85rem; margin-bottom: 12px; }
.position-box b { color: var(--yes); }

/* Order book */
.book { font-size: .82rem; font-variant-numeric: tabular-nums; }
.book .brow { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 3px 0; position: relative; }
.book .brow .depth { position: absolute; inset: 0 0 0 auto; opacity: .12; border-radius: 3px; }
.book .brow span { position: relative; }
.book .brow.ask { color: var(--no); }
.book .brow.bid { color: var(--yes); }
.book .bhead { display: grid; grid-template-columns: 1fr 1fr 1fr; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; padding-bottom: 4px; }
.book .spread { text-align: center; color: var(--muted); padding: 4px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 4px 0; }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--yes); font-weight: 700; }
.neg { color: var(--no); font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .v { font-size: 1.45rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }

.rank-1 { color: #f5c518; font-weight: 800; }
.rank-2 { color: #b8c0cc; font-weight: 800; }
.rank-3 { color: #cd7f32; font-weight: 800; }

/* ============ Modal ============ */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(4, 6, 10, .68); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-card {
  width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1rem; font-weight: 700; line-height: 1.35; }
.modal-body { padding: 18px; }
.modal-close { border: none; background: var(--panel-2); width: 32px; height: 32px; border-radius: 999px; color: var(--muted); font-size: 18px; flex: 0 0 auto; }
.modal-close:hover { background: var(--panel-3); color: var(--text); }

/* ============ Auth ============ */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 20px; }
.auth-card input { width: 100%; padding: 12px 14px; margin-bottom: 12px; background: var(--input); border: 1px solid var(--border); border-radius: 10px; outline: none; }
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--yes-soft); }
.auth-card .btn { width: 100%; padding: 12px; }
.auth-alt { text-align: center; margin-top: 16px; color: var(--muted); font-size: .88rem; }
.auth-alt a { color: var(--accent); font-weight: 700; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 300;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.toast.ok { border-color: var(--yes); color: var(--yes); }
.toast.err { border-color: var(--no); color: var(--no); }

.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-weight: 700; }
.banner.warn { background: rgba(245, 197, 24, .14); color: #f5c518; }
.banner.info { background: var(--panel-2); color: var(--text-2); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 8px 12px; background: var(--input); border: 1px solid var(--border); border-radius: 9px; outline: none; }
/* ============ Polymarket-Feinschliff ============ */
.card-top-actions { display: flex; gap: 6px; align-items: center; }
.star {
  background: none; border: none; font-size: 17px; line-height: 1; color: var(--muted);
  padding: 2px 4px; border-radius: 6px;
}
.star:hover { color: #f5c518; background: var(--panel-2); }
.star.on { color: #f5c518; }
.live-dot {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--yes);
}
.live-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--yes); box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.outcome-line { padding: 8px 0; border-top: 1px solid var(--border); cursor: pointer; }
.outcome-line:first-child { border-top: none; }
.outcome-line:hover .ol-name { color: var(--accent); }
.ol-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ol-name {
  font-size: .88rem; font-weight: 600; color: var(--text-2); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ol-pct { font-size: .95rem; font-weight: 800; white-space: nowrap; }
.ol-bar { height: 5px; border-radius: 999px; background: var(--panel-2); margin-top: 6px; overflow: hidden; }
.ol-bar > div { height: 100%; background: var(--yes); border-radius: 999px; }
.ol-bar > div.no { background: var(--no); }
.more-link {
  display: block; width: 100%; text-align: left; padding: 9px 0 2px;
  background: none; border: none; border-top: 1px solid var(--border);
  color: var(--muted); font-size: .82rem; font-weight: 600;
}
.more-link:hover { color: var(--accent); }

.outcome-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.outcome-chips::-webkit-scrollbar { display: none; }
.ochip {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text-2); font-weight: 700; font-size: .82rem;
}
.ochip:hover { border-color: var(--accent); color: var(--text); }
.ochip.active { background: var(--yes-soft); border-color: var(--yes); color: var(--yes); }
.ochip .p { font-size: .95rem; font-weight: 800; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button {
  padding: 9px 14px; background: none; border: none; color: var(--muted);
  font-weight: 700; font-size: .88rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.equity-chart svg { width: 100%; height: 180px; display: block; }
.equity-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.equity-legend b { color: var(--text); }

.skeleton {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 37%, var(--panel-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-card { height: 190px; border-radius: var(--radius-lg); }
.badge-pos { font-size: .72rem; font-weight: 800; color: var(--yes); }
.badge-neg { font-size: .72rem; font-weight: 800; color: var(--no); }
