/* ===========================================================
   HairAI+ · 设计系统
   移动优先的手机端美发体验，桌面端沿用同一套品牌语言。
   =========================================================== */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e9e9ee;
  --line: rgba(15, 15, 22, 0.08);
  --line-strong: rgba(15, 15, 22, 0.16);
  --text: #0d0d12;
  --text-2: #6b6b76;
  --text-3: #9b9ba5;
  --on-dark: #ffffff;
  --accent: #6c5ce7;
  --accent-soft: rgba(108, 92, 231, 0.1);
  --accent-grad: linear-gradient(135deg, #7a5cff 0%, #3d7dff 100%);
  --ok: #16a34a;
  --danger: #e5484d;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 15, 25, 0.06);
  --shadow: 0 12px 32px rgba(15, 15, 25, 0.1);
  --shadow-lg: 0 24px 64px rgba(15, 15, 25, 0.18);
  --bar-h: 60px;
  --nav-h: 66px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.dark {
  --bg: #0b0b0f;
  --surface: #14141a;
  --surface-2: #1c1c23;
  --surface-3: #26262f;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f5f5f7;
  --text-2: #a1a1ad;
  --text-3: #74747f;
  --accent-soft: rgba(122, 92, 255, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
sup { font-size: 0.55em; top: -0.7em; }

body.no-icons [data-lucide] { display: none; }

/* 任何组件显式设置了 display 时，hidden 属性仍必须生效 */
[hidden] { display: none !important; }

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

.app { min-height: 100vh; display: flex; flex-direction: column; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 20px calc(var(--nav-h) + 40px);
}

.page { animation: page-in 0.24s ease both; }
.page[hidden] { display: none; }

/* 只做透明度过渡：给 .page 加 transform 会让页面成为 position:fixed 的包含块，
   底部常驻的生成按钮就会改成相对页面定位，滚动时被底栏压住或跑出视口。 */
@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0 0 8px -6px;
  padding: 6px 10px 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
}
.page-back:hover { background: var(--surface-2); color: var(--text); }
.page-back svg { width: 18px; height: 18px; }

.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 26px; line-height: 1.2; }
.page-head p { margin-top: 8px; color: var(--text-2); font-size: 13.5px; }
.page-head strong { color: var(--text); }

/* ------------------------------ 顶栏 ------------------------------ */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--bar-h);
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
body.dark .app-bar { background: rgba(11, 11, 15, 0.86); }

.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text small { color: var(--text-3); font-size: 11.5px; }

.top-nav { display: none; }

.app-bar__actions { display: inline-flex; align-items: center; gap: 8px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status-chip .dot.is-connected { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16); }

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-2);
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button svg { width: 18px; height: 18px; }

/* ------------------------------ 首页 ------------------------------ */

.home { display: grid; gap: 20px; }

.hero {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.hero img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 26%; }
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 130px;
  background: linear-gradient(180deg, rgba(8, 8, 12, 0) 0%, rgba(8, 8, 12, 0.3) 100%);
  pointer-events: none;
}

.hero-top {
  position: absolute;
  inset: 12px 12px auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hero-tag,
.hero-change {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(12, 12, 16, 0.42);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.hero-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; }
.hero-change:hover { background: rgba(12, 12, 16, 0.62); }
.hero-change svg { width: 15px; height: 15px; }

/* 首屏入口上提，压在首图下缘，与参考稿的层级一致 */
.home-panel { display: grid; gap: 14px; margin-top: -34px; }
.home-lead { color: var(--text-2); font-size: 13px; }

.entry-list { display: grid; gap: 10px; }

.entry {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.entry:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.entry:active { transform: scale(0.99); }

.entry-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}
.entry-icon svg { width: 20px; height: 20px; }

.entry-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.entry-copy strong { font-size: 15.5px; font-weight: 600; }
.entry-copy small { color: var(--text-2); font-size: 12.5px; }

.entry-arrow { flex: none; width: 18px; height: 18px; color: var(--text-3); }

.entry--primary { background: var(--text); border-color: transparent; color: var(--on-dark); }
.entry--primary .entry-copy small { color: rgba(255, 255, 255, 0.66); }
.entry--primary .entry-icon { background: rgba(255, 255, 255, 0.14); color: #fff; }
.entry--primary .entry-arrow { color: rgba(255, 255, 255, 0.6); }

.home-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.home-hint { color: var(--text-3); font-size: 12.5px; }

/* ------------------------------ 通用按钮 ------------------------------ */

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--accent-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(93, 96, 255, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(93, 96, 255, 0.34); }
.primary-button:active { transform: scale(0.99); }
.primary-button:disabled { opacity: 0.6; transform: none; box-shadow: none; cursor: default; }
.primary-button svg { width: 18px; height: 18px; }
.primary-button--block { width: 100%; }

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
}
.secondary-button:hover { background: var(--surface-2); }
.secondary-button svg { width: 18px; height: 18px; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.ghost-button:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------ 发型库 ------------------------------ */

/* 发型类别切换（女生 / 男生） */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.segmented button {
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease;
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: flex;
  gap: 8px;
  margin: 0 -20px 16px;
  padding: 2px 20px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}.filter-row::-webkit-scrollbar { display: none; }

.filter-row button {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.filter-row button.is-active { background: var(--text); color: var(--on-dark); }

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

.style-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  text-align: center;
  background: none;
}
.style-card__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 2px solid transparent;
  overflow: hidden;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.style-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
}
/* 素材缺失时的占位：干净的中性块，不放任何假人像 */
.style-card__placeholder {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface-3) 100%);
  color: var(--text-3);
}
.style-card__placeholder svg { width: 26px; height: 26px; opacity: 0.5; }
.style-card.is-placeholder .style-card__placeholder { display: grid; }

.style-card:hover .style-card__media { transform: translateY(-2px); }
.style-card.is-selected .style-card__media { border-color: var(--accent); }
.style-card__name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.style-card.is-selected .style-card__name { color: var(--accent); font-weight: 600; }
.style-card em { display: none; }

.generate-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  z-index: 25;
  display: grid;
  gap: 8px;
  padding: 12px 20px 14px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
}
/* 常驻生成栏不能被最后一排发型遮住 */
#stylesPage { padding-bottom: 108px; }
body.dark .generate-dock { background: rgba(11, 11, 15, 0.9); }
.generate-dock__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.generate-dock__label { color: var(--text-2); font-size: 12.5px; }
.generate-dock__label strong { color: var(--text); }

/* 常驻生成栏里的迷你背景切换 */
.segmented--mini { margin: 0; padding: 3px; gap: 3px; grid-template-columns: auto auto; background: var(--surface-2); }
.segmented--mini button { height: 26px; padding: 0 11px; font-size: 12px; border-radius: 8px; }

/* ------------------------------ 文字描述 ------------------------------ */

.field-label { display: block; margin-bottom: 8px; color: var(--text-2); font-size: 13px; font-weight: 600; }

textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  resize: vertical;
}
textarea::placeholder { color: var(--text-3); }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--text-3);
  font-size: 12px;
}

.quick-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.quick-prompts button {
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
}
.quick-prompts button:hover { border-color: var(--accent); color: var(--accent); }

.preference-row { display: grid; gap: 10px; margin-bottom: 20px; }
.preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.preference input { position: absolute; opacity: 0; pointer-events: none; }
.preference i {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.18s ease;
}
.preference i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 0.18s ease;
}
.preference input:checked + i { background: var(--accent); }
.preference input:checked + i::after { transform: translateX(18px); }
.preference input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

.generate-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--text-3);
  font-size: 12px;
}
.generate-note svg { width: 14px; height: 14px; }

/* ------------------------------ 作品 ------------------------------ */

.empty-studio {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 20px 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
}
.empty-studio h2 { font-size: 17px; }
.empty-studio p { color: var(--text-2); font-size: 13.5px; max-width: 24em; }
.empty-studio .primary-button { margin-top: 6px; }

.studio-stack { position: relative; width: 132px; height: 168px; margin-bottom: 6px; }
.studio-stack img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  border-radius: var(--radius);
  border: 2px solid var(--bg);
  box-shadow: var(--shadow-sm);
}
.studio-stack img:first-child { transform: rotate(-7deg) translateX(-16px); opacity: 0.85; }
.studio-stack img:last-child { transform: rotate(4deg) translateX(14px); }

.works-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.works-grid[hidden] { display: none; }
.work-card { position: relative; text-align: left; background: none; }
.work-card__open { display: block; width: 100%; padding: 0; border: 0; background: none; }
.work-card__open img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: 50% 22%;
  border-radius: var(--radius);
  background: var(--surface-2);
}
/* 作品默认保存，也允许随时删掉 */
.work-card__delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(12, 12, 16, 0.5);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}
.work-card__delete:hover { background: rgba(12, 12, 16, 0.78); }
.work-card strong { display: block; margin-top: 8px; font-size: 13.5px; font-weight: 600; }
.work-card small { color: var(--text-3); font-size: 11.5px; }

/* ------------------------------ 我的 ------------------------------ */

.salon-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: var(--text);
  color: var(--on-dark);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 17px;
  font-weight: 700;
}
.salon-copy { display: flex; flex-direction: column; gap: 3px; }
.salon-copy strong { font-size: 16px; }
.salon-copy small { color: rgba(255, 255, 255, 0.66); font-size: 12.5px; }

.list-group {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 18px;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
}
.list-icon svg { width: 18px; height: 18px; }
.list-copy { display: flex; flex-direction: column; gap: 2px; margin-right: auto; min-width: 0; }
.list-copy strong { font-size: 14.5px; font-weight: 600; }
.list-copy small { color: var(--text-2); font-size: 12.5px; }

.switch-dot {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.18s ease;
}
.switch-dot::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 0.18s ease;
}
body.dark .switch-dot { background: var(--accent); }
body.dark .switch-dot::after { transform: translateX(16px); }

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}
.security-note svg { flex: none; width: 14px; height: 14px; margin-top: 2px; }

/* ------------------------------ API 接入 ------------------------------ */

.provider-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.provider-link:hover { border-color: var(--accent); }
.provider-link__main { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.provider-link__main svg { width: 18px; height: 18px; color: var(--accent); }
.provider-link small { color: var(--text-3); font-size: 12px; }

.connection-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.connection-state > div { display: flex; flex-direction: column; gap: 2px; }
.connection-state strong { font-size: 14.5px; }
.connection-state small { color: var(--text-2); font-size: 12.5px; }
.connection-indicator {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-3);
}
.connection-state.is-connected { background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.28); }
.connection-state.is-connected .connection-indicator { background: var(--ok); box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16); }

.key-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.key-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.key-input-wrap input {
  flex: 1;
  min-width: 0;
  height: 50px;
  border: 0;
  background: none;
  font-size: 14.5px;
  letter-spacing: 0.02em;
}
.key-input-wrap input:focus { outline: none; }
.key-input-wrap button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); color: var(--text-3); }
.key-input-wrap button:hover { background: var(--surface-2); color: var(--text); }
.key-input-wrap svg { width: 18px; height: 18px; }

.text-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.text-input::placeholder { color: var(--text-3); }

.api-readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.api-readonly-grid > div {
  min-width: 0;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.api-readonly-grid span { display: block; color: var(--text-3); font-size: 11.5px; }
.api-readonly-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#connectPage .preference { margin-bottom: 16px; }
#disconnectApi { margin-top: 10px; width: 100%; justify-content: center; color: var(--danger); }
#disconnectApi:hover { background: rgba(229, 72, 77, 0.08); }

/* ------------------------------ 发色 ------------------------------ */

.color-picker { margin-bottom: 16px; }
.color-picker__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 12.5px;
}
.color-picker__head strong { color: var(--text); font-size: 13px; }

.color-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 -20px;
  padding: 2px 20px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.color-row::-webkit-scrollbar { display: none; }

.color-row .swatch {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.color-row .swatch:hover { transform: translateY(-1px); }
.color-row .swatch.is-active { border-color: var(--accent); }
.color-row .swatch--keep {
  width: auto;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: none;
}
.color-row .swatch--keep.is-active { background: var(--text); color: var(--on-dark); border-color: transparent; }

/* ------------------------------ 开通引导 ------------------------------ */

.onboard {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.onboard__step {
  display: flex;
  gap: 12px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.onboard__index {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 700;
}
.onboard__body { display: grid; gap: 4px; min-width: 0; }
.onboard__body strong { font-size: 14.5px; font-weight: 600; }
.onboard__body small { color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.onboard__body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 12px;
}
.onboard__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.onboard__actions .secondary-button { min-height: 38px; font-size: 13.5px; padding: 0 14px; }
.onboard__actions .ghost-button { border: 1px solid var(--line); }

.advanced {
  margin: 4px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.advanced summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 600; }
.advanced summary::marker { color: var(--text-3); }
.advanced[open] summary { margin-bottom: 12px; }
.advanced .field-label:first-of-type { margin-top: 0; }

/* ------------------------------ 套壳窗口 ------------------------------ */

.shell {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.shell[hidden] { display: none; }
.shell__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.shell__bar strong { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell iframe { flex: 1; width: 100%; border: 0; background: var(--surface-2); }
.shell__note {
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
}

/* ------------------------------ 手机访问提示 ------------------------------ */

.lan-card {
  display: grid;
  gap: 8px;
  padding: 15px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.lan-card__head { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.lan-card__head svg { width: 18px; height: 18px; color: var(--accent); }
.lan-card p { color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.lan-card__url { display: flex; align-items: center; gap: 8px; }
.lan-card__url code {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------ 底部导航 ------------------------------ */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
body.dark .bottom-nav { background: rgba(11, 11, 15, 0.9); }

.bottom-nav button {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 9px 0 7px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
}
.bottom-nav svg { width: 21px; height: 21px; }
.bottom-nav button.is-active { color: var(--accent); }

/* ------------------------------ 生成结果 ------------------------------ */

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}
.result-modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 8, 12, 0.55); backdrop-filter: blur(3px); }

.result-sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--bg);
  overflow-y: auto;
  animation: sheet-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes sheet-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { font-size: 19px; }
.sheet-step { display: block; color: var(--text-3); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; }
.sheet-spacer { width: 34px; }

.generating-state { display: grid; gap: 14px; justify-items: center; text-align: center; }
.generating-state[hidden] { display: none; }
.generating-state > p { color: var(--text-2); font-size: 12.5px; }

.generation-photo {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-2);
}
.generation-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; }
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 28%;
  background: linear-gradient(180deg, rgba(122, 92, 255, 0) 0%, rgba(122, 92, 255, 0.45) 50%, rgba(122, 92, 255, 0) 100%);
  animation: scan 1.9s ease-in-out infinite;
}
@keyframes scan {
  0% { top: -28%; }
  100% { top: 100%; }
}

.generation-copy { display: flex; align-items: baseline; gap: 10px; }
.generation-copy strong { font-size: 15px; }
.generation-copy span { color: var(--accent); font-size: 14px; font-weight: 700; }

.progress-track {
  width: min(100%, 300px);
  height: 5px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-track span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width 0.28s ease;
}

.result-state { display: grid; gap: 16px; }
.result-state[hidden] { display: none; }

.compare-wrap {
  --compare-width: 100%;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.compare-after { width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; }
.compare-before { position: absolute; top: 0; left: 0; bottom: 0; width: 48%; overflow: hidden; }
.compare-before img {
  width: var(--compare-width);
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: 50% 24%;
}
.compare-wrap input[type="range"] {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  -webkit-appearance: none;
  appearance: none;
  background: none;
}
.compare-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 48%;
  z-index: 3;
  width: 2px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.compare-line span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: #0d0d12;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}
.compare-line svg { width: 18px; height: 18px; }

.compare-tag {
  position: absolute;
  bottom: 12px;
  z-index: 4;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(12, 12, 16, 0.5);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}
.before-tag { left: 12px; }
.after-tag { right: 12px; }

.result-meta {
  display: grid;
  gap: 8px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.result-meta > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.result-meta span { color: var(--text-2); font-size: 13px; }
.result-meta strong { font-size: 15px; }
.result-meta p { color: var(--text-2); font-size: 13px; line-height: 1.6; }

.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 22px);
  z-index: 90;
  max-width: min(86vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(13, 13, 18, 0.92);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
/* 结果弹层打开时，提示改到顶部，避免压住“再次生成 / 保存图片” */
.result-modal.is-open ~ .toast { bottom: auto; top: calc(var(--bar-h) + 16px); }

/* ------------------------------ 桌面端 ------------------------------ */

@media (min-width: 900px) {
  body { font-size: 15.5px; }

  .app-bar { padding: 12px 40px; }
  .brand { margin-right: 26px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-text strong { font-size: 17px; }

  .top-nav { display: flex; align-items: center; gap: 4px; margin-right: auto; }
  .top-nav__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
  }
  .top-nav__item:hover { background: var(--surface-2); color: var(--text); }
  .top-nav__item.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }
  .top-nav__item svg { width: 17px; height: 17px; }

  .bottom-nav { display: none; }

  .app-main {
    max-width: 1160px;
    padding: 30px 40px 72px;
  }

  .page-head h1 { font-size: 32px; }
  .page-back { display: none; }

  .home { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 44px; align-items: start; }
  .home-panel { gap: 20px; margin-top: 0; }
  #stylesPage { padding-bottom: 0; }
  .home-lead { font-size: 15px; }
  .entry { padding: 18px; }
  .entry-icon { width: 46px; height: 46px; }
  .entry-copy strong { font-size: 16.5px; }

  .style-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 16px; }
  .filter-row { margin: 0 0 20px; padding: 0; }

  .generate-dock {
    position: sticky;
    bottom: 24px;
    max-width: 460px;
    margin: 28px auto 0;
    padding: 14px 16px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }

  #describePage { max-width: 720px; }
  #describePage textarea { font-size: 15px; }

  .works-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .empty-studio { padding: 44px 24px 48px; }

  #profilePage .salon-card,
  #profilePage .list-group,
  #profilePage .security-note,
  #connectPage > * { max-width: 620px; }
  #connectPage .primary-button--block { width: 100%; }

  .result-modal.is-open { display: grid; place-items: center; }
  .result-sheet {
    position: relative;
    inset: auto;
    width: min(92vw, 720px);
    max-height: 90vh;
    padding: 22px 26px 26px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
  }
  .generation-photo { width: min(100%, 340px); }
  .toast { bottom: 34px; }
}

@media (min-width: 1200px) {
  .style-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ------------------------------ 无障碍 ------------------------------ */

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
