:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --border: #d8dee8;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-rgb: 37, 99, 235;
  --title: #111827;
  --danger: #dc2626;
  --radius: 12px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 48px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.link-back {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 6px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.link-back:hover {
  background: var(--accent-soft);
  border-color: rgba(37, 99, 235, 0.55);
}

.logo-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  padding: 0 108px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.seal-note {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
}

.kind-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 3px;
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.kind-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 8px 7px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.kind-tab-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.kind-tab-desc {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  opacity: 0.85;
}

.kind-tab.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.18);
}

.kind-tab.is-active .kind-tab-label {
  color: var(--accent-strong);
}

.kind-tab.is-active .kind-tab-desc {
  color: var(--accent);
  opacity: 1;
}

.kind-tab[data-kind="face"].is-active {
  border-color: #7c3aed;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.18);
}

.kind-tab[data-kind="face"].is-active .kind-tab-label,
.kind-tab[data-kind="face"].is-active .kind-tab-desc {
  color: #6d28d9;
}

.upload-panel.kind-palm {
  border-color: rgba(37, 99, 235, 0.28);
}

.upload-panel.kind-face {
  border-color: rgba(124, 58, 237, 0.28);
}

.upload-panel.kind-palm .preview-wrap {
  border-color: rgba(37, 99, 235, 0.4);
}

.upload-panel.kind-face .preview-wrap {
  border-color: rgba(124, 58, 237, 0.4);
}

.upload-panel.kind-face .preview-icon {
  color: #7c3aed;
}

.upload-panel.kind-face .preview-tap-badge {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.25);
}

.upload-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  margin-bottom: 16px;
}

.preview-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface-2);
  border: 2px dashed rgba(37, 99, 235, 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.preview-wrap:hover,
.preview-wrap:focus-visible {
  border-color: rgba(37, 99, 235, 0.65);
  background: #eef4ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.preview-wrap.has-image {
  border-style: solid;
  border-color: rgba(37, 99, 235, 0.28);
  background: var(--surface-2);
}

.preview-wrap.has-image:hover,
.preview-wrap.has-image:focus-visible {
  background: #eef4ff;
}

.preview-img {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  display: block;
}

.preview-placeholder {
  text-align: center;
  padding: 28px 20px;
  color: var(--muted);
}

.preview-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--accent);
}

.kx-icon {
  display: block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

.preview-icon .kx-icon {
  width: 48px;
  height: 48px;
  opacity: 0.9;
}

.preview-tap-badge {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.preview-change-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.upload-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn-upload {
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 12px 10px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.btn-upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

.btn-upload-icon .kx-icon {
  width: 26px;
  height: 26px;
}

.btn-upload-gallery {
  color: var(--accent-strong);
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(180deg, #fff, var(--accent-soft));
}

.btn-upload-camera {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, #fff, #ecfdf5);
}

.btn-upload:hover,
.btn-upload:focus-visible {
  filter: brightness(0.98);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
  outline: none;
}

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

.upload-sheet.hidden {
  display: none !important;
}

.upload-sheet-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.upload-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 18px 16px max(20px, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background: #fff;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
  animation: sheet-up 0.22s ease;
}

.upload-sheet-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.upload-sheet-sub {
  margin: 0 0 16px;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}

.upload-sheet-action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.upload-sheet-action strong {
  display: block;
  font-size: 16px;
  color: var(--text);
}

.upload-sheet-action small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.upload-sheet-action-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-2);
}

.upload-sheet-action-icon .kx-icon {
  width: 24px;
  height: 24px;
}

.upload-sheet-action--gallery {
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.upload-sheet-action--gallery .upload-sheet-action-icon {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.upload-sheet-action--camera {
  border-color: rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, #fff, #f0fdf9);
}

.upload-sheet-action--camera .upload-sheet-action-icon {
  background: #d1fae5;
  color: #0f766e;
}

.upload-sheet-action:hover,
.upload-sheet-action:focus-visible {
  border-color: rgba(37, 99, 235, 0.55);
  outline: none;
}

.upload-sheet-cancel {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

@keyframes sheet-up {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

.btn-secondary {
  flex: 1;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.preview-sub {
  font-size: 12px;
  margin-top: 6px;
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-primary {
  width: 100%;
  margin-top: 4px;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  font-weight: 600;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-panel {
  margin-bottom: 20px;
  scroll-margin-top: 64px;
}

.form-panel .btn-primary {
  scroll-margin-top: 72px;
  scroll-margin-bottom: 24px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field select,
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.field select:focus,
.field input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.result-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  scroll-margin-top: 56px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.result-loading {
  padding: 4px 0 8px;
  color: var(--muted);
}

.result-loading .interp-loading {
  text-align: left;
}

.result-loading .chaozhi-bg-task {
  display: none;
}

.thinking-box {
  margin-bottom: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--surface-2);
}

.thinking-body {
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.result-output {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
  scroll-margin-bottom: 24px;
}

.result-output h2 {
  font-size: 16px;
  color: var(--accent-strong);
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.result-output h2.section-warn {
  color: var(--danger);
  border-bottom-color: rgba(220, 38, 38, 0.25);
}

.result-output.section-warn-wrap {
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: #fef2f2;
}

.result-output p {
  margin: 6px 0;
}

.site-footer {
  text-align: center;
  padding: 20px 16px 32px;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
}

.result-output p.error,
.result-output .error {
  color: var(--danger);
}

.hidden { display: none !important; }

.is-streaming::after {
  content: "▍";
  animation: blink 1s step-end infinite;
  color: var(--accent);
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 480px) {
  .page { padding: 12px 12px 24px; }
  .preview-wrap { min-height: 168px; }
  .preview-placeholder { padding: 20px 14px; }
  .preview-img { max-height: 240px; }
}

/* 照片上传进度（阶段一） */
.upload-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  text-align: center;
}

.upload-progress strong {
  font-size: 0.95rem;
  color: var(--text);
}

/* 标题后动态省略号特效 */
.upload-progress strong.upload-dots::after {
  content: "";
  display: inline-block;
  width: 1.3em;
  text-align: left;
  animation: upload-dots-anim 1.4s steps(1, end) infinite;
}

@keyframes upload-dots-anim {
  0% { content: ""; }
  14% { content: "."; }
  28% { content: ".."; }
  42% { content: "..."; }
  56% { content: "...."; }
  70% { content: "....."; }
  84% { content: "......"; }
  100% { content: "......."; }
}

.upload-bar-wrap {
  width: min(320px, 82%);
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.upload-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.18s ease-out;
}

/* 浏览器/WebView 不提供上传总量时的「不确定进度」动画（避免一直停在 0%） */
.upload-bar-fill.indeterminate {
  width: 34% !important;
  transition: none;
  animation: upload-indeterminate 1.1s ease-in-out infinite;
}
@keyframes upload-indeterminate {
  0%   { transform: translateX(-105%); }
  50%  { transform: translateX(60%); }
  100% { transform: translateX(215%); }
}

.upload-pct {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
