:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  background: #eef2f8;
  color: #172033;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(71, 111, 230, 0.16), transparent 34rem),
    linear-gradient(145deg, #f7f9fd 0%, #e8edf6 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.window {
  width: min(100%, 580px);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d9e0eb;
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(39, 52, 84, 0.16);
}

.titlebar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 13px;
  padding: 20px 24px;
  color: #ffffff;
  background: linear-gradient(125deg, #385bd2, #597eea);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 21px;
  font-weight: 700;
}

.titlebar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.content {
  padding: 25px 28px 28px;
}

/* 链接校验中 / 校验失败：只显示这一块，不再露出表单和标题栏 */
body.gate-mode .titlebar {
  display: none;
}

.gate {
  padding: 46px 28px 50px;
  text-align: center;
}

.gate-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  place-items: center;
  border: 1px solid #f3d5d5;
  border-radius: 50%;
  background: #fdf1f1;
  font-size: 26px;
  line-height: 1;
}

.gate-icon.is-loading {
  border-color: #dbe4ff;
  background: #eef3ff;
  animation: gate-pulse 1.15s ease-in-out infinite;
}

@keyframes gate-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.gate-title {
  margin: 0;
  color: #26304a;
  font-size: 17px;
  font-weight: 600;
}

.gate-detail {
  margin: 10px 0 0;
  color: #6a7688;
  font-size: 13px;
  line-height: 1.65;
}

.field-grid {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 9px 14px;
}

.field-grid > label {
  color: #445068;
  font-size: 13px;
  font-weight: 600;
}

.field-grid input {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #ced6e3;
  border-radius: 8px;
  outline: none;
  color: #1f2a3d;
  background: #ffffff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field-grid input:focus {
  border-color: #5275df;
  box-shadow: 0 0 0 3px rgba(82, 117, 223, 0.14);
}

.field-grid input[readonly] {
  color: #46536a;
  background: #f5f7fa;
}

.input-with-status {
  position: relative;
}

.input-with-status input {
  padding-right: 36px;
}

.status-dot {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 9px;
  height: 9px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #d3a627;
  box-shadow: 0 0 0 4px rgba(211, 166, 39, 0.13);
}

.status-dot.ready {
  background: #31a166;
  box-shadow: 0 0 0 4px rgba(49, 161, 102, 0.12);
}

.status-dot.error {
  background: #cf4d4d;
  box-shadow: 0 0 0 4px rgba(207, 77, 77, 0.12);
}

.field-hint {
  grid-column: 2;
  margin-top: -4px;
  color: #8791a3;
  font-size: 11px;
}

.quick-guide {
  margin-top: 18px;
  padding: 12px 15px;
  border: 1px solid #dce3ef;
  border-radius: 10px;
  background: #f8faff;
}

.quick-guide h2 {
  margin: 0 0 7px;
  color: #445068;
  font-size: 12px;
  font-weight: 700;
}

.quick-guide ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 20px;
  margin: 0;
  padding-left: 19px;
  color: #697586;
  font-size: 11px;
  line-height: 1.45;
}

.primary-button {
  width: 100%;
  margin-top: 22px;
  padding: 11px 18px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(120deg, #3c5fd1, #5578e5);
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 140ms ease, opacity 140ms ease;
}

.primary-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.primary-button:hover:not(:disabled) {
  background: linear-gradient(120deg, #3456c5, #496ddc);
}

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.copy-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 120ms ease, background 140ms ease, opacity 140ms ease;
}

.copy-button:active {
  transform: translateY(1px);
}

.result-panel {
  margin-top: 20px;
  padding: 15px 16px;
  border: 1px solid #dce3ef;
  border-radius: 10px;
  background: #f8faff;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  color: #667189;
  font-size: 12px;
  font-weight: 600;
}

.copy-button {
  padding: 5px 10px;
  color: #4162c9;
  background: #e7edff;
  font-size: 12px;
}

.copy-button:disabled {
  cursor: default;
  opacity: 0.45;
}

#access-code {
  display: block;
  min-height: 24px;
  overflow-wrap: anywhere;
  color: #1d2f65;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.message {
  margin: 10px 0 0;
  color: #63708a;
  font-size: 12px;
  text-align: center;
}

.message.error {
  color: #bf3f46;
}

.message.success {
  color: #27865a;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .window {
    border-radius: 14px;
  }

  .titlebar,
  .content,
  .gate {
    padding-left: 18px;
    padding-right: 18px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .field-hint {
    grid-column: 1;
    margin: -2px 0 7px;
  }

  .quick-guide ol {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 780px) {
  .app-shell {
    align-items: start;
  }
}
