/* AnyQRCode — Apple 风格界面
   浅色为主，自动适配深色模式；白色卡片 + #f5f5f7 底 + 蓝色点缀。 */

:root {
  color-scheme: light dark;
  /* 统一的缓动曲线，接近 iOS 的手感 */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --hairline: rgba(0, 0, 0, 0.1);
  --border: #d2d2d7;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-quiet: #f5f5f7;
  --seg-bg: rgba(120, 120, 128, 0.12);
  --seg-thumb: #ffffff;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --success: #1d8a3d;
  --success-bg: rgba(52, 199, 89, 0.12);
  --warning: #a05a00;
  --warning-bg: rgba(255, 159, 10, 0.14);
  --danger: #d70015;
  --danger-bg: rgba(255, 59, 48, 0.1);
  --nav-bg: rgba(251, 251, 253, 0.82);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.06);
  --shadow-qr: 0 10px 30px rgba(0, 0, 0, 0.1);
  /* 生成设置 / 预览两块面板的固定高度。
     取「配色 + 线性渐变」这一最高页所需的高度——它比别的页多了
     渐变终点和角度滑块两块，中文下实测需要 802px，够它就够所有页。 */
  --panel-h: 802px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --hairline: rgba(255, 255, 255, 0.14);
    --border: #3a3a3c;
    --fill: rgba(120, 120, 128, 0.26);
    --fill-quiet: #2c2c2e;
    --seg-bg: rgba(120, 120, 128, 0.26);
    --seg-thumb: #636366;
    --accent: #0a84ff;
    --accent-hover: #3699ff;
    --success: #30d158;
    --success-bg: rgba(48, 209, 88, 0.16);
    --warning: #ff9f0a;
    --warning-bg: rgba(255, 159, 10, 0.16);
    --danger: #ff453a;
    --danger-bg: rgba(255, 69, 58, 0.16);
    --nav-bg: rgba(22, 22, 23, 0.78);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-qr: 0 10px 30px rgba(0, 0, 0, 0.55);
  }

  /* 黑色 Logo 在深色界面里反白 */
  .brand-logo,
  .footer-logo,
  .logo-option img {
    filter: invert(1);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

/* ------------------------------------------------------------------ 动画 */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes qrIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 只在首屏出现一次，切换选项卡和切语言时不再重播，避免闪烁 */
.hero h1 { animation: rise 0.6s var(--ease-out) both; }
.hero-sub { animation: rise 0.6s var(--ease-out) 0.08s both; }
.preset-bar { animation: rise 0.6s var(--ease-out) 0.14s both; }
.workspace > .card:first-child { animation: rise 0.6s var(--ease-out) 0.2s both; }
.workspace > .card:last-child { animation: rise 0.6s var(--ease-out) 0.26s both; }
.history-panel { animation: rise 0.6s var(--ease-out) 0.32s both; }

/* 关掉动画偏好时全部退化成静态，避免晕眩 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------- 顶部导航 */

.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1140px, 100%);
  height: 48px;
  margin: 0 auto;
  padding: 0 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 26px;
  height: 26px;
  display: block;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-note {
  font-size: 12px;
  color: var(--text-secondary);
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.18s var(--ease);
}

.nav-link:hover {
  opacity: 1;
}

/* 中英切换 */

.lang-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 980px;
  background: var(--seg-bg);
}

.lang-btn {
  min-width: 42px;
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 980px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.2s var(--spring);
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn:active {
  transform: scale(0.94);
}

.lang-btn.is-active {
  color: var(--text);
}

.lang-switch:not(.has-thumb) .lang-btn.is-active {
  background: var(--seg-thumb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

/* --------------------------------------------------- 分段控件的滑块 */

/* 选中态原本直接给当前项加底色，切换时是「跳」过去的。
   改成一块绝对定位的滑块滑动。等宽分组（选项卡、分段控件的 label 都是 flex:1）
   几何全部用 CSS 由容器推导，JS 只写「一共几项 --n、当前第几项 --i」，
   所以缩放、换语言、滚动条出现都不会算错。
   中英切换两个按钮不等宽，才需要 JS 量一次。 */
.tabs,
.segmented,
.lang-switch {
  position: relative;
}

.tabs,
.segmented {
  --seg-pad: 3px;
  --seg-gap: 2px;
}

.seg-thumb {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  background: var(--seg-thumb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  pointer-events: none;
  transition: transform 0.34s var(--ease-out), width 0.34s var(--ease-out),
    height 0.34s var(--ease-out), opacity 0.2s var(--ease);
}

/* 首次定位不要从左上角滑进来 */
.seg-thumb.is-init {
  transition: none;
}

.tabs .seg-thumb,
.segmented .seg-thumb {
  top: var(--seg-pad);
  left: var(--seg-pad);
  height: calc(100% - 2 * var(--seg-pad));
  width: calc((100% - 2 * var(--seg-pad) - (var(--n, 1) - 1) * var(--seg-gap)) / var(--n, 1));
  transform: translateX(calc(var(--i, 0) * (100% + var(--seg-gap))));
}

.tabs .seg-thumb { border-radius: 9px; }
.segmented .seg-thumb { border-radius: 8px; }
.lang-switch .seg-thumb { border-radius: 980px; }

/* 文字压在滑块上面 */
.tabs .tab,
.lang-switch .lang-btn,
.segmented label {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------------ Hero */

.hero {
  padding: 74px 24px 10px;
  text-align: center;
}

.hero h1 {
  max-width: 760px;
  margin: 0 auto;
  font-size: clamp(32px, 4.6vw, 54px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-wrap: balance;
}

.hero-sub {
  max-width: 600px;
  margin: 18px auto 0;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------------ 布局 */

.page {
  padding-bottom: 20px;
}

/* 两块面板高度写死：切换选项卡、切语言都不会跳动。
   内容超出时由内部滚动条消化，而不是把卡片撑高。 */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  gap: 20px;
  height: var(--panel-h);
  width: min(1140px, 100%);
  margin: 20px auto 0;
  padding: 0 22px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  padding: 26px;
}

.workspace > .card {
  overflow: hidden;
}

/* 生成设置：表头和输入框固定，只有当前选项卡内部滚动 */
.builder-panel .tab-panel.is-active {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-right: -10px;
  padding-right: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 128, 0.3) transparent;
}

.builder-panel .tab-panel.is-active::-webkit-scrollbar {
  width: 6px;
}

.builder-panel .tab-panel.is-active::-webkit-scrollbar-track {
  background: transparent;
}

.builder-panel .tab-panel.is-active::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(120, 120, 128, 0.3);
}

/* 预览：二维码框吃掉剩余空间，下面的按钮和信息贴住底部 */
.preview-panel .qr-frame {
  flex: 1;
  min-height: 0;
}

/* 预设条：独立一栏。宽度对齐下面两张卡片的外沿
   （workspace 是 1140 减去左右各 22 的内边距） */
.preset-bar {
  width: min(1096px, calc(100% - 44px));
  margin: 34px auto 0;
  padding: 20px 26px 22px;
}

.preset-bar-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.preset-bar-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.preset-bar-head small {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-panel {
  width: min(1096px, calc(100% - 44px));
  margin: 20px auto 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------ 表单 */

.field-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input-row input,
.text-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-row input:focus,
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14);
}

.helper-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.status-text {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.status-text.error {
  color: var(--danger);
}

.status-text.success {
  color: var(--success);
}

.status-text.warning {
  color: var(--warning);
}

/* ------------------------------------------------------------------ 按钮 */

.primary-btn {
  height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 980px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.18s ease, transform 0.12s ease;
}

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

.primary-btn:active {
  transform: scale(0.98);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.22s var(--ease), transform 0.2s var(--spring), opacity 0.22s var(--ease);
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(120, 120, 128, 0.2);
}

.secondary-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.text-btn {
  border: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.22s var(--ease), transform 0.2s var(--spring);
}

.text-btn:hover:not(:disabled) {
  background: rgba(0, 113, 227, 0.08);
}

.text-btn:active:not(:disabled) {
  transform: scale(0.96);
}

/* ------------------------------------------------------------------ 快捷项 */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 20px;
}

.chip {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 980px;
  background: var(--fill);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.22s var(--ease), transform 0.25s var(--spring);
}

.chip:hover {
  background: rgba(120, 120, 128, 0.2);
  transform: translateY(-1px);
}

.chip:active {
  transform: scale(0.95);
}

/* ------------------------------------------------------------------ 选项卡 */

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-bg);
  margin-bottom: 10px;
}

/* 状态提示在预览区，紧挨着二维码；没内容时不占位 */
.preview-panel > .status-text {
  margin: 14px 0 0;
}

.status-text:empty {
  display: none;
}

.tab {
  flex: 1;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.28s var(--ease), box-shadow 0.28s var(--ease),
    transform 0.2s var(--spring);
}

.tab:active {
  transform: scale(0.96);
}

.tab.is-active {
  font-weight: 600;
}

.tabs:not(.has-thumb) .tab.is-active {
  background: var(--seg-thumb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

/* ------------------------------------------------------------------ 设置组 */

.setting-group {
  padding: 18px 0 14px;
  border-top: 1px solid var(--hairline);
}

.tab-panel > .setting-group:first-child {
  border-top: 0;
  padding-top: 2px;
}

.group-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.group-title span {
  font-size: 14px;
  font-weight: 600;
}

.group-title small {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 预设卡片 */

/* 预设整块铺开，不做横向滚动。列数由 JS 算好写进 --cols，
   保证多行时每行列数一致，不会出现最后一行只剩一个的情况。 */
.preset-gallery,
.preset-row {
  display: grid;
  /* 列宽封顶并整体居中，行数少的时候不会拉成很空的大格子 */
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 148px));
  justify-content: center;
  gap: 10px;
}

.preset-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 6px 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--spring);
}

.preset-card canvas {
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--hairline);
  transition: transform 0.25s var(--spring), box-shadow 0.25s var(--ease);
}

.preset-card span {
  font-size: 12px;
  color: var(--text-secondary);
  transition: color 0.2s var(--ease);
}

.preset-card:hover {
  background: var(--fill-quiet);
}

.preset-card:hover canvas {
  transform: scale(1.07);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

.preset-card:active {
  transform: scale(0.96);
}

.preset-card.is-active {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.06);
}

.preset-card.is-active canvas {
  transform: scale(1.04);
}

.preset-card.is-active span {
  color: var(--accent);
  font-weight: 600;
}

/* 形状选择 */

/* 和预设一样铺开成均分多行，列数由 JS 写进 --cols */
.shape-picker {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: 8px;
}

.shape-option {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 4px 8px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
    color 0.25s var(--ease), transform 0.25s var(--spring);
}

.shape-option svg {
  width: 26px;
  height: 26px;
  display: block;
  transition: transform 0.3s var(--spring);
}

.shape-option span {
  font-size: 11px;
  color: var(--text-secondary);
  transition: color 0.2s var(--ease);
}

.shape-option:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.shape-option:hover svg {
  transform: scale(1.14);
}

.shape-option:active {
  transform: scale(0.95);
}

.shape-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
  color: var(--accent);
}

.shape-option.is-active svg {
  transform: scale(1.1);
}

.shape-option.is-active span {
  color: var(--accent);
  font-weight: 600;
}

/* Logo 选择 */

/* 图标同样全部铺开，列数由 JS 算好，多行时每行个数一致 */
.logo-picker {
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), minmax(0, 54px));
  gap: 8px;
  margin-bottom: 12px;
}

.logo-option {
  width: 100%;
  max-width: 54px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
    color 0.25s var(--ease), transform 0.25s var(--spring);
}

.logo-option svg,
.logo-option img {
  display: block;
  transition: transform 0.3s var(--spring);
}

.logo-option svg {
  width: 22px;
  height: 22px;
}

.logo-option img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.logo-none {
  font-size: 11px;
  color: var(--text-secondary);
}

.logo-option:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.logo-option:hover svg,
.logo-option:hover img {
  transform: scale(1.16);
}

.logo-option:active {
  transform: scale(0.94);
}

.logo-option.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
  color: var(--accent);
}

.logo-option.is-active svg,
.logo-option.is-active img {
  transform: scale(1.1);
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.upload-btn {
  cursor: pointer;
}

/* --------------------------------------------------------- 上传文件 */

.file-drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 22px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--fill-quiet);
  color: var(--text);
  text-align: center;
  transition: border-color 0.22s var(--ease), background 0.22s var(--ease), transform 0.2s var(--spring);
}

.file-drop:hover {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.05);
}

.file-drop:active {
  transform: scale(0.99);
}

.file-drop.is-over {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(0, 113, 227, 0.09);
}

.file-drop.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.05);
}

.file-drop-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.file-drop-icon svg {
  width: 19px;
  height: 19px;
}

.file-drop-icon img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.file-drop-text {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.file-drop-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.upload-config {
  margin-top: 12px;
}

.gh-config {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.upload-warn {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 12px;
  line-height: 1.55;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.upload-actions .primary-btn {
  flex: 1;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.upload-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--fill);
  overflow: hidden;
}

.upload-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.2s var(--ease);
}

.upload-progress span {
  min-width: 68px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}

/* 分段控件（单选） */

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--seg-bg);
}

.segmented label {
  flex: 1;
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.28s var(--ease), box-shadow 0.28s var(--ease),
    color 0.2s var(--ease), transform 0.2s var(--spring);
}

.segmented label:active span {
  transform: scale(0.95);
}

.segmented input:checked + span {
  font-weight: 600;
}

.segmented:not(.has-thumb) input:checked + span {
  background: var(--seg-thumb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.segmented input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.3);
}

/* 颜色 */

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.color-field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-row input {
  width: 38px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.color-row input:disabled {
  opacity: 0.4;
  cursor: default;
}

.color-row span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* 配色预设 */

.swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: 980px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.22s var(--ease), transform 0.25s var(--spring);
}

.swatch:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.swatch:active {
  transform: scale(0.95);
}

.swatch span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fg) 0 50%, var(--bgc) 50% 100%);
  border: 1px solid var(--hairline);
  transition: transform 0.3s var(--spring);
}

.swatch:hover span {
  transform: scale(1.18) rotate(12deg);
}

/* 设置块 */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.setting-block {
  padding: 14px;
  border-radius: 12px;
  background: var(--fill-quiet);
}

.setting-group .setting-block + .setting-block {
  margin-top: 12px;
}

#fgAngleField {
  margin-top: 12px;
}

.setting-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.setting-title label,
.setting-title > span:first-child {
  font-size: 13px;
  font-weight: 600;
}

.setting-title span:last-child {
  font-size: 12px;
  color: var(--text-secondary);
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.check-inline {
  margin-top: 8px;
}

/* ------------------------------------------------------------------ 预览 */

.qr-state {
  padding: 5px 12px;
  border-radius: 980px;
  background: var(--fill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.qr-state.ready {
  background: var(--success-bg);
  color: var(--success);
}

.qr-frame {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 220px;
  padding: 22px;
  border-radius: 16px;
  background: var(--fill-quiet);
  overflow: hidden;
}

#qrContainer {
  display: none;
  max-width: 100%;
  max-height: 100%;
  padding: 14px;
  border-radius: 18px;
  background: var(--qr-bg, #ffffff);
  box-shadow: var(--shadow-qr);
}

#qrContainer.is-transparent {
  background-image: conic-gradient(rgba(120, 120, 128, 0.18) 90deg, transparent 90deg 180deg, rgba(120, 120, 128, 0.18) 180deg 270deg, transparent 270deg);
  background-size: 18px 18px;
}

/* 双重保险：宽高都封顶，object-fit 保证是等比缩小而不是压扁或裁切 */
#qrContainer canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  height: auto !important;
  object-fit: contain;
}

/* 每次重新生成时轻轻弹一下 */
#qrContainer canvas.is-fresh {
  animation: qrIn 0.42s var(--ease-out) both;
}

.qr-caption {
  display: none;
  max-width: 340px;
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  word-break: break-word;
}

.qr-frame.ready #qrContainer {
  display: block;
}

.qr-frame.ready .qr-caption.has-text {
  display: block;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
}

.empty-state strong {
  font-size: 15px;
  font-weight: 600;
}

.empty-state span {
  font-size: 13px;
  color: var(--text-secondary);
}

.qr-frame.ready .empty-state {
  display: none;
}

/* 体检结果 */

.health-list {
  margin-top: 14px;
}

.health-item {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
}

.health-item.ok {
  background: var(--success-bg);
  color: var(--success);
}

.health-item.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.health-item.error {
  background: var(--danger-bg);
  color: var(--danger);
}

/* 操作与信息 */

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--fill-quiet);
}

.result-panel > div {
  min-width: 0;
}

.meta-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.result-link.muted {
  color: var(--text-secondary);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.meta-grid div {
  min-width: 0;
}

.meta-grid dt {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.meta-grid dd {
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 历史 */

.history-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.history-empty {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.history-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  transition: border-color 0.22s var(--ease), transform 0.25s var(--spring),
    box-shadow 0.25s var(--ease);
}

.history-item:hover {
  border-color: var(--border);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.history-item:active {
  transform: scale(0.98);
}

.history-item strong,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  font-size: 13px;
  font-weight: 600;
}

.history-item span {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-footer span {
  font-size: 11px;
}

.mini-swatch {
  flex: none;
  width: 26px;
  height: 16px;
  border-radius: 980px;
  border: 1px solid var(--hairline);
  background: linear-gradient(135deg, var(--fg) 0 50%, var(--bgc) 50% 100%);
}

/* ------------------------------------------------------------------ 页脚 */

.footer {
  padding: 68px 24px 44px;
  text-align: center;
}

.footer-logo {
  width: 138px;
  opacity: 0.88;
}

.footer-note {
  max-width: 460px;
  margin: 20px auto 6px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.footer-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-meta {
  margin: 26px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.85;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 50;
  max-width: min(400px, calc(100vw - 44px));
  padding: 12px 20px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #f5f5f7;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 1040px) {
  /* 单列之后固定高度没有意义，交给内容自己撑开 */
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace > .card {
    overflow: visible;
  }

  .builder-panel .tab-panel.is-active {
    overflow-y: visible;
    margin-right: 0;
    padding-right: 0;
  }

  .preview-panel .qr-frame {
    min-height: 320px;
  }

  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    padding-top: 56px;
  }
}

@media (max-width: 700px) {
  .nav-inner {
    padding: 0 16px;
  }

  .nav-note {
    display: none;
  }

  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .history-panel,
  .preset-bar {
    width: calc(100% - 28px);
  }

  .preset-bar {
    padding: 18px 16px 20px;
  }

  .card {
    padding: 20px;
  }

  .hero h1 {
    font-size: 31px;
  }

  .hero-sub {
    font-size: 15px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .primary-btn {
    width: 100%;
  }

  .settings-grid,
  .color-grid,
  .history-list {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-frame {
    min-height: 330px;
    padding: 18px;
  }

  .result-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}
