:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --green: #0f9f6e;
  --green-soft: #dff7ec;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #ffedd5;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-root {
  min-height: 100vh;
}

.loading-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loading-screen {
  color: var(--muted);
}

.loading-icon {
  width: 84px;
  height: 84px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
}

.brand-icon.small {
  width: 42px;
  height: 42px;
}

.brand-row h1,
.brand-row p {
  margin: 0;
}

.brand-row h1 {
  font-size: 1.8rem;
  line-height: 1.1;
}

.brand-row p,
.muted {
  color: var(--muted);
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -14px -14px 14px;
  padding: 12px 14px;
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.compact-brand {
  margin-bottom: 0;
  min-width: 0;
}

.compact-brand > div {
  min-width: 0;
}

.compact-brand span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-brand strong {
  display: block;
  max-width: 58vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-picker {
  min-width: min(280px, 42vw);
  margin-left: auto;
}

.collection-picker select {
  min-height: 42px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.share-action {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.icon-button,
.small-button,
.secondary-button,
.primary-button,
.quick-action,
.tab-bar button,
.filter-row button,
.auth-tabs button,
.tile-stepper button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.secondary-button,
.small-button {
  padding: 0 14px;
}

.icon-button {
  min-width: 54px;
  padding: 0 12px;
}

.stack-form,
.inline-form,
.quick-form {
  display: grid;
  gap: 14px;
}

.stack-form.compact {
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 1rem;
}

textarea {
  min-height: 126px;
  padding: 12px;
  line-height: 1.4;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.form-error,
.notice {
  margin: 14px 0 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}

.form-error,
.notice.error {
  background: var(--red-soft);
  color: #991b1b;
}

.notice.success {
  background: var(--green-soft);
  color: #047857;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  width: max-content;
  max-width: min(420px, calc(100vw - 28px));
  transform: translateX(-50%);
  border: 1px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-weight: 900;
  text-align: center;
}

.toast.success {
  background: var(--green-soft);
  color: #047857;
}

.toast.error {
  background: var(--red-soft);
  color: #991b1b;
}

.share-toast {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 20;
  width: max-content;
  max-width: 220px;
  border: 1px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.12);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.share-toast.success {
  background: var(--green-soft);
  color: #047857;
}

.share-toast.error {
  background: var(--red-soft);
  color: #991b1b;
}

.support-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(23, 32, 51, 0.36);
}

.support-dialog {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.support-dialog .panel-title {
  margin-bottom: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(23, 32, 51, 0.05);
  margin-bottom: 14px;
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h2,
.suggestion-card h3 {
  margin: 0;
  line-height: 1.2;
}

.panel-title h2 {
  font-size: 1.05rem;
}

.progress-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(23, 32, 51, 0.05);
  margin-bottom: 14px;
  padding: 14px;
}

.progress-ring {
  --progress: 0%;
  width: 68px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 0 56%, transparent 57%),
    conic-gradient(var(--green) var(--progress), #edf2f7 0);
}

.progress-ring span {
  font-size: 0.95rem;
  font-weight: 900;
}

.progress-copy {
  display: grid;
  gap: 2px;
}

.progress-copy strong {
  font-size: 1.45rem;
  line-height: 1.05;
}

.progress-copy span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 4px;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--line);
}

.stat-card span {
  font-size: 1.7rem;
  font-weight: 900;
}

.stat-card strong {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-card.owned {
  background: var(--green-soft);
}

.stat-card.missing {
  background: var(--red-soft);
}

.stat-card.trade {
  background: var(--amber-soft);
}

.tab-bar,
.filter-row,
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.filter-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-picker {
  margin-bottom: 14px;
}

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

.tab-bar button,
.filter-row button,
.auth-tabs button {
  background: #ffffff;
}

.tab-bar button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  min-height: 20px;
  border-radius: 999px;
  background: var(--red);
  color: #ffffff;
  padding: 2px 6px;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 900;
}

.tab-bar button.active,
.filter-row button.active,
.auth-tabs button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: #1d4ed8;
}

.quick-form {
  grid-template-columns: 1fr repeat(3, minmax(70px, auto));
  align-items: end;
}

.quick-action {
  padding: 0 10px;
}

.sticker-sections {
  display: grid;
  gap: 18px;
}

.sticker-section {
  display: grid;
  gap: 10px;
}

.section-separator {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-top: 2px solid var(--line);
  padding-top: 12px;
}

.sticker-section:first-child .section-separator {
  border-top: 0;
  padding-top: 0;
}

.section-separator h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
}

.section-separator span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.sticker-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.sticker-tile {
  min-height: 132px;
  display: grid;
  grid-template-rows: 1fr 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.sticker-tile.is-owned {
  border-color: rgba(15, 159, 110, 0.35);
}

.sticker-tile.is-missing {
  border-color: rgba(220, 38, 38, 0.25);
}

.sticker-tile.has-trade {
  border-color: rgba(217, 119, 6, 0.45);
}

.tile-main {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.sticker-number {
  font-size: 1.28rem;
  line-height: 1;
  font-weight: 900;
}

.sticker-detail {
  width: 100%;
  min-height: 18px;
  overflow: hidden;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-state {
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.is-owned .sticker-state {
  background: var(--green-soft);
  color: #047857;
}

.is-missing .sticker-state {
  background: var(--red-soft);
  color: #991b1b;
}

.has-trade .sticker-state {
  background: var(--amber-soft);
  color: #92400e;
}

.tile-stepper {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  border-top: 1px solid var(--line);
  text-align: center;
  font-weight: 900;
}

.tile-stepper button {
  min-height: 37px;
  border: 0;
  border-radius: 0;
  background: #f8fafc;
}

.tile-stepper span {
  font-size: 0.92rem;
}

.suggestion-list {
  display: grid;
  gap: 10px;
}

.suggestion-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.suggestion-card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.trade-lines {
  display: grid;
  gap: 8px;
}

.trade-lines p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.trade-lines span {
  min-width: 42px;
  color: var(--muted);
  font-weight: 900;
}

.number-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1d4ed8;
  padding: 3px 8px;
  font-size: 0.82rem;
}

.ring-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.ring-steps li {
  line-height: 1.35;
}

.ring-steps span {
  color: var(--muted);
}

.request-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.request-controls.has-offer {
  grid-template-columns: minmax(180px, 1.4fr) 1fr 1fr auto;
}

.request-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.request-header h3 {
  margin-bottom: 0;
}

.meeting-line {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: capitalize;
}

.status-pill.accepted,
.status-pill.completed {
  background: var(--green-soft);
  color: #047857;
}

.status-pill.declined,
.status-pill.cancelled {
  background: var(--red-soft);
  color: #991b1b;
}

.response-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.response-list span {
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 800;
}

.response-list b {
  color: var(--ink);
}

.request-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.request-actions.single {
  grid-template-columns: 1fr;
}

.empty-grid {
  grid-column: 1 / -1;
  margin: 0;
}

@media (max-width: 620px) {
  .top-bar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .collection-picker {
    grid-column: 1 / -1;
    order: 3;
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .top-actions {
    justify-self: end;
  }

  .compact-brand strong {
    max-width: 66vw;
  }

  .quick-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-form label {
    grid-column: 1 / -1;
  }

  .sticker-section-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }

  .section-separator {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .sticker-tile {
    min-height: 126px;
  }

  .request-controls {
    grid-template-columns: 1fr;
  }

  .request-controls.has-offer {
    grid-template-columns: 1fr;
  }

  .request-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 20px;
  }

  .top-bar {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 0 0 16px;
  }
}
