/* konkur-bet - Polymarket parody, dark UI, RTL Persian.
   Palette follows Polymarket: near-black page, raised cards, green YES / red NO. */

:root {
  --bg: #0d0d0d;
  --bg-raised: #161616;
  --bg-hover: #1e1e1e;
  --line: #2a2a2a;
  --line-soft: #202020;
  --text: #f0f0f0;
  --text-dim: #9a9a9a;
  --text-faint: #6b6b6b;
  --yes: #2dc98a;
  --yes-dim: #1d7a54;
  --yes-soft: rgba(45, 201, 138, 0.12);
  --no: #f0524a;
  --no-dim: #94322d;
  --no-soft: rgba(240, 82, 74, 0.12);
  --accent: #5b8cff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --max: 1280px;
}

* { box-sizing: border-box; }

/* The UA rule `[hidden] { display: none }` is a *user-agent* style, so any
   author rule that sets `display` silently beats it. `.drawer` and `.wallet`
   are both `display: flex`, which meant the activity drawer and the wallet
   stayed on screen despite the `hidden` attribute. This restores the
   attribute's meaning for good. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 800; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
img { max-width: 100%; display: block; }

.muted { color: var(--text-dim); }
.tiny { font-size: 0.78rem; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand-mark { font-weight: 800; font-size: 1.1rem; }
.brand-sub { color: var(--text-faint); font-size: 0.72rem; }

.tabs { display: flex; gap: 4px; margin-inline-start: auto; }
.tabs a {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.12s, color 0.12s;
}
.tabs a:hover { background: var(--bg-hover); color: var(--text); }
.tabs a.active { background: var(--bg-raised); color: var(--text); }

.wallet {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.wallet-name {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wallet-name:hover { color: var(--text); }
.wallet-nums { display: flex; align-items: baseline; gap: 4px; }
.wallet-coins { font-weight: 800; font-variant-numeric: tabular-nums; }
.wallet-label { color: var(--text-faint); font-size: 0.72rem; }

/* ---------- layout ---------- */

.shell { max-width: var(--max); margin: 0 auto; padding: 24px; }

.page-head { margin: 28px 0 14px; }
.page-head h1 { margin-bottom: 4px; }
.page-head h2 { margin-bottom: 4px; }

.hero { margin-bottom: 22px; }
.hero h1 { margin-bottom: 8px; }
.hero p { max-width: 62ch; margin: 0; }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.stat {
  display: flex;
  flex-direction: column;
  min-width: 108px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-faint); font-size: 0.75rem; }

.footer {
  max-width: var(--max);
  margin: 40px auto 0;
  padding: 20px 24px 40px;
  color: var(--text-faint);
  font-size: 0.8rem;
  border-top: 1px solid var(--line-soft);
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.controls input[type="search"],
.controls select {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-width: 200px;
  outline: none;
}
.controls input[type="search"]:focus,
.controls select:focus { border-color: var(--accent); }

.sortbar { display: flex; gap: 2px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.sortbar button {
  background: none;
  border: 0;
  padding: 6px 12px;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
}
.sortbar button:hover { color: var(--text); }
.sortbar button.active { background: var(--bg-hover); color: var(--text); font-weight: 600; }

.btn {
  background: var(--accent);
  border: 0;
  color: #0d0d0d;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--bg-raised); border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.icon-btn { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 4px 8px; }
.icon-btn:hover { color: var(--text); }

/* ---------- event grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.event-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.12s, transform 0.12s;
}
.event-card:hover { border-color: #3d3d3d; transform: translateY(-1px); }

.event-card-top { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.event-card-top img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-hover);
  flex-shrink: 0;
}
.event-card-top h3 { font-size: 0.98rem; }
.event-card-top .muted { font-size: 0.75rem; }

.mini-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.mini-row .q { flex: 1; color: var(--text-dim); font-size: 0.82rem; }

.prob-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; flex: 0 0 90px; }
.prob-bar i { display: block; height: 100%; background: var(--yes); }

.pill {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 9px;
  border-radius: 5px;
  min-width: 52px;
  text-align: center;
}
.pill.yes { background: var(--yes-soft); color: var(--yes); }
.pill.no { background: var(--no-soft); color: var(--no); }
.pill.flat { background: var(--bg-hover); color: var(--text-dim); }

.card-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 0.75rem;
}

.loadmore { display: flex; justify-content: center; margin-top: 20px; }

/* ---------- event page ---------- */

.event-head { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; }
.event-photo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-raised);
  border: 2px solid var(--line);
}
.event-meta .back { color: var(--text-dim); font-size: 0.85rem; }
.event-meta .back:hover { color: var(--text); }
.event-meta h1 { margin: 4px 0; }

.market-list { display: flex; flex-direction: column; gap: 12px; }

.market {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.market-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--line);
}
.market-q { flex: 1; font-size: 0.95rem; }
.market-price { display: flex; align-items: baseline; gap: 8px; }
.market-price .prob { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.market-price .mult { font-size: 0.78rem; }

.market-body { display: grid; grid-template-columns: 1fr 300px; gap: 0; }

/* order book ladder */
.ladder { padding: 12px 16px; border-inline-end: 1px solid var(--line-soft); }
.ladder table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ladder th {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-faint);
  text-align: start;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.ladder td { position: relative; padding: 3px 6px; font-size: 0.82rem; }
.ladder td.depth { position: relative; }
.ladder td.depth i {
  position: absolute;
  inset-block: 1px;
  inset-inline-end: 0;
  border-radius: 3px;
  opacity: 0.16;
}
.ladder tr.ask td.depth i { background: var(--no); }
.ladder tr.bid td.depth i { background: var(--yes); }
.ladder td.num { text-align: end; }
.ladder .lbl { color: var(--text-dim); font-size: 0.75rem; }
.ladder-empty { color: var(--text-faint); font-size: 0.82rem; padding: 10px 0; }

/* trade panel */
.trade { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.amount { display: flex; align-items: center; gap: 8px; }
.amount input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.amount input:focus { border-color: var(--accent); }

.chips { display: flex; gap: 6px; }
.chips button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
}
.chips button:hover { border-color: var(--accent); color: var(--text); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px;
  cursor: pointer;
  font-weight: 800;
  transition: filter 0.12s;
}
.side span { font-size: 0.92rem; }
.side em { font-style: normal; font-size: 0.72rem; opacity: 0.75; font-variant-numeric: tabular-nums; }
.side.yes { background: var(--yes); color: #06281a; }
.side.no { background: var(--no); color: #2a0a08; }
.side:hover { filter: brightness(1.08); }
.side:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.limit { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.limit summary { color: var(--text-dim); font-size: 0.82rem; cursor: pointer; }
.limit-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; flex-wrap: wrap; }
.limit-row label { display: flex; flex-direction: column; gap: 3px; font-size: 0.75rem; color: var(--text-dim); }
.limit-row input {
  width: 78px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.market-foot {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 9px 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  flex-wrap: wrap;
}
.spark { margin-inline-start: auto; }
.spark svg { display: block; }

.my-orders { padding: 0 16px 12px; }
.my-orders table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.my-orders th { text-align: start; color: var(--text-faint); font-weight: 500; padding: 4px 6px; }
.my-orders td { padding: 4px 6px; border-top: 1px solid var(--line-soft); }
.cancel-btn { background: none; border: 1px solid var(--line); border-radius: 4px; color: var(--text-dim); cursor: pointer; font-size: 0.75rem; padding: 2px 8px; }
.cancel-btn:hover { color: var(--no); border-color: var(--no); }

/* ---------- tables ---------- */

.table-wrap { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-wrap th {
  text-align: start;
  font-weight: 500;
  color: var(--text-faint);
  font-size: 0.78rem;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table-wrap td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-size: 0.88rem; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: var(--bg-hover); }
.table-wrap .person-cell { display: flex; align-items: center; gap: 9px; }
.table-wrap .person-cell img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

.rank-1 td { background: rgba(255, 215, 0, 0.07); }
.rank-1 .rk { color: #ffd700; font-weight: 800; }
.rank-2 .rk { color: #cfd4da; font-weight: 800; }
.rank-3 .rk { color: #cd7f32; font-weight: 800; }
.rk { color: var(--text-faint); }

.pos { color: var(--yes); }
.neg { color: var(--no); }
.zero { color: var(--text-faint); }
.flag { color: #ffb020; font-size: 0.75rem; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* ---------- toast + drawer ---------- */

.toast {
  position: fixed;
  inset-inline: 50%;
  bottom: 28px;
  transform: translateX(50%);
  z-index: 60;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  font-weight: 600;
  max-width: 90vw;
}
.toast.good { border-color: var(--yes-dim); color: var(--yes); }
.toast.bad { border-color: var(--no-dim); color: var(--no); }

.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 70;
  width: min(420px, 100vw);
  background: var(--bg-raised);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-body { padding: 8px 18px 20px; overflow-y: auto; }
.drawer-body .feed-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.drawer-body .feed-row img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.drawer-body .feed-main { flex: 1; font-size: 0.82rem; }
.drawer-body .feed-side { font-size: 0.72rem; color: var(--text-faint); }

.scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.55); }

@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid > * { animation: pop-in 0.22s ease both; }
.market { animation: pop-in 0.22s ease both; }

@media (max-width: 860px) {
  .market-body { grid-template-columns: 1fr; }
  .ladder { border-inline-end: 0; border-bottom: 1px solid var(--line-soft); }
  .topbar { flex-wrap: wrap; gap: 10px 16px; padding: 10px 16px; }
  .tabs { margin-inline-start: 0; order: 3; width: 100%; overflow-x: auto; }
  .shell { padding: 16px; }
  .brand-sub { display: none; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
}
