:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --ink: #111312;
  --muted: #727771;
  --line: #dedfdb;
  --soft: #f1f3ef;
  --accent: #137a55;
  --warm: #d56f43;
  --danger: #b63832;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

main {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

.gate {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto auto auto auto 1fr;
  place-items: center;
  gap: 16px;
}

.shell {
  min-height: 100vh;
  padding: 32px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 24px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 750;
  line-height: 1;
}

.mark img {
  width: clamp(44px, 7vw, 76px);
  height: clamp(44px, 7vw, 76px);
  object-fit: contain;
  flex: 0 0 auto;
}

.gate .mark {
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.gate .mark img {
  width: clamp(86px, 13vw, 132px);
  height: clamp(86px, 13vw, 132px);
}

.shell .mark {
  font-size: 24px;
  gap: 10px;
}

.shell .mark img {
  width: 46px;
  height: 46px;
}

.badge {
  min-height: 32px;
  max-width: 46vw;
  padding: 6px 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button,
.link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

button svg,
.link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

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

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

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

.spinner {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.82s linear infinite;
}

.status.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status.loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid #cfd3ce;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.82s linear infinite;
}

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

.qr {
  width: 280px;
  height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.export-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

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

input::placeholder {
  color: #a0a49f;
}

.status,
.result {
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
}

.result a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  text-decoration: none;
  font-weight: 650;
}

.result a svg {
  width: 17px;
  height: 17px;
}

.history {
  margin-top: 28px;
  border-top: 1px solid var(--line);
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-title {
  display: flex;
  gap: 10px;
  align-items: baseline;
  min-width: 0;
}

.history-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-title span {
  color: var(--warm);
  font-size: 13px;
  font-weight: 700;
}

.history-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.icon-link {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.icon-link svg {
  width: 17px;
  height: 17px;
}

.error {
  color: var(--danger);
}

@media (max-width: 640px) {
  main {
    width: min(100vw - 20px, 980px);
  }

  .shell {
    padding-top: 20px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    max-width: 58vw;
  }

  .export-form,
  .history-row {
    grid-template-columns: 1fr;
  }

  .badge {
    max-width: 52vw;
  }

  .history-actions {
    justify-content: flex-start;
  }
}
