:root {
  color-scheme: light;
  --bg: #f3f7f6;
  --surface: #ffffff;
  --ink: #172126;
  --muted: #738087;
  --line: #dce6e2;
  --teal: #0f766e;
  --teal-dark: #0a4f4a;
  --coral: #f76672;
  --coral-dark: #df4f5c;
  --amber: #f4b35b;
  --danger: #c9362c;
  --ok: #138a43;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: center;
  min-height: 92px;
  padding: max(16px, env(safe-area-inset-top)) 20px 18px;
  background: linear-gradient(135deg, var(--teal), #156b90);
  color: #fff;
}

.topbar::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 64px;
  height: 6px;
  border-radius: 999px;
  background: var(--amber);
}

.topbar h1 {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.16;
  font-weight: 780;
}

form {
  padding: 14px 14px 0;
}

.form-section {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 39, 42, 0.08);
}

.form-section.no-heading {
  padding-top: 17px;
}

.form-section.no-heading .field:first-child {
  margin-top: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.section-title span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 24px;
  border-radius: 6px;
  background: #e2f3ef;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field > span {
  color: #304045;
  font-size: 14px;
  font-weight: 720;
}

.field input,
.field select,
.readonly-field strong {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cddad5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 13px;
  font-size: 16px;
}

.field input::placeholder {
  color: #99a3a8;
}

.field select {
  appearance: auto;
  color: #3f4d52;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.readonly-field strong {
  display: flex;
  align-items: center;
  background: #f6faf8;
  font-weight: 650;
}

.password-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented b {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid #d6e2de;
  border-radius: 8px;
  background: #f8fbfa;
  color: #435156;
  font-size: 15px;
  font-weight: 720;
  white-space: nowrap;
}

.segmented input:checked + b {
  border-color: rgba(15, 118, 110, 0.38);
  background: #e2f3ef;
  color: var(--teal-dark);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.08);
}

.phone-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 9px;
}

.code-button,
.submit {
  border: 0;
  border-radius: 8px;
  background: var(--coral);
  color: #fff;
  font-weight: 780;
  box-shadow: 0 12px 22px rgba(247, 102, 114, 0.22);
}

.code-button {
  min-height: 48px;
  padding: 0 8px;
  font-size: 14px;
}

.submit {
  width: 100%;
  min-height: 54px;
  font-size: 18px;
}

.code-button:active,
.submit:active {
  background: var(--coral-dark);
}

.code-button:disabled,
.submit:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

small {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

[aria-invalid="true"] {
  border-color: var(--danger) !important;
}

.hidden {
  display: none;
}

.result {
  min-height: 26px;
  margin: 0;
  padding: 2px 4px 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.result.ok {
  color: var(--ok);
}

.result.bad {
  color: var(--danger);
}

.action-bar {
  margin: 0 -14px;
  padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(220, 230, 226, 0.85);
  background: var(--bg);
}

@media (max-width: 380px) {
  .topbar {
    min-height: 88px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  form {
    padding-left: 10px;
    padding-right: 10px;
  }

  .form-section {
    padding: 13px;
  }

  .password-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .segmented {
    gap: 6px;
  }

  .segmented b {
    font-size: 14px;
  }

  .phone-control {
    grid-template-columns: 1fr;
  }

  .code-button {
    width: 118px;
  }
}
