:root {
  color-scheme: light;
  --bg: #eef4fb;
  --bg-soft: #f8fbff;
  --card: #ffffff;
  --text: #13233a;
  --muted: #62748d;
  --line: #dbe5f0;
  --blue: #1663d8;
  --blue-dark: #0f4fb0;
  --blue-soft: #e8f1ff;
  --green: #14884d;
  --green-soft: #e8f8ef;
  --red: #c72d3b;
  --red-soft: #fff0f2;
  --shadow: 0 20px 50px rgba(27, 48, 80, 0.14);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(22, 99, 216, 0.14), transparent 34rem),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
}

button,
input,
textarea {
  font: inherit;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  font-weight: 800;
}

h2 {
  font-size: 22px;
  line-height: 1.25;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px;
  box-shadow: 0 12px 30px rgba(27, 48, 80, 0.09);
}

.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.tab-button.is-active {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 10px 22px rgba(22, 99, 216, 0.2);
}

.tab-panel {
  display: none;
  gap: 18px;
}

.tab-panel.is-active {
  display: grid;
}

.card {
  border: 1px solid rgba(219, 229, 240, 0.85);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card__header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.card__header p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.step {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 14px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 800;
}

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

.form {
  display: grid;
  gap: 12px;
}

.mail-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

label {
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fbfdff;
  color: var(--text);
  padding: 14px 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(22, 99, 216, 0.12);
}

.button {
  position: relative;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  color: #ffffff;
  background: var(--blue);
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 12px 24px rgba(22, 99, 216, 0.24);
}

.button:hover:not(:disabled) {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.button--ghost {
  min-height: 42px;
  color: var(--blue);
  background: var(--blue-soft);
  box-shadow: none;
}

.button--ghost:hover:not(:disabled) {
  color: #ffffff;
  background: var(--blue);
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.button.is-loading .spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.value-box {
  display: grid;
  min-width: 0;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  padding: 14px;
}

.value-box__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.value-box__text {
  min-height: 24px;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.4;
}

.value-box__text--secret {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
}

.code-card {
  display: grid;
  gap: 12px;
  justify-items: start;
  border-color: rgba(20, 136, 77, 0.25);
  background: linear-gradient(180deg, #ffffff 0%, var(--green-soft) 100%);
}

.code-card__label {
  color: var(--green);
  font-size: 16px;
  font-weight: 800;
}

.code-card__code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(36px, 8vw, 64px);
  line-height: 1;
}

.mail-preview {
  display: grid;
  gap: 16px;
}

.mail-preview__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.mail-preview__grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  padding: 14px;
}

.mail-preview__grid dt {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mail-preview__grid dd {
  margin: 0;
  min-height: 21px;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.mailbox-result {
  display: grid;
  gap: 16px;
}

.mailbox-header p {
  margin-top: 6px;
  color: var(--muted);
}

.mailbox-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 420px;
}

.mailbox-list {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.mailbox-item {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  color: var(--text);
  padding: 13px;
  text-align: left;
  cursor: pointer;
}

.mailbox-item.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 99, 216, 0.12);
}

.mailbox-item__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.mailbox-item__top strong,
.mailbox-item__subject,
.mailbox-item__preview {
  overflow: hidden;
  text-overflow: ellipsis;
}

.mailbox-item__top strong,
.mailbox-item__subject {
  white-space: nowrap;
}

.mailbox-item__subject {
  font-weight: 800;
}

.mailbox-item__preview {
  display: -webkit-box;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mailbox-item__code {
  width: fit-content;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
}

.mailbox-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  overflow: hidden;
}

.mailbox-empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.mailbox-detail__header {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.mailbox-detail__header h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.mailbox-detail__header dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.mailbox-detail__header dl div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
}

.mailbox-detail__header dt {
  color: var(--muted);
  font-weight: 800;
}

.mailbox-detail__header dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mailbox-code {
  width: min(420px, calc(100% - 32px));
  margin: 18px auto;
  border-radius: 16px;
  background: var(--blue-soft);
  padding: 18px;
  text-align: center;
}

.mailbox-code span {
  display: block;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.mailbox-code strong {
  display: block;
  margin-top: 6px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: clamp(32px, 6vw, 52px);
  letter-spacing: 0.12em;
}

.mailbox-code__copy {
  width: 100%;
  margin-top: 14px;
}

.mailbox-code--empty {
  background: #fff7ed;
}

.mailbox-code--empty span {
  color: #b45309;
}

.mailbox-code--empty p {
  margin: 8px 0 0;
  color: #92400e;
  font-weight: 700;
  line-height: 1.45;
}

.mailbox-body {
  padding: 18px;
}

.mailbox-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "Cascadia Mono", Consolas, monospace;
  line-height: 1.65;
}

.mailbox-frame {
  width: 100%;
  min-height: 620px;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.side-stack {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 18px;
}

.instruction {
  position: static;
}

.instruction-panel {
  display: none;
}

.instruction-panel.is-active {
  display: block;
}

.instruction ol {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.55;
}

.buy-card {
  display: grid;
  gap: 14px;
}

.buy-card p {
  color: var(--muted);
  line-height: 1.5;
}

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

.lot-link {
  display: grid;
  min-height: 46px;
  align-items: center;
  justify-content: stretch;
  gap: 6px;
  border-radius: 14px;
  color: #ffffff;
  background: var(--blue);
  padding: 12px 16px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 12px 24px rgba(22, 99, 216, 0.2);
  transition: transform 0.15s ease, background 0.15s ease;
}

.lot-link:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.lot-link__title,
.lot-link__stock,
.lot-link__price {
  display: block;
  overflow-wrap: anywhere;
}

.lot-link__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
}

.lot-link__stock,
.lot-link__price {
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 700;
}

.lot-link__price {
  color: #ffffff;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100% - 36px));
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(27, 48, 80, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

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

.toast.is-error {
  color: var(--red);
  background: var(--red-soft);
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .page {
    width: min(100% - 22px, 680px);
    padding: 28px 0;
  }

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

  .side-stack,
  .instruction {
    position: static;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 16px, 520px);
    padding: 22px 0;
  }

  .card {
    padding: 18px;
  }

  .card__header {
    gap: 12px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 20px;
  }

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

  .mail-preview__grid {
    grid-template-columns: 1fr;
  }

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

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

  .mailbox-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .mailbox-list {
    max-height: none;
    padding-right: 0;
  }

  .mailbox-detail__header dl div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .mailbox-frame {
    min-height: 520px;
  }

  .button {
    width: 100%;
  }
}
