:root,
[data-theme='light'] {
  color-scheme: light;
  --bg-canvas: #F4F5F7;
  --bg-surface: #FFFFFF;
  --bg-surface-subtle: #ECEEF2;
  --border-hairline: rgba(17, 19, 24, 0.08);
  --border-strong: rgba(17, 19, 24, 0.16);
  --text-primary: #111318;
  --text-secondary: #5C6370;
  --text-tertiary: #8E95A3;
  --primary-action: #14171F;
  --on-primary-action: #FFFFFF;
  --emerald: #1B9A67;
  --emerald-soft: #E8F7F0;
  --rose: #D93D4D;
  --rose-soft: #FCEEEF;
  --amber: #C97A10;
  --amber-soft: #FDF4E6;
  --stage-dark: #0B0D11;
  --dock-glass: rgba(20, 24, 32, 0.86);
  --dock-border: rgba(255, 255, 255, 0.14);
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg-canvas: #0D0F12;
  --bg-surface: #161920;
  --bg-surface-subtle: #1F242E;
  --border-hairline: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-primary: #F3F5F8;
  --text-secondary: #9AA2B1;
  --text-tertiary: #687080;
  --primary-action: #F3F5F8;
  --on-primary-action: #111318;
  --emerald: #2DC284;
  --emerald-soft: rgba(45, 194, 132, 0.15);
  --rose: #F05A68;
  --rose-soft: rgba(240, 90, 104, 0.15);
  --amber: #F0A43B;
  --amber-soft: rgba(240, 164, 59, 0.15);
  --stage-dark: #0B0D11;
  --dock-glass: rgba(20, 24, 32, 0.86);
  --dock-border: rgba(255, 255, 255, 0.14);
}

@media (prefers-color-scheme: dark) {
  [data-theme='system'] {
    color-scheme: dark;
    --bg-canvas: #0D0F12;
    --bg-surface: #161920;
    --bg-surface-subtle: #1F242E;
    --border-hairline: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text-primary: #F3F5F8;
    --text-secondary: #9AA2B1;
    --text-tertiary: #687080;
    --primary-action: #F3F5F8;
    --on-primary-action: #111318;
    --emerald: #2DC284;
    --emerald-soft: rgba(45, 194, 132, 0.15);
    --rose: #F05A68;
    --rose-soft: rgba(240, 90, 104, 0.15);
    --amber: #F0A43B;
    --amber-soft: rgba(240, 164, 59, 0.15);
  }
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "MiSans", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: "JetBrains Mono", "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  flex-direction: column;
}

.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 22px;
  padding: 16px;
}

.subtle-box {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
}

.btn-primary {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  background: var(--primary-action);
  color: var(--on-primary-action);
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn-primary.emerald {
  background: var(--emerald);
  color: #FFFFFF;
}

.btn-primary.rose {
  background: var(--rose);
  color: #FFFFFF;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-primary:disabled {
  background: var(--bg-surface-subtle);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.btn-soft {
  min-height: 46px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.btn-soft:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-soft.rose {
  color: var(--rose);
  border-color: rgba(217, 61, 77, 0.28);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.25;
}

.status-pill.neutral {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
}

.status-pill.emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.status-pill.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.rose {
  background: var(--rose-soft);
  color: var(--rose);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.text-input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  background: rgba(8, 10, 14, 0.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 26px;
  padding: 22px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

.toast-banner {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--dock-glass);
  border: 1px solid var(--dock-border);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-stage {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  background: var(--stage-dark);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.glass-pill {
  background: var(--dock-glass);
  border: 1px solid var(--dock-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #FFFFFF;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(0.45);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0;
  }
}

.touch-ripple {
  position: fixed;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid #2DC284;
  background: rgba(45, 194, 132, 0.18);
  pointer-events: none;
  z-index: 55;
  animation: ripple 0.42s ease-out forwards;
}

/* 老安卓 WebView 兜底：flex gap 需 Chrome 84+，inset 需 Chrome 87+。
   用 inset 的支持性近似判断 —— 不支持 inset 的浏览器基本也不支持 flex gap，
   此时给按钮内图标补右边距，避免图标与文字贴死。
   （误判窗口仅 Chrome 84~86，影响可忽略；现代浏览器完全不受影响。） */
@supports not (inset: 0) {
  .btn-primary > svg {
    margin-right: 8px;
  }
  .btn-soft > svg {
    margin-right: 7px;
  }
  .status-pill > svg {
    margin-right: 6px;
  }
}
