/* ============================================================
   妆造顾问 · Apple-style redesign
   系统字体 · 半透明材质 · 弹簧缓动 · 深浅色自适应
   ============================================================ */

:root {
  /* 圆角(Apple 连续曲率观感) */
  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  /* 弹簧感缓动(Vaul/Apple sheet 同款) */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* 品牌强调色(B站 少女粉) */
  --accent: #fb7299;
  --accent-press: #e06285;

  /* —— 浅色(默认) —— */
  --bg: #f5f5f7;
  --bg-2: #ececee;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --elevated: rgba(255, 255, 255, 0.85);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --hairline: rgba(0, 0, 0, 0.10);
  --hairline-strong: rgba(0, 0, 0, 0.16);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.20);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06);
  --accent-tint: rgba(251, 114, 153, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #0a0a0c;
    --surface: rgba(28, 28, 30, 0.66);
    --surface-solid: #1c1c1e;
    --elevated: rgba(44, 44, 46, 0.72);
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --hairline: rgba(255, 255, 255, 0.12);
    --hairline-strong: rgba(255, 255, 255, 0.20);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    --accent: #ff85a7;
    --accent-tint: rgba(255, 133, 167, 0.16);
  }
}

* { box-sizing: border-box; }

/* hidden 属性优先级最高,避免被 .uploader img { display:block } 等规则覆盖 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 100%;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(60rem 40rem at 80% -10%, var(--accent-tint), transparent 60%),
    linear-gradient(var(--bg), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ---------- 头部 ---------- */
header { text-align: center; margin-bottom: 1.75rem; position: relative; }

h1 {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.021em;   /* 大字负字距 */
  font-weight: 700;
  margin: 0 0 0.4rem;
}
.sub {
  color: var(--text-2);
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0;
}

/* 半透明胶囊按钮(材质浮层) */
.gear {
  position: absolute; top: -0.25rem; right: 0;
  display: inline-flex; align-items: center; gap: 0.3rem;
  text-decoration: none; color: var(--text-2);
  font-size: 0.8rem; font-weight: 500; letter-spacing: -0.01em;
  background: var(--surface);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: 999px; padding: 0.44rem 0.8rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease-out, color 0.2s, border-color 0.2s;
}
.gear:hover { color: var(--text); border-color: var(--hairline-strong); }
.gear:active { transform: scale(0.96); }

/* ---------- 提示条 ---------- */
.banner {
  margin-bottom: 1.25rem; padding: 0.85rem 1rem;
  border-radius: var(--r-md);
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--text); font-size: 0.9rem;
  animation: materialize 0.45s var(--ease-out) both;
}
.banner a { color: var(--accent); font-weight: 600; text-decoration: none; }
.banner a:hover { text-decoration: underline; }

/* ---------- 上传区 ---------- */
.uploader {
  border: 1.5px dashed var(--hairline-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  min-height: 17rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s var(--ease-out), transform 0.2s var(--spring), box-shadow 0.25s;
}
.uploader:hover { border-color: var(--accent); }
.uploader.dragover {
  border-color: var(--accent); transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}
.uploader img { width: 100%; max-height: 24rem; object-fit: contain; display: block; }

.hint { text-align: center; color: var(--text-2); padding: 2rem; }
.hint .icon { font-size: 2.6rem; opacity: 0.85; }
.hint p { margin: 0.7rem 0 0.25rem; color: var(--text); font-size: 1.05rem; font-weight: 500; letter-spacing: -0.01em; }
.hint span { font-size: 0.8rem; color: var(--text-3); }

/* ---------- 主按钮 ---------- */
.primary {
  width: 100%; margin-top: 1.1rem; padding: 0.95rem;
  border: 0; border-radius: var(--r-md);
  background: var(--accent); color: #fff;
  font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.1s ease-out, background 0.2s, opacity 0.2s;
}
.primary:hover { background: var(--accent-press); }
.primary:active:not(:disabled) { transform: scale(0.97); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ---------- 状态 ---------- */
.status {
  margin-top: 1rem; padding: 0.8rem 1rem;
  border-radius: var(--r-md);
  background: var(--fill); color: var(--text-2);
  font-size: 0.9rem; text-align: center;
}
.status.error { color: #ff453a; background: color-mix(in srgb, #ff453a 12%, transparent); }
.spinner {
  display: inline-block; width: 0.9rem; height: 0.9rem; margin-right: 0.5rem;
  border: 2px solid var(--fill-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 结果 ---------- */
.result { margin-top: 1.75rem; }

.card {
  background: var(--elevated);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-lg);
  animation: materialize 0.5s var(--ease-out) both;
}
.card h2, .looks-title {
  font-size: 1.15rem; font-weight: 650; letter-spacing: -0.015em;
  margin: 0 0 0.85rem;
}
.looks-title { margin: 1.75rem 0 0.9rem; }

.face-summary {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  color: var(--text);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* 核心特征 Bento 布局 */
.face-core-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.face-core-item {
  background: linear-gradient(135deg, rgba(251, 114, 153, 0.08), rgba(251, 114, 153, 0.02));
  border: 1px solid rgba(251, 114, 153, 0.15);
  border-radius: var(--r-md);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.face-core-item span {
  font-size: 0.76rem;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.face-core-item strong {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
}

.face-meta {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.face-meta li {
  background: var(--fill);
  border: 1px solid var(--hairline);
  padding: 0.6rem 0.95rem;
  border-radius: var(--r-md);
  font-size: 0.86rem;
  color: var(--text-2);
  line-height: 1.45;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.face-meta li::before {
  content: "✦";
  color: var(--accent);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.face-meta li:hover {
  background: var(--fill-2);
  border-color: var(--hairline-strong);
}

/* 核心关键词高亮 */
.highlight-word {
  color: var(--accent);
  font-weight: 600;
  background: rgba(251, 114, 153, 0.09);
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  border: 1px solid rgba(251, 114, 153, 0.12);
  margin: 0 0.1rem;
  display: inline-block;
  line-height: 1.2;
}

/* 妆容卡片 */
.looks { display: flex; flex-direction: column; gap: 0.85rem; }
.look {
  background: var(--elevated);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 1.15rem 1.3rem;
  box-shadow: var(--shadow-sm);
  animation: materialize 0.5s var(--ease-out) both;
}
.look h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; color: var(--accent); }
.look .reason { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; margin: 0 0 0.85rem; }
.look .steps { margin: 0 0 0.9rem; padding-left: 1.15rem; color: var(--text); font-size: 0.9rem; line-height: 1.7; }

/* 每套妆容下的教程区 */
.look-tutorials { margin-top: 0.5rem; padding-top: 0.9rem; border-top: 1px solid var(--hairline); }
.tut-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem; gap: 0.5rem; flex-wrap: wrap;
}
.tut-tabs {
  display: inline-flex;
  background: var(--fill);
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  gap: 0.15rem;
}
.tut-tab {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s var(--ease-out);
}
.tut-tab:hover {
  color: var(--text);
}
.tut-tab.active {
  background: var(--surface-solid);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tut-tab:active {
  transform: scale(0.96);
}
.tut-more {
  border: 0; background: transparent; color: var(--accent);
  font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: inherit;
  padding: 0.2rem 0; transition: opacity 0.15s;
}
.tut-more:hover { opacity: 0.7; }
.tut-status { margin: 0.3rem 0; }

.dy-platform-tag {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  z-index: 4;
}

/* ---------- 关键词 / 芯片 ---------- */
.kw-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kw {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--text); font-size: 0.83rem; font-weight: 500; letter-spacing: -0.005em;
  background: var(--fill); border: 1px solid transparent;
  padding: 0.44rem 0.85rem; border-radius: 999px; cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease-out, background 0.2s, border-color 0.2s;
}
.kw::before { content: "🔍"; font-size: 0.78rem; }
.kw:hover { background: var(--fill-2); border-color: var(--hairline); }
.kw:active { transform: scale(0.95); }

/* ---------- 抖音搜索面板 ---------- */
.search-panel { margin-top: 0.9rem; }
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.search-bar input {
  flex: 1; min-width: 12rem; padding: 0.8rem 0.95rem; font-size: 0.95rem;
  background: var(--fill); border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text); outline: none; font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.search-bar input::placeholder { color: var(--text-3); }
.search-bar input:focus { border-color: var(--accent); background: var(--surface-solid); }
.search-go, .search-app {
  border: 0; border-radius: var(--r-md); padding: 0 1.1rem; font-size: 0.9rem;
  font-weight: 600; letter-spacing: -0.01em; cursor: pointer; font-family: inherit;
  transition: transform 0.1s ease-out, background 0.2s, border-color 0.2s;
}
.search-go { background: var(--accent); color: #fff; }
.search-go:hover { background: var(--accent-press); }
.search-go:active, .search-app:active { transform: scale(0.96); }
.search-app { background: var(--fill); color: var(--text); border: 1px solid var(--hairline); }
.search-app:hover { background: var(--fill-2); }

/* ---------- 抖音视频结果网格 ---------- */
.dy-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem; margin-top: 0.9rem;
}
.dy-card {
  text-align: left; padding: 0; border: 0; cursor: pointer; font-family: inherit;
  background: transparent; color: var(--text);
  border-radius: var(--r-md); overflow: hidden;
  transition: transform 0.12s var(--spring);
  animation: materialize 0.4s var(--ease-out) both;
}
.dy-card:hover { transform: translateY(-2px); }
.dy-card:active { transform: scale(0.97); }
.dy-thumb {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 62.5%; /* 16:10 比例撑开 */
  background: var(--fill);
  border-radius: var(--r-md);
  overflow: hidden;
}
.dy-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease-out;
  z-index: 2;
}
.dy-thumb-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  z-index: 1;
}
.dy-thumb-emoji {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}
.dy-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border-radius: 50%;
  font-size: 0.9rem;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
  z-index: 3;
}
.dy-card:hover .dy-play {
  opacity: 1;
}
.dy-duration {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  font-size: 0.72rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 4;
}
.dy-info { padding: 0.45rem 0.15rem 0.2rem; }
.dy-desc {
  margin: 0 0 0.25rem; font-size: 0.82rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 500;
}
.dy-author { display: block; font-size: 0.74rem; color: var(--text-2); margin-bottom: 0.1rem; }
.dy-stats { display: block; font-size: 0.72rem; color: var(--text-3); }

/* ---------- 播放浮层(iframe 嵌套) ---------- */
.player-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  animation: fadeIn 0.25s var(--ease-out) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.player-box {
  position: relative; width: min(24rem, 92vw);
  background: var(--surface-solid); border-radius: var(--r-xl); overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: materialize 0.35s var(--ease-out) both;
  display: flex; flex-direction: column;
}
.player-box-tall { width: min(34rem, 96vw); height: min(82vh, 720px); }
.player-iframe {
  flex: 1 1 auto; width: 100%; border: 0; display: block;
  background: #fff; min-height: 0;
}
.player-close {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2;
  width: 2rem; height: 2rem; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 0.85rem;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform 0.1s ease-out;
}
.player-close:active { transform: scale(0.9); }
.player-meta { padding: 0.85rem 1rem 0.5rem; font-size: 0.86rem; line-height: 1.45; color: var(--text); }
.player-meta b { font-weight: 650; }
.player-sub { color: var(--text-3); font-size: 0.78rem; }
.player-actions {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem 0.9rem; gap: 0.75rem;
}
.player-action {
  background: var(--accent); color: #fff; padding: 0.5rem 0.95rem;
  border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  text-decoration: none; flex: 0 0 auto;
  transition: transform 0.1s ease-out, background 0.2s;
}
.player-action:hover { background: var(--accent-press); }
.player-action:active { transform: scale(0.96); }
.player-tip { color: var(--text-3); font-size: 0.72rem; text-align: right; line-height: 1.4; }

/* 设置页分隔线 */
.divider { border: 0; border-top: 1px solid var(--hairline); margin: 1.4rem 0; }

/* ---------- 设置页表单 ---------- */
.field { display: block; margin-bottom: 1.15rem; }
.field > span { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 0.4rem; color: var(--text); letter-spacing: -0.01em; }
.field input {
  width: 100%; padding: 0.8rem 0.95rem; font-size: 0.95rem;
  background: var(--fill); border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text); outline: none; font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.field input:focus { border-color: var(--accent); background: var(--surface-solid); }
.field-hint { display: block; margin-top: 0.4rem; color: var(--text-3); font-size: 0.78rem; }

.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.4rem 0 1.3rem; }
.preset-label { color: var(--text-3); font-size: 0.82rem; }
.preset {
  background: var(--fill); border: 1px solid transparent; color: var(--text-2);
  padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.78rem; cursor: pointer;
  font-family: inherit; transition: transform 0.1s ease-out, background 0.2s;
}
.preset:hover { background: var(--fill-2); color: var(--text); }
.preset:active { transform: scale(0.95); }

.back-link {
  display: inline-block; margin-top: 1.25rem; color: var(--text-2);
  text-decoration: none; font-size: 0.9rem;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

/* ---------- 页脚 ---------- */
footer { margin-top: 2.25rem; text-align: center; }
footer small { color: var(--text-3); font-size: 0.76rem; }

/* ---------- 动画:材质化入场(模糊+缩放+位移) ---------- */
@keyframes materialize {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.985); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ---------- 无障碍:尊重系统偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card, .look, .banner { animation: fade 0.2s ease both; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}

@media (prefers-reduced-transparency: reduce) {
  .gear, .uploader, .card, .look { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --hairline: rgba(0,0,0,0.35); --text-2: #48484a; }
  .card, .look, .uploader { border-color: var(--hairline); }
}
