:root {
  --t1: #4fa8aa;
  --t1-dark: #337f82;
  --t1-soft: #edf7f7;
  --page: #f5f6f7;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #646a73;
  --border: #dfe3e8;
  --border-strong: #c9cdd4;
  --danger: #d54941;
  --danger-soft: #fff2f0;
  --focus: rgba(79, 168, 170, 0.22);
  --shadow: 0 3px 14px rgba(31, 35, 41, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { background: var(--page); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; line-height: 1.55; }

body { margin: 0; min-width: 320px; background: var(--page); }

button, input, textarea { font: inherit; }

.page-shell { width: min(100%, 760px); margin: 0 auto; padding: 16px 12px 32px; }
.form-card, .success-card { background: var(--card); border: 1px solid #e6e8eb; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.form-header { padding: 28px 20px 24px; border-top: 5px solid var(--t1); }
.brand-logo { display: block; width: 132px; height: auto; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--t1-dark); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; }
h1 { margin: 0; font-size: clamp(26px, 6vw, 34px); line-height: 1.25; letter-spacing: -0.02em; }
.form-description { margin: 14px 0 0; color: var(--muted); font-size: 15px; white-space: pre-line; }
.preview-banner { padding: 10px 20px; color: #785d23; background: #fff8df; border-top: 1px solid #f1df9b; border-bottom: 1px solid #f1df9b; font-size: 13px; font-weight: 600; text-align: center; }
.privacy-note { display: grid; gap: 3px; margin-top: 20px; padding: 14px 16px; color: #3f5d5e; background: var(--t1-soft); border: 1px solid #d5ecec; border-radius: var(--radius); font-size: 13px; }
.privacy-note strong { color: #2f6f72; }

.error-summary { margin: 0 20px 22px; padding: 15px 17px; color: #8f2922; background: var(--danger-soft); border: 1px solid #f2c7c3; border-radius: var(--radius); }
.error-summary h2 { margin: 0 0 6px; font-size: 15px; }
.error-summary ul { margin: 0; padding-left: 20px; }
.error-summary a { color: inherit; }

.form-section { padding: 28px 20px; border-top: 1px solid #eceef1; }
.section-heading { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; margin-bottom: 28px; }
.section-index { display: grid; place-items: center; width: 34px; height: 34px; color: var(--t1-dark); background: var(--t1-soft); border-radius: 50%; font-size: 12px; font-weight: 800; }
.section-heading h2 { margin: 0; font-size: 20px; line-height: 1.35; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.field-grid { display: grid; gap: 0 18px; }
.field { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
.field label, .field legend { display: block; margin: 0 0 8px; color: var(--text); font-size: 14px; font-weight: 600; }
.field legend { width: 100%; }
.required-mark { color: var(--danger); font-weight: 700; }
.optional-label { margin-left: 5px; color: #8f959e; font-size: 12px; font-weight: 400; }
.field-help { margin: -3px 0 9px; color: var(--muted); font-size: 12px; }
.otp-row { display: flex; gap: 8px; align-items: center; margin-top: 9px; }
.otp-row input { flex: 1; min-width: 90px; }
.otp-row button { min-height: 42px; padding: 9px 13px; white-space: nowrap; }
.otp-row + .field-help { margin-top: 7px; }
.phone-input-row { display: flex; align-items: stretch; width: 100%; }
.phone-prefix { display: grid; min-width: 58px; place-items: center; padding: 9px 12px; color: var(--t1-dark); background: var(--t1-soft); border: 1px solid var(--border-strong); border-right: 0; border-radius: 6px 0 0 6px; font-weight: 700; }
.phone-input-row input { flex: 1; min-width: 0; border-radius: 0 6px 6px 0; }
.phone-input-row:focus-within .phone-prefix { border-color: var(--t1); }
.field-error { margin: 7px 0 0; color: var(--danger); font-size: 12px; font-weight: 500; }

input[type="text"], input[type="tel"], input[type="email"], textarea {
  display: block; width: 100%; min-height: 42px; padding: 9px 12px; color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: 6px; outline: none; transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a6abb2; }
input:hover, textarea:hover { border-color: #aeb4bc; }
input:focus, textarea:focus { border-color: var(--t1); box-shadow: 0 0 0 3px var(--focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"], fieldset[aria-invalid="true"] input { border-color: var(--danger); }

.option-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.option-card { position: relative; display: block !important; margin: 0 !important; cursor: pointer; }
.option-card input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.option-card span { display: flex; min-height: 42px; align-items: center; padding: 9px 12px 9px 40px; color: #373c43; background: #fff; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-weight: 400; transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease; }
.option-card span::before { position: absolute; left: 13px; width: 16px; height: 16px; content: ""; background: #fff; border: 1px solid #b9bec6; border-radius: 3px; }
.option-card input[type="radio"] + span::before { border-radius: 50%; }
.option-card:hover span { border-color: #9bcfd0; background: #fbfefe; }
.option-card input:focus-visible + span { border-color: var(--t1); box-shadow: 0 0 0 3px var(--focus); }
.option-card input:checked + span { color: #285f61; background: var(--t1-soft); border-color: var(--t1); }
.option-card input:checked + span::before { background: var(--t1); border-color: var(--t1); box-shadow: inset 0 0 0 3px #fff; }
.option-card input[type="checkbox"]:checked + span::after { position: absolute; left: 17px; top: 50%; width: 7px; height: 4px; content: ""; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-65%) rotate(-45deg); }
.option-card--large span { display: grid; gap: 2px; align-content: center; min-height: 62px; padding-left: 42px; }
.option-card--large span::before { top: 22px; }
.option-card--large span strong { font-size: 14px; }
.option-card--large span small { color: var(--muted); font-size: 12px; }

.upload-box { display: flex !important; gap: 12px; align-items: center; min-height: 70px; margin: 0 !important; padding: 12px 14px; color: #373c43; background: #fafbfc; border: 1px dashed #b9bec6; border-radius: 6px; cursor: pointer; transition: border-color 150ms ease, background 150ms ease; }
.upload-box:hover { background: var(--t1-soft); border-color: var(--t1); }
.upload-box:focus-within { box-shadow: 0 0 0 3px var(--focus); }
.upload-icon { display: grid; place-items: center; flex: 0 0 34px; height: 34px; color: var(--t1-dark); background: #fff; border: 1px solid #cde5e5; border-radius: 5px; font-size: 21px; font-weight: 400; }
.upload-box strong, .upload-box small { display: block; }
.upload-box small { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.conditional-flow { margin-top: 10px; }
.branch-panel { margin: 10px 0 24px; padding: 20px 16px 1px; background: #fbfdfd; border: 1px solid #d9eeee; border-radius: var(--radius); }
.branch-heading { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid #e4eeee; }
.branch-heading span { color: #285f61; font-size: 15px; font-weight: 700; }
.branch-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.course-panel { margin: 4px -10px 24px; padding: 22px 10px 0; border-top: 1px solid #e7e9ec; }
.course-heading { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; margin-bottom: 22px; }
.course-heading > span { grid-row: 1 / span 2; display: grid; place-items: center; width: 46px; height: 46px; color: #fff; background: var(--t1); border-radius: 7px; font-size: 11px; font-weight: 700; }
.course-heading h3 { margin: 0; font-size: 17px; }
.course-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.continuation { padding: 18px; background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); }
[hidden] { display: none !important; }

.form-actions { padding: 22px 20px 26px; background: #fafbfc; border-top: 1px solid #eceef1; }
.form-actions p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.submit-button { display: flex; width: 100%; min-height: 46px; align-items: center; justify-content: center; gap: 12px; padding: 11px 20px; color: #fff; background: var(--t1); border: 1px solid var(--t1); border-radius: 6px; cursor: pointer; font-weight: 700; transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 100ms ease; }
.submit-button:hover { background: var(--t1-dark); border-color: var(--t1-dark); }
.submit-button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.submit-button:active { transform: translateY(1px); }
.submit-button[disabled] { cursor: wait; opacity: 0.7; }
.draft-button { display: flex; min-height: 46px; align-items: center; justify-content: center; padding: 11px 18px; color: var(--t1-dark); background: #fff; border: 1px solid var(--t1); border-radius: 6px; cursor: pointer; font-weight: 700; }
.draft-button:hover { background: var(--t1-soft); }
.draft-button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.draft-button[disabled] { cursor: wait; opacity: 0.65; }
.draft-dialog { width: min(calc(100% - 24px), 520px); padding: 28px 24px 24px; color: var(--text); background: #fff; border: 0; border-top: 5px solid var(--t1); border-radius: 10px; box-shadow: 0 18px 60px rgba(31, 35, 41, 0.24); }
.draft-dialog::backdrop { background: rgba(31, 35, 41, 0.48); }
.draft-dialog h2 { margin: 0; font-size: 24px; }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; color: var(--muted); background: transparent; border: 0; border-radius: 50%; cursor: pointer; font-size: 26px; line-height: 1; }
.dialog-close:hover { background: #f1f3f4; }
.draft-dialog-help { margin: 10px 0 16px; color: var(--muted); font-size: 13px; }
.draft-qr { display: block; width: min(72vw, 250px); height: auto; margin: 0 auto 18px; border: 1px solid var(--border); border-radius: 6px; }
.draft-link-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.draft-link { width: 100%; min-height: 42px; padding: 9px 12px; color: #3f464f; background: #f7f8f9; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 12px; }
.draft-dialog-actions { display: grid; gap: 10px; margin-top: 14px; }
.draft-download { text-decoration: none; }
.draft-expiry { margin: 14px 0 0; color: #8f959e; font-size: 12px; text-align: center; }
.page-footer { margin: 18px 0 0; color: #8f959e; font-size: 11px; text-align: center; }

.success-page { min-height: 100vh; }
.success-shell { display: grid; min-height: 100vh; place-items: center; padding: 20px 12px; }
.success-card { width: min(100%, 620px); padding: 30px 22px 34px; border-top: 5px solid var(--t1); text-align: center; }
.success-card .brand-logo { margin: 0 auto 30px; }
.success-icon { display: grid; width: 58px; height: 58px; place-items: center; margin: 0 auto 18px; color: #fff; background: var(--t1); border-radius: 50%; font-size: 28px; }
.success-card h1 { font-size: clamp(25px, 6vw, 32px); }
.success-card > p:not(.eyebrow) { max-width: 490px; margin: 14px auto 0; color: var(--muted); font-size: 14px; }
.success-note { display: grid; gap: 4px; margin-top: 26px; padding: 15px 17px; background: #f7f8f9; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; text-align: left; }
.success-note span { color: var(--muted); }
.success-next-steps { margin: 20px 0 0; padding: 14px 18px 14px 34px; color: var(--muted); background: #f7fbfb; border: 1px solid #dbeceb; border-radius: var(--radius); text-align: left; }
.success-links { display: grid; gap: 10px; margin-top: 18px; }

@media (min-width: 560px) {
  .page-shell { padding: 32px 20px 44px; }
  .form-header { padding: 38px 42px 32px; }
  .error-summary { margin-right: 42px; margin-left: 42px; }
  .form-section { padding: 36px 42px; }
  .field-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-grid--inline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .option-grid--binary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 25px 42px 30px; }
  .form-actions p { margin: 0; }
  .submit-button { width: auto; min-width: 180px; }
  .draft-dialog-actions { grid-template-columns: 1fr 1fr; }
  .course-panel { margin-right: 0; margin-left: 0; padding: 24px 0 0 18px; border-left: 3px solid #d9eeee; }
  .success-card { padding: 40px 50px 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

/* Shared draft interaction: a draggable glass action stays available while the form scrolls. */
.draft-float { position: fixed; z-index: 20; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); display: inline-flex; width: auto; min-width: 88px; min-height: 52px; align-items: center; justify-content: center; gap: 0; padding: 12px 22px; color: #fff; background: linear-gradient(135deg, rgba(79, 168, 170, .88), rgba(51, 127, 130, .8)); border: 1px solid rgba(255,255,255,.58); border-radius: 18px; box-shadow: 0 14px 34px rgba(42, 105, 108, .24), inset 0 1px 0 rgba(255,255,255,.46); backdrop-filter: blur(18px) saturate(145%); -webkit-backdrop-filter: blur(18px) saturate(145%); cursor: grab; user-select: none; touch-action: none; }
.draft-float:hover { background: linear-gradient(135deg, rgba(93, 184, 186, .94), rgba(51, 127, 130, .88)); transform: translateY(-1px); }
.draft-float:active, .draft-float.is-dragging { cursor: grabbing; transform: scale(.98); }
.draft-float[disabled] { cursor: wait; opacity: .7; transform: none; }
.draft-confirm-dialog { width: min(calc(100% - 24px), 520px); padding: 30px 26px 24px; color: var(--text); background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.92); border-top: 5px solid var(--t1); border-radius: 15px; box-shadow: 0 22px 70px rgba(31,35,41,.28); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.draft-confirm-dialog::backdrop { background: rgba(31,35,41,.5); backdrop-filter: blur(3px); }
.draft-confirm-dialog h2 { margin: 0; font-size: clamp(24px, 5vw, 30px); line-height: 1.25; }
.draft-confirm-lead { margin: 12px 0 18px; color: var(--muted); font-size: 14px; }
.draft-confirm-list { display: grid; gap: 10px; margin: 0; padding: 16px 18px 16px 34px; color: #4d5660; background: var(--t1-soft); border: 1px solid #d5ecec; border-radius: 10px; font-size: 13px; }
.draft-confirm-list strong { color: var(--t1-dark); }
.draft-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.draft-confirm-actions .draft-button, .draft-confirm-actions .submit-button { width: 100%; min-width: 0; text-decoration: none; }
@media (max-width: 559px) { .draft-float { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); min-width: 72px; padding: 12px 18px; border-radius: 16px; } .draft-confirm-actions { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .draft-float { transition: none; } }

/* Community group access: a second draggable glass action above the draft control. */
.community-group-float { position: fixed; z-index: 21; right: max(18px, env(safe-area-inset-right)); bottom: max(88px, calc(66px + env(safe-area-inset-bottom))); min-width: 104px; min-height: 48px; padding: 11px 18px; color: #2f7779; background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(224,246,246,.76)); border: 1px solid rgba(255,255,255,.82); border-radius: 17px; box-shadow: 0 12px 30px rgba(42,105,108,.18), inset 0 1px 0 rgba(255,255,255,.72); backdrop-filter: blur(18px) saturate(145%); -webkit-backdrop-filter: blur(18px) saturate(145%); cursor: grab; user-select: none; touch-action: none; }
.community-group-float:hover { color: #245f61; background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(207,239,239,.9)); transform: translateY(-1px); }
.community-group-float:active, .community-group-float.is-dragging { cursor: grabbing; transform: scale(.98); }
.community-group-float[disabled] { cursor: wait; opacity: .7; transform: none; }
.community-group-dialog { width: min(calc(100% - 24px), 520px); padding: 30px 26px 24px; color: var(--text); background: rgba(255,255,255,.95); border: 1px solid rgba(255,255,255,.92); border-top: 5px solid var(--t1); border-radius: 15px; box-shadow: 0 22px 70px rgba(31,35,41,.28); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.community-group-dialog::backdrop { background: rgba(31,35,41,.5); backdrop-filter: blur(3px); }
.community-group-dialog h2 { margin: 0; font-size: clamp(24px, 5vw, 30px); line-height: 1.25; }
.community-group-lead { margin: 12px 0 16px; color: var(--muted); font-size: 14px; }
.community-group-qr { display: block; width: min(72vw, 300px); height: auto; margin: 0 auto 16px; border: 1px solid var(--border); border-radius: 10px; }
.community-group-note { margin: 0; padding: 12px 14px; color: #3f5d5e; background: var(--t1-soft); border: 1px solid #d5ecec; border-radius: 9px; font-size: 13px; }
.community-group-link { display: block; margin-top: 14px; color: var(--t1-dark); font-size: 13px; text-align: center; text-decoration: underline; }
@media (max-width: 559px) { .community-group-float { right: 14px; bottom: 82px; min-width: 92px; padding: 11px 16px; border-radius: 15px; } }
@media (prefers-reduced-motion: reduce) { .community-group-float { transition: none; } }
