/* StraitAPI 用户调研 — Apple 玻璃 + 设置风层次 */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --bg: #f5f5f7;
  --card: rgba(255, 255, 255, 0.78);
  --card-border: rgba(0, 0, 0, 0.06);
  --hairline: rgba(60, 60, 67, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 24px rgba(0, 0, 0, 0.04);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #0071e3;
  --accent-active: #0062c4;
  --accent-ring: rgba(0, 113, 227, 0.3);
  --on-accent: #ffffff;
  --fill: rgba(118, 118, 128, 0.09);
  --fill-hover: rgba(118, 118, 128, 0.14);
  --fill-active: rgba(118, 118, 128, 0.2);
  --field: #ffffff;
  --field-border: rgba(0, 0, 0, 0.12);
  --danger: #d70015;
  --danger-ring: rgba(215, 0, 21, 0.2);
  --topbar: rgba(245, 245, 247, 0.74);
  --toast-bg: rgba(29, 29, 31, 0.9);
  --toast-text: #ffffff;
  --scrim: rgba(0, 0, 0, 0.32);
  --gold: #c49a2c;
  --gold-text: #9a7414;

  --tg-head: rgba(255, 255, 255, 0.9);
  --tg-chat: #dde6ee;
  --tg-bubble: #ffffff;
  --tg-time: #8b9aa7;
  --tg-key: rgba(48, 66, 86, 0.58);
  --tg-key-active: rgba(48, 66, 86, 0.72);
  --tg-key-text: #ffffff;
  --sheet-shadow: 0 -10px 40px rgba(0, 0, 0, 0.14);

  --radius-card: 18px;
  --radius-ctl: 12px;
  --page-max: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: rgba(28, 28, 30, 0.8);
    --card-border: rgba(255, 255, 255, 0.08);
    --hairline: rgba(255, 255, 255, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8d8d93;
    --accent: #0071e3;
    --accent-active: #0a84ff;
    --accent-ring: rgba(10, 132, 255, 0.45);
    --fill: rgba(118, 118, 128, 0.2);
    --fill-hover: rgba(118, 118, 128, 0.26);
    --fill-active: rgba(118, 118, 128, 0.34);
    --field: rgba(118, 118, 128, 0.14);
    --field-border: rgba(255, 255, 255, 0.12);
    --danger: #ff453a;
    --danger-ring: rgba(255, 69, 58, 0.3);
    --topbar: rgba(22, 22, 23, 0.72);
    --toast-bg: rgba(58, 58, 60, 0.95);
    --scrim: rgba(0, 0, 0, 0.56);
    --gold-text: #e0b84a;

    --tg-head: rgba(23, 33, 43, 0.94);
    --tg-chat: #0e1621;
    --tg-bubble: #182533;
    --tg-time: #6d8299;
    --tg-key: rgba(255, 255, 255, 0.1);
    --tg-key-active: rgba(255, 255, 255, 0.18);
    --sheet-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

html.modal-open,
html.modal-open body {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

/* ---------- 顶栏 + 进度条 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--topbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--page-max);
  height: 52px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar-logo {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-count {
  flex: none;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s ease;
}

/* ---------- 页面 ---------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.card + .card,
.card + .survey,
.survey .card + .card {
  margin-top: 16px;
}

@media (min-width: 480px) {
  .card {
    padding: 22px 22px;
  }
}

.intro-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
}

.intro-deadline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.icon-clock {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notice p {
  margin: 0;
  text-align: center;
  color: var(--text-2);
}

/* ---------- 问卷 ---------- */

.survey-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.section-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-2);
}

.q {
  padding: 18px 0;
  border-top: 1px solid var(--hairline);
  scroll-margin-top: 76px;
}

.q:last-child {
  padding-bottom: 4px;
}

.section-title + .q {
  margin-top: 12px;
}

.q-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  transition: color 0.2s ease;
}

.q-num {
  margin-right: 6px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.q-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  vertical-align: 1px;
  white-space: nowrap;
}

.q-hint {
  margin: 4px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}

.q-error .q-title {
  color: var(--danger);
}

/* 单选：设置风列表行 */

.opts {
  margin-top: 12px;
}

.opts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt {
  border: 0;
  border-radius: var(--radius-ctl);
  background: var(--fill);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 15.5px;
  line-height: 1.4;
}

.opt-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.35;
}

.opt-ind,
.opt-box {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--text-3);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.opt-ind {
  border-radius: 50%;
}

.opt-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.opt[aria-checked="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.opt[aria-checked="true"] .opt-ind,
.opt[aria-checked="true"] .opt-box {
  border-color: var(--on-accent);
}

.opt[aria-checked="true"] .opt-ind::after {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: var(--on-accent);
}

.opt[aria-checked="true"] .opt-box::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.opt[aria-disabled="true"] {
  opacity: 0.42;
}

.opt:active {
  background: var(--fill-active);
}

.opt[aria-checked="true"]:active {
  background: var(--accent-active);
}

@media (hover: hover) {
  .opt:hover {
    background: var(--fill-hover);
  }
  .opt[aria-checked="true"]:hover {
    background: var(--accent-active);
  }
}

.opts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 文本 */

.field {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-ctl);
  background: var(--field);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field::placeholder {
  color: var(--text-3);
}

.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.q-error .field,
.q-error .field:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-ring);
}

textarea.field {
  min-height: 108px;
  resize: none;
  overflow: hidden;
}

.counter {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 防机器人字段 */

.hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* 提交按钮 */

.btn-primary {
  display: block;
  width: 100%;
  min-height: 50px;
  margin-top: 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn-primary:active {
  background: var(--accent-active);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--accent-active);
  }
}

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

.survey-fields:disabled .opt,
.survey-fields:disabled .field {
  cursor: default;
}

/* ---------- 轻提示 ---------- */

.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 100;
  width: -webkit-max-content;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast:empty {
  display: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

/* ---------- 提交成功：Telegram 机器人消息 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.overlay.open .overlay-scrim {
  opacity: 1;
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  background: var(--tg-chat);
  box-shadow: var(--sheet-shadow);
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1);
  outline: none;
}

.overlay.open .sheet {
  transform: none;
}

@media (min-width: 641px) {
  .overlay {
    align-items: center;
    padding: 24px;
  }
  .sheet {
    border-radius: 20px;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.24s ease;
  }
  .overlay.open .sheet {
    opacity: 1;
    transform: none;
  }
}

.tg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 10px 6px 10px 14px;
  background: var(--tg-head);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.tg-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 1px;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.tg-avatar img {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.tg-avatar.spin img {
  animation: coin-flip 0.9s cubic-bezier(0.35, 0.1, 0.25, 1);
}

@keyframes coin-flip {
  0% {
    transform: perspective(240px) rotateY(0deg) scale(1);
  }
  50% {
    transform: perspective(240px) rotateY(180deg) scale(1.08);
  }
  100% {
    transform: perspective(240px) rotateY(360deg) scale(1);
  }
}

.tg-meta {
  flex: 1;
  min-width: 0;
}

.tg-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.tg-sub {
  font-size: 13px;
  line-height: 1.3;
  color: var(--text-2);
}

.tg-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}

.tg-close svg {
  width: 30px;
  height: 30px;
  padding: 8px;
  border-radius: 50%;
  background: var(--fill);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.tg-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px calc(20px + env(safe-area-inset-bottom)) 18px;
}

.tg-msg {
  display: flex;
  flex-direction: column;
  max-width: min(92%, 380px);
}

.tg-bubble {
  position: relative;
  padding: 8px 12px 6px;
  border-radius: 18px 18px 18px 6px;
  background: var(--tg-bubble);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.tg-bubble p {
  margin: 0;
}

.tg-strong {
  font-weight: 700;
}

.tg-time {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--tg-time);
  text-align: right;
}

.tg-tail {
  border-bottom-left-radius: 4px;
}

.tg-tail::before,
.tg-tail::after {
  content: "";
  position: absolute;
  bottom: 0;
  height: 14px;
}

.tg-tail::before {
  left: -7px;
  width: 14px;
  background: var(--tg-bubble);
  border-bottom-right-radius: 14px 12px;
}

.tg-tail::after {
  left: -14px;
  width: 14px;
  background: var(--tg-chat);
  border-bottom-right-radius: 10px;
}

.tg-keyboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 4px;
}

.tg-keyboard.kb-3 .tg-key[data-link="balance"] {
  grid-column: 1 / -1;
}

.tg-key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  background: var(--tg-key);
  color: var(--tg-key-text);
  font-size: 14.5px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: background-color 0.15s ease;
}

.tg-key::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  opacity: 0.75;
}

.tg-key:active {
  background: var(--tg-key-active);
}

@media (hover: hover) {
  .tg-key:hover {
    background: var(--tg-key-active);
  }
}

.tg-egg {
  margin-left: 0;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: left bottom;
  transition: opacity 0.32s ease, transform 0.36s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.tg-egg.show {
  opacity: 1;
  transform: none;
}

.tg-bubble-sm {
  padding: 7px 11px 5px;
  font-size: 14px;
  line-height: 1.5;
}

.egg-tag {
  color: var(--gold-text);
  font-weight: 700;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

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