:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172033;
  background: #f5f7fb;
  --ink: #172033;
  --muted: #6b778c;
  --faint: #8b96a8;
  --line: #dce3ec;
  --line-strong: #c7d1de;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --blue: #2563eb;
  --blue-dark: #1e4fd0;
  --teal: #0f766e;
  --green: #087f5b;
  --red: #b42318;
  --amber: #a15c00;
  --shadow: 0 10px 28px rgba(23, 32, 51, .055);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f5f7fb; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1220px, calc(100% - 44px)); margin: 0 auto; padding: 38px 0 56px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.brand-lockup { display: flex; align-items: flex-start; gap: 14px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; margin-top: 3px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 22px; font-weight: 500; }
.eyebrow { margin: 0 0 8px; color: #738096; font-size: 11px; font-weight: 700; letter-spacing: .16em; }
h1, h2, p { margin: 0; }
h1 { color: var(--ink); font-size: clamp(25px, 3vw, 32px); font-weight: 700; letter-spacing: 0; line-height: 1.2; }
.topbar-copy { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.session-status { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: #536176; font-size: 12px; white-space: nowrap; }
.status-indicator, .summary-dot { width: 8px; height: 8px; border-radius: 50%; background: #a4afbf; }
.session-status.connected .status-indicator { background: var(--green); box-shadow: 0 0 0 3px #d9f4e8; }
.session-status.connected { border-color: #b7e5d0; color: var(--green); }
.session-status.partial .status-indicator { background: #c47a12; box-shadow: 0 0 0 3px #fff0d5; }
.session-status.partial { border-color: #ead3a8; color: var(--amber); }
.session-status.error .status-indicator { background: var(--red); box-shadow: 0 0 0 3px #fde3e0; }
.session-status.error { border-color: #f2c3bd; color: var(--red); }
.access-status { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 11px; border: 1px solid #cfe0ff; border-radius: 999px; background: #f4f7ff; color: #355da3; font-size: 12px; white-space: nowrap; }
.access-status[hidden], .access-change[hidden], .access-cancel[hidden] { display: none; }
.access-status strong { color: #244b96; font-size: 12px; font-weight: 700; }
.access-status.exhausted { border-color: #f2c3bd; background: #fff5f4; color: var(--red); }
.access-status.exhausted strong { color: var(--red); }
.access-change { min-height: 34px; padding: 0 11px; font-size: 12px; }

.progress-rail { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 3px 12px rgba(23, 32, 51, .025); }
.progress-step { display: grid; grid-template-columns: 28px auto; column-gap: 9px; min-width: 145px; align-items: center; color: var(--faint); }
.progress-step span { grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 50%; color: #68758a; font-size: 11px; font-weight: 700; }
.progress-step strong { color: #637087; font-size: 13px; font-weight: 650; line-height: 1.2; }
.progress-step small { margin-top: 3px; color: var(--faint); font-size: 11px; }
.progress-step.active span { border-color: var(--blue); background: var(--blue); color: #fff; }
.progress-step.active strong { color: var(--ink); }
.progress-step.complete span { border-color: #8acdb2; background: #effaf5; color: var(--green); }
.progress-step.complete strong { color: var(--green); }
.progress-line { flex: 1; height: 1px; background: var(--line); }

.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.migration-panel { margin-top: 18px; }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.step { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; }
.heading-copy { min-width: 0; flex: 1; }
.heading-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
h2 { color: var(--ink); font-size: 18px; font-weight: 700; line-height: 1.3; }
.heading-copy p { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.state-label { padding: 3px 7px; border: 1px solid #cfe0ff; border-radius: 4px; background: #f2f6ff; color: #2856a8; font-size: 11px; font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 12px; align-items: end; }
.field { display: grid; min-width: 0; gap: 7px; color: #46546a; font-size: 12px; font-weight: 600; }
.field-wide { grid-column: 1 / -1; }
.field small { margin-top: -1px; color: var(--faint); font-size: 11px; font-weight: 400; line-height: 1.35; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px; outline: none; background: #fff; color: var(--ink); font-size: 14px; font-weight: 400; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
input::placeholder { color: #a1aabb; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input:disabled, select:disabled { background: #f5f7fa; color: #9aa5b5; cursor: not-allowed; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 650; white-space: nowrap; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .08s ease; }
.button span { font-size: 16px; font-weight: 400; line-height: 1; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:focus-visible { outline: 3px solid rgba(37, 99, 235, .2); outline-offset: 2px; }
.button:disabled { opacity: .52; cursor: not-allowed; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(37, 99, 235, .15); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { border-color: var(--line-strong); background: #fff; color: #35435a; }
.button.secondary:hover:not(:disabled) { border-color: #95a6bd; background: #f8fafc; }
.action-button { width: 100%; }

.target-picker { margin-top: 22px; padding-top: 18px; border-top: 1px solid #e8edf3; }
.picker-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.picker-title, .choice-label { color: var(--ink); font-size: 13px; font-weight: 700; }
.picker-note { color: var(--faint); font-size: 11px; }
.picker-row { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto minmax(145px, 1.3fr); gap: 9px; align-items: end; }
.inline-field { gap: 6px; }
.inline-field span { color: var(--faint); font-size: 11px; font-weight: 500; }
.manual-entry { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--faint); font-size: 11px; }
.manual-entry::before { content: ""; flex: 1; height: 1px; background: #e8edf3; }
.manual-entry span { white-space: nowrap; }
.manual-id { width: 145px; }
.manual-id input { min-height: 36px; font-size: 13px; }

.migration-layout { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(300px, 1.35fr); gap: 18px 24px; align-items: end; }
.source-store-field { max-width: 420px; }
.data-choice { min-width: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 7px; }
.choice-card { display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink); cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.choice-card:hover { border-color: #9fb0c6; background: #fff; }
.choice-card:has(input:checked) { border-color: #9ab8f5; background: #f3f7ff; }
.choice-card input { width: 17px; min-height: 17px; accent-color: var(--blue); }
.choice-card span { display: grid; gap: 3px; min-width: 0; }
.choice-card strong { font-size: 13px; font-weight: 700; }
.choice-card small { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.choice-upcoming { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.selection-summary { display: flex; align-items: center; gap: 8px; grid-column: 1 / 2; min-height: 36px; color: var(--muted); font-size: 12px; }
.summary-dot { flex: none; }
.selection-summary.ready { color: var(--green); }
.selection-summary.ready .summary-dot { background: var(--green); box-shadow: 0 0 0 3px #d9f4e8; }
.migration-actions { display: flex; justify-content: flex-end; gap: 9px; grid-column: 2 / 3; }
.migration-actions .button { min-width: 118px; }
.agreement-row { display: flex; align-items: center; gap: 5px; grid-column: 1 / -1; padding-top: 13px; border-top: 1px solid #e8edf3; color: var(--muted); font-size: 12px; }
.agreement-check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.agreement-check input { width: 16px; min-height: 16px; accent-color: var(--blue); }
.agreement-link { padding: 3px 2px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.agreement-link:focus-visible { outline: 3px solid rgba(37, 99, 235, .2); outline-offset: 2px; }
.result { min-height: 36px; margin-top: 15px; padding: 9px 11px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.result:empty { min-height: 0; margin-top: 0; padding: 0; }
.result.success { border-color: #b7e5d0; background: #f1fbf6; color: var(--green); }
.result.error { border-color: #f2c3bd; background: #fff5f4; color: var(--red); }
.result.info { border-color: #cfe0ff; background: #f4f7ff; color: #355da3; }
.footer-note { margin-top: 18px; color: #8792a5; font-size: 11px; line-height: 1.5; text-align: center; }
.confirm-dialog { width: min(420px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(23, 32, 51, .22); }
.confirm-dialog::backdrop { background: rgba(23, 32, 51, .38); }
.confirm-dialog h3 { margin: 5px 0 8px; font-size: 19px; }
.confirm-dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-kicker { color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.access-dialog { width: min(440px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(23, 32, 51, .22); }
.access-dialog::backdrop { background: rgba(23, 32, 51, .48); }
.access-dialog h2 { margin: 5px 0 9px; font-size: 21px; }
.access-dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.access-form { display: grid; gap: 16px; }
.access-code-field { margin-top: 4px; }
.access-submit { width: 100%; }
.access-cancel { width: 100%; }
.access-form .result { margin-top: -5px; }
.access-form .result:empty { display: none; }
.usage-dialog { width: min(520px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(23, 32, 51, .22); }
.usage-dialog::backdrop { background: rgba(23, 32, 51, .42); }
.usage-dialog h2 { margin: 5px 0 14px; font-size: 21px; }
.usage-dialog p { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.usage-countdown { margin-top: 20px; padding: 10px 12px; border: 1px solid #dbe6fb; border-radius: 6px; background: #f5f8ff; color: #42619b; font-size: 12px; line-height: 1.45; }
.usage-close { width: 100%; margin-top: 12px; }
.privacy-dialog { width: min(620px, calc(100% - 32px)); max-height: min(780px, calc(100% - 32px)); padding: 26px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(23, 32, 51, .22); }
.privacy-dialog::backdrop { background: rgba(23, 32, 51, .46); }
.privacy-dialog h3 { margin: 5px 0 14px; font-size: 20px; }
.privacy-copy { display: grid; gap: 10px; }
.privacy-copy p { color: #4f5d72; font-size: 13px; line-height: 1.7; }
.privacy-countdown { margin-top: 18px; padding: 10px 12px; border: 1px solid #dbe6fb; border-radius: 6px; background: #f5f8ff; color: #42619b; font-size: 12px; line-height: 1.45; }
.usage-help { position: fixed; right: 22px; bottom: 22px; z-index: 10; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #b8c9e6; border-radius: 50%; background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(37, 99, 235, .25); cursor: pointer; font-size: 20px; font-weight: 700; line-height: 1; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.usage-help:hover { background: var(--blue-dark); box-shadow: 0 10px 24px rgba(37, 99, 235, .3); transform: translateY(-2px); }
.usage-help:focus-visible { outline: 3px solid rgba(37, 99, 235, .24); outline-offset: 3px; }

@media (max-width: 1040px) {
  .setup-grid { grid-template-columns: 1fr; }
  .setup-panel .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .setup-panel .field-wide { grid-column: span 2; }
  .setup-panel .action-button { width: 100%; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 620px); padding: 24px 0 40px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 20px; }
  .session-status { align-self: flex-start; }
  .topbar-actions { justify-content: flex-start; }
  .progress-rail { gap: 7px; padding: 12px; }
  .progress-step { min-width: 0; grid-template-columns: 25px auto; column-gap: 7px; }
  .progress-step span { width: 25px; height: 25px; }
  .progress-step strong { font-size: 11px; }
  .progress-step small, .progress-line { display: none; }
  .progress-rail { justify-content: space-between; }
  .panel { padding: 19px 16px; }
  .setup-panel .form-grid, .form-grid { grid-template-columns: 1fr; }
  .setup-panel .field-wide, .field-wide { grid-column: auto; }
  .picker-row, .migration-layout { grid-template-columns: 1fr; }
  .picker-row .button, .inline-field, .store-field, .source-store-field { width: 100%; max-width: none; }
  .manual-entry { align-items: stretch; flex-direction: column; gap: 7px; }
  .manual-entry::before { display: none; }
  .manual-entry span { align-self: flex-start; }
  .manual-id { width: 100%; }
  .choice-grid { grid-template-columns: 1fr; }
  .choice-card small { white-space: normal; }
  .selection-summary, .migration-actions { grid-column: auto; }
  .migration-actions { justify-content: stretch; flex-direction: column; }
  .migration-actions .button { width: 100%; }
  .usage-help { right: 16px; bottom: 16px; }
}
