:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2ff;
  color: #172033;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.24), transparent 32rem),
    linear-gradient(135deg, #f8fafc 0%, #eef2ff 45%, #e0f2fe 100%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.shell.login-mode,
.shell.result-mode {
  justify-content: center;
}

.shell.login-mode {
  grid-template-columns: minmax(320px, 560px);
}

.shell.result-mode {
  grid-template-columns: minmax(320px, 1040px);
}

.shell.login-mode .result-panel,
.shell.result-mode .form-panel {
  display: none;
}

.panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(30, 41, 59, 0.14);
  backdrop-filter: blur(18px);
}

.form-panel,
.result-panel {
  padding: 34px;
}

.result-panel {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.06;
  letter-spacing: -0.04em;
}

h2 {
  margin: 12px 0 6px;
}

form,
.result {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field-tip {
  margin: -4px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-weight: 700;
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
}

.remember-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: #2563eb;
}

input,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.94);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

details {
  color: #475569;
}

summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 10px;
}

button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  padding: 15px 18px;
  cursor: pointer;
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: white;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 18px 38px rgba(79, 70, 229, 0.28);
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary-button {
  margin-top: 16px;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
  box-shadow: none;
}

.secondary-button:hover {
  background: rgba(15, 23, 42, 0.1);
}

.empty-state {
  text-align: center;
  margin: auto;
}

.qr-placeholder {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: 26px;
  display: grid;
  place-items: center;
  border: 2px dashed #94a3b8;
  color: #94a3b8;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.qr-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  text-align: center;
}

.qr-card img {
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: block;
  padding: 14px;
  border-radius: 24px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e2e8f0, 0 18px 40px rgba(15, 23, 42, 0.12);
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.uid-card-title {
  word-break: break-word;
}

.valid-window {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(241, 245, 249, 0.76);
  color: #475569;
  text-align: center;
}

.time-title {
  display: block;
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.time-value {
  display: block;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  word-break: keep-all;
}

.refresh-countdown {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  margin: 12px auto 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  font-weight: 900;
}

.status {
  min-height: 24px;
  margin: 18px 0 0;
  text-align: center;
  font-weight: 800;
}

.status.loading { color: #2563eb; }
.status.success { color: #15803d; }
.status.error { color: #dc2626; }

.hidden {
  display: none;
}

@media (max-width: 840px) {
  body {
    background:
      radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.2), transparent 20rem),
      linear-gradient(180deg, #f8fafc 0%, #eef2ff 55%, #e0f2fe 100%);
  }

  .shell {
    width: 100%;
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  }

  .shell.login-mode,
  .shell.result-mode {
    grid-template-columns: 1fr;
  }

  .panel {
    border-radius: 24px;
    box-shadow: 0 18px 46px rgba(30, 41, 59, 0.12);
  }

  .form-panel,
  .result-panel {
    padding: 22px;
  }

  .result-panel {
    min-height: 300px;
  }

  h1 {
    font-size: clamp(32px, 10vw, 42px);
    line-height: 1.08;
  }

  form,
  .result {
    gap: 14px;
    margin-top: 22px;
  }

  .qr-placeholder {
    width: min(52vw, 190px);
    height: min(52vw, 190px);
    border-radius: 22px;
    font-size: 38px;
  }

  .qr-card {
    max-width: none;
    padding: 14px;
    border-radius: 22px;
  }

  .qr-grid {
    grid-template-columns: 1fr;
  }

  .qr-card img {
    width: min(100%, 300px);
    padding: 10px;
    border-radius: 20px;
  }

  .valid-window {
    padding: 10px 12px;
  }

  .time-value {
    font-size: 13px;
  }

  .refresh-countdown {
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .form-panel,
  .result-panel {
    padding: 18px;
  }

  h1 {
    font-size: clamp(28px, 11vw, 36px);
  }

  input,
  button {
    border-radius: 14px;
  }

  .qr-card img {
    width: min(100%, 270px);
  }
}
