:root {
  color-scheme: light;
  --blue: #3157f6;
  --blue-strong: #2145d8;
  --ink: #1f232b;
  --muted: #626878;
  --line: #dde3f0;
  --paper: #ffffff;
  --surface: #f4f6fb;
  --surface-strong: #e9eef9;
  --green: #1f8f62;
  --amber: #9a6200;
  --red: #a13232;
  --radius: 8px;
  --shadow: 0 22px 62px rgba(37, 58, 124, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "PingFang TC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(49, 87, 246, 0.14), rgba(49, 87, 246, 0) 320px),
    var(--surface);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.62;
}

.app-shell {
  width: min(980px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(92px + env(safe-area-inset-bottom));
}

.topbar,
.brand,
.top-actions,
.wallet-summary,
.toolbar,
.identity-line,
.ticket-title-row,
.outcome-row,
.price-row,
.card-footer,
.card-actions,
.dialog-head,
.dialog-actions,
.bottom-tabs {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

.brand-mark,
.pm-mark,
.import-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.brand-mark {
  position: relative;
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--blue);
}

.brand-mark span {
  position: absolute;
  left: 26px;
  top: 10px;
  width: 22px;
  height: 28px;
  border-radius: 6px;
  background: #fff;
  clip-path: polygon(0 20%, 50% 0, 100% 20%, 100% 80%, 50% 100%, 0 80%);
}

.pm-mark::before {
  width: 21px;
  height: 27px;
  border-radius: 6px;
  background: #fff;
  clip-path: polygon(0 20%, 50% 0, 100% 20%, 100% 80%, 50% 100%, 0 80%);
  content: "";
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  top: 13px;
  display: block;
  width: 4px;
  height: 26px;
  border-radius: 8px;
  background: #fff;
  content: "";
}

.brand-mark::before {
  left: 10px;
  opacity: 0.64;
}

.brand-mark::after {
  left: 18px;
  opacity: 0.84;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.7rem;
  line-height: 1.12;
}

.top-actions {
  gap: 8px;
}

.icon-button,
.primary-button,
.ghost-button,
.primary-link {
  min-height: 42px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 850;
  text-decoration: none;
}

.icon-button {
  width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.icon-button.mini {
  width: 36px;
  min-height: 36px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
}

.icon-button svg,
.primary-button svg,
.ghost-button svg,
.primary-link svg {
  width: 18px;
  height: 18px;
}

.primary-button,
.primary-link {
  border: 1px solid transparent;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
}

.ghost-button {
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.wallet-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 12px;
}

.wallet-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(205, 213, 230, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 6px 18px rgba(37, 58, 124, 0.06);
}

.wallet-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.wallet-summary strong {
  display: block;
  overflow: hidden;
  font-size: clamp(0.95rem, 3vw, 1.08rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.link-control,
.search-control {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.search-control {
  flex: 1 1 260px;
  padding-left: 12px;
}

.link-control {
  width: 100%;
  padding-left: 12px;
}

.link-control svg,
.search-control svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 0;
  outline: 0;
  padding: 0 12px 0 8px;
  color: var(--ink);
  background: transparent;
}

input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

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

.segmented button.is-active {
  color: var(--blue);
  background: #fff;
  box-shadow: 0 1px 6px rgba(31, 35, 43, 0.09);
}

.identity-line {
  justify-content: space-between;
  gap: 10px;
  margin: 6px 2px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.wallet-stage {
  min-height: calc(100vh - 286px);
  padding: 4px 0 34px;
}

.wallet-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 560px);
  margin: 0 auto;
  padding-bottom: 96px;
  scroll-snap-type: y proximity;
}

.ticket-card {
  position: relative;
  z-index: var(--stack-z);
  width: 100%;
  min-height: 518px;
  margin-bottom: -58px;
  border-radius: var(--radius);
  overflow: hidden;
  color: #fff;
  background: var(--blue);
  box-shadow: var(--shadow);
  scroll-snap-align: start;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.ticket-card:last-child {
  margin-bottom: 0;
}

.ticket-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 72px rgba(37, 58, 124, 0.22);
}

.ticket-top {
  position: relative;
  min-height: 112px;
  padding: 17px 18px;
  background:
    linear-gradient(90deg, rgba(49, 87, 246, 0.98), rgba(49, 87, 246, 0.72)),
    var(--market-image, none);
  background-size: cover;
  background-position: center;
}

.ticket-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 16, 44, 0), rgba(8, 16, 44, 0.12));
}

.ticket-title-row,
.wallet-label {
  position: relative;
  z-index: 1;
}

.ticket-title-row {
  max-width: calc(100% - 126px);
  gap: 10px;
  font-weight: 950;
  line-height: 1.24;
}

.pm-mark {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #fff;
}

.pm-mark::before {
  width: 16px;
  height: 20px;
  background: var(--blue);
}

.wallet-label {
  position: absolute;
  right: 18px;
  top: 21px;
  max-width: 120px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.9);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 850;
}

.ticket-paper {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto auto;
  min-height: 296px;
  margin: -22px 18px 0;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

.ticket-paper::before,
.ticket-paper::after {
  position: absolute;
  top: calc(100% - 122px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue);
  content: "";
  z-index: 2;
}

.ticket-paper::before {
  left: -22px;
}

.ticket-paper::after {
  right: -22px;
}

.ticket-body {
  padding: 28px 28px 22px;
}

.market-question {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.34;
}

.outcome-row {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.outcome-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--blue);
  background: #eef2ff;
  font-size: 1.42rem;
  font-weight: 950;
}

.outcome-row strong {
  color: var(--ink);
  font-size: 1.24rem;
}

.price-row {
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.tear-line {
  position: relative;
  z-index: 3;
  height: 2px;
  margin: 0 24px;
  border: 0;
  background-image: repeating-linear-gradient(
    to right,
    #d5dbea 0,
    #d5dbea 9px,
    transparent 9px,
    transparent 17px
  );
  transform: translateY(18px);
}

.ticket-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  min-height: 118px;
  padding: 22px 28px 24px;
}

.stake-label {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.payout-value {
  margin: 0;
  color: var(--blue);
  font-size: 2.64rem;
  font-weight: 950;
  line-height: 0.96;
}

.odds-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--blue);
  background: #edf1ff;
  font-weight: 950;
}

.card-footer {
  justify-content: space-between;
  gap: 10px;
  min-height: 88px;
  padding: 14px 18px 16px;
}

.verify-pill,
.date-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.verify-verified {
  color: #dff7ec;
  background: rgba(20, 109, 72, 0.72);
}

.verify-unverified {
  color: #fff1cf;
  background: rgba(139, 86, 0, 0.68);
}

.verify-error {
  color: #ffe3e3;
  background: rgba(140, 42, 42, 0.68);
}

.date-pill {
  color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.13);
}

.card-actions {
  margin-left: auto;
  gap: 6px;
}

.import-panel {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  margin: min(10vh, 76px) auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 54px rgba(37, 58, 124, 0.12);
}

.import-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  color: var(--blue);
  background: #edf1ff;
}

.import-mark svg {
  width: 24px;
  height: 24px;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 1px dashed #cbd3e6;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--blue);
}

.empty-state h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(360px, calc(100% - 28px));
  transform: translateX(-50%);
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(205, 213, 230, 0.86);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 42px rgba(37, 58, 124, 0.18);
  backdrop-filter: blur(16px);
}

.bottom-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: 7px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.bottom-tabs button.is-active {
  color: #fff;
  background: var(--blue);
}

.bottom-tabs svg {
  width: 18px;
  height: 18px;
}

.ticket-dialog {
  width: min(520px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 28px 84px rgba(20, 24, 44, 0.28);
}

.ticket-dialog::backdrop {
  background: rgba(18, 22, 34, 0.48);
}

.dialog-head {
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
}

#dialogBody {
  padding: 16px 18px 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.detail-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 760;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.send-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.send-chat-field {
  display: grid;
  gap: 7px;
}

.send-chat-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.send-chat-field input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding-left: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.send-panel .primary-button {
  width: 100%;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(31, 35, 43, 0.94);
  box-shadow: 0 14px 34px rgba(31, 35, 43, 0.22);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 980px);
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  h1 {
    font-size: 1.44rem;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

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

  .primary-button,
  .link-control,
  .search-control {
    width: 100%;
  }

  .search-control {
    flex: 0 0 auto;
  }

  .wallet-summary div {
    min-height: 42px;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented button {
    width: 100%;
  }

  .wallet-stage {
    min-height: calc(100vh - 324px);
  }

  .ticket-card {
    min-height: 508px;
    margin-bottom: -46px;
  }

  .ticket-card:hover {
    transform: none;
  }

  .ticket-title-row {
    max-width: calc(100% - 104px);
    font-size: 0.94rem;
  }

  .wallet-label {
    max-width: 98px;
  }

  .ticket-paper {
    margin-inline: 12px;
  }

  .ticket-body,
  .ticket-bottom {
    padding-inline: 22px;
  }

  .market-question {
    font-size: 1rem;
  }

  .outcome-badge {
    font-size: 1.22rem;
  }

  .payout-value {
    font-size: 2.28rem;
  }

  .card-footer {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .card-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 420px) {
  .wallet-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ticket-paper::before,
  .ticket-paper::after {
    width: 36px;
    height: 36px;
  }

  .ticket-paper::before {
    left: -18px;
  }

  .ticket-paper::after {
    right: -18px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
