:root {
  color-scheme: light;
  --ink: #1c1f24;
  --muted: #626a73;
  --line: #d9dee4;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --charcoal: #2b2f35;
  --green: #1f7a54;
  --green-soft: #e5f3ec;
  --gold: #b97819;
  --gold-soft: #fff1d6;
  --red: #b64b42;
  --blue: #245c94;
  --blue-soft: #e6f0fa;
  --shadow: 0 18px 50px rgba(40, 45, 52, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 245, 239, 0.92)),
    radial-gradient(circle at top left, rgba(31, 122, 84, 0.1), transparent 32rem),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(180px, auto);
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(40, 45, 52, 0.08);
}

.brand,
.user-pill,
.nav-links,
.market-meta,
.donation-row,
.panel-head,
.section-head,
.segmented-control,
.admin-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-links {
  gap: 4px;
  padding: 4px;
  background: #eef1f2;
  border-radius: 8px;
}

.nav-links a {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  background: white;
  color: var(--ink);
  outline: none;
}

.user-pill {
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.user-pill span {
  color: var(--muted);
  font-weight: 700;
}

main {
  display: grid;
  gap: 18px;
  padding-top: 18px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 18px;
  align-items: stretch;
  min-height: 360px;
}

.hero-copy,
.quick-actions,
.market-surface,
.side-rail > section,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  justify-content: end;
  padding: clamp(28px, 5vw, 62px);
  background:
    linear-gradient(135deg, rgba(28, 31, 36, 0.94), rgba(44, 55, 57, 0.86)),
    linear-gradient(90deg, rgba(31, 122, 84, 0.34), rgba(185, 120, 25, 0.34));
  color: white;
}

.hero-copy h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.45rem, 6vw, 5.7rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 720px;
  margin: 20px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(1rem, 1.6vw, 1.24rem);
  line-height: 1.55;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-copy .eyebrow {
  color: #aee7c8;
}

.quick-actions {
  display: grid;
  align-content: space-between;
  gap: 22px;
  padding: 24px;
}

.panel-head,
.section-head {
  justify-content: space-between;
  gap: 16px;
}

h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.36rem;
  line-height: 1.12;
}

.donation-form {
  display: grid;
  gap: 10px;
}

.donation-form label,
.prediction-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.donation-row {
  gap: 10px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

input:focus {
  outline: 3px solid rgba(36, 92, 148, 0.2);
  border-color: var(--blue);
}

.primary-button,
.ghost-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 850;
}

.primary-button {
  background: var(--ink);
  color: white;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #050607;
}

.ghost-button,
.secondary-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.danger-button {
  background: #fff2f0;
  border-color: #f0c8c3;
  color: var(--red);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metrics-grid article {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.metrics-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.metrics-grid strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.36fr);
  gap: 18px;
  align-items: start;
}

.market-surface,
.admin-panel,
.side-rail > section {
  padding: 18px;
}

.segmented-control {
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #eef1f2;
}

.segmented-control button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 8px 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.segmented-control button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(40, 45, 52, 0.08);
}

.market-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.market-card {
  display: grid;
  gap: 14px;
  min-height: 430px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.market-card.resolved {
  background: #f3f5f2;
}

.market-meta {
  justify-content: space-between;
  gap: 8px;
}

.tag,
.status,
.source-pill,
.prediction-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 900;
}

.tag {
  background: var(--blue-soft);
  color: var(--blue);
}

.status {
  background: var(--green-soft);
  color: var(--green);
}

.status.closed {
  background: var(--gold-soft);
  color: var(--gold);
}

.market-card h3 {
  margin-bottom: 0;
  font-size: 1.16rem;
  line-height: 1.25;
}

.market-description {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.market-source {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.source-pill {
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
}

.source-pill a {
  color: var(--blue);
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.option-button:hover,
.option-button:focus-visible,
.option-button.selected {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 122, 84, 0.13);
}

.option-button strong {
  font-size: 0.98rem;
}

.option-button span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.prediction-form {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: auto;
}

.prediction-form button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.side-rail {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 92px;
}

.compact {
  align-items: end;
}

.prediction-list,
.leaderboard-list,
.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px dashed #c7ced6;
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.prediction-item,
.leaderboard-list li,
.admin-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.prediction-item {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.prediction-item strong,
.prediction-item span {
  display: block;
}

.prediction-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.prediction-state.open {
  width: max-content;
  background: var(--blue-soft);
  color: var(--blue);
}

.prediction-state.won {
  width: max-content;
  background: var(--green-soft);
  color: var(--green);
}

.prediction-state.lost {
  width: max-content;
  background: #fff2f0;
  color: var(--red);
}

.leaderboard-list {
  padding-left: 0;
  list-style: none;
  counter-reset: leaderboard;
}

.leaderboard-list li {
  counter-increment: leaderboard;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.leaderboard-list li::before {
  content: counter(leaderboard);
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.leaderboard-list small {
  display: block;
  color: var(--muted);
}

.leaderboard-list strong:last-child {
  color: var(--green);
}

.admin-panel {
  margin-bottom: 28px;
}

.admin-note {
  max-width: 470px;
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.admin-subhead {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-subhead h3,
.admin-subhead p {
  margin: 0;
}

.admin-subhead p {
  color: var(--muted);
}

.admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.admin-item h3 {
  margin-bottom: 4px;
}

.admin-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.admin-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(380px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.message-stack {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.message {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.message.success {
  border-color: #b7dec9;
  background: var(--green-soft);
  color: var(--green);
}

.message.error {
  border-color: #f0c8c3;
  background: #fff2f0;
  color: var(--red);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.server-form {
  grid-template-columns: 1fr;
}

.option-label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

.option-label:has(input:checked) {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 84, 0.13);
}

.option-label input {
  width: 18px;
  min-height: 18px;
}

.option-label span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.import-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.import-form select,
.import-form input {
  width: auto;
  min-width: 130px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

@media (max-width: 1120px) {
  .hero-panel,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .nav-links,
  .user-pill {
    width: 100%;
  }

  .nav-links {
    justify-content: space-between;
  }

  .hero-panel {
    min-height: unset;
  }

  .hero-copy {
    min-height: 420px;
    padding: 26px;
  }

  .metrics-grid,
  .market-list,
  .side-rail {
    grid-template-columns: 1fr;
  }

  .section-head,
  .panel-head,
  .admin-item,
  .prediction-form {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .segmented-control {
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .brand {
    align-items: flex-start;
  }

  .donation-row {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-copy h1 {
    font-size: 3rem;
  }
}
