/* =========================================================
   365Lab 国庆头像 · 红金国风主题
   ========================================================= */
:root {
  --red: #c8102e;
  --red-bright: #e8273f;
  --red-dark: #9b0f24;
  --red-deep: #5c0814;
  --gold: #ffd34d;
  --gold-light: #ffe9a8;
  --gold-deep: #e8a817;
  --cream: #faf3e3;
  --paper: #fffdf7;
  --ink: #33200f;
  --ink-soft: #6b5636;
  --line: #ead9ae;
  --shadow: 0 10px 30px rgba(140, 11, 30, .12);
  --shadow-sm: 0 4px 14px rgba(140, 11, 30, .08);
  --radius: 16px;
  --font-cn: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "FangSong", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-cn);
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 50% -120px, rgba(232, 168, 23, .18), transparent 70%),
    var(--cream);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input[type="range"] { width: 100%; accent-color: var(--red); }
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px clamp(14px, 4vw, 40px);
  background: linear-gradient(90deg, var(--red-deep), var(--red) 55%, var(--red-dark));
  box-shadow: 0 4px 18px rgba(92, 8, 20, .35);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.logo-star {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, var(--gold-light), var(--gold-deep));
  color: var(--red-dark); font-size: 20px;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.15);
}
.logo-text { font-size: 19px; font-weight: 800; letter-spacing: 1px; }
.logo-sub { font-size: 13px; font-weight: 600; opacity: .92; margin-left: 6px; }
.lang-switch { display: flex; gap: 6px; }
.lang-btn {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.4);
  transition: all .2s;
}
.lang-btn.active, .lang-btn:hover { background: var(--gold); color: var(--red-dark); border-color: var(--gold); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 320px at 20% 0%, rgba(255,211,77,.22), transparent 65%),
    radial-gradient(800px 300px at 85% 10%, rgba(255,255,255,.12), transparent 60%),
    linear-gradient(135deg, var(--red-deep), var(--red) 45%, var(--red-dark));
  color: #fff; text-align: center;
  padding: 46px 20px 40px;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2.5px 2.5px at 8% 18%, rgba(255,211,77,.9), transparent),
    radial-gradient(2px 2px at 18% 70%, rgba(255,211,77,.75), transparent),
    radial-gradient(2.5px 2.5px at 32% 32%, rgba(255,211,77,.85), transparent),
    radial-gradient(2px 2px at 45% 82%, rgba(255,211,77,.7), transparent),
    radial-gradient(2.5px 2.5px at 58% 22%, rgba(255,211,77,.9), transparent),
    radial-gradient(2px 2px at 68% 66%, rgba(255,211,77,.8), transparent),
    radial-gradient(2.5px 2.5px at 82% 38%, rgba(255,211,77,.85), transparent),
    radial-gradient(2px 2px at 92% 76%, rgba(255,211,77,.7), transparent),
    radial-gradient(2px 2px at 26% 52%, rgba(255,211,77,.5), transparent),
    radial-gradient(2px 2px at 76% 12%, rgba(255,211,77,.5), transparent);
  background-size: 240px 240px;
  opacity: .55;
}
.hero-inner { position: relative; max-width: 880px; margin: 0 auto; }
.hero-flag { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.hero-flag span {
  font-size: 18px; color: var(--gold);
  text-shadow: 0 0 14px rgba(255,211,77,.75);
  animation: twinkle 2.4s ease-in-out infinite;
}
.hero-flag span:nth-child(2) { animation-delay: .4s; }
.hero-flag span:nth-child(3) { animation-delay: .8s; }
.hero-flag span:nth-child(4) { animation-delay: 1.2s; }
.hero-flag span:nth-child(5) { animation-delay: 1.6s; }
@keyframes twinkle { 0%,100% { opacity: .55; transform: scale(.92);} 50% { opacity: 1; transform: scale(1.08);} }
.hero h1 {
  font-family: var(--font-kai);
  font-size: clamp(30px, 5.4vw, 52px);
  font-weight: 700; letter-spacing: 2px;
  text-shadow: 0 4px 24px rgba(0,0,0,.3);
}
.hero-sub { margin-top: 12px; font-size: clamp(14px, 2.4vw, 17px); opacity: .94; }
.hero-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.hero-chips li {
  padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(255,211,77,.14); border: 1px solid rgba(255,211,77,.55); color: var(--gold-light);
}

/* ---------- 工作区 ---------- */
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px; align-items: start;
  max-width: 1280px; margin: 28px auto 0; padding: 0 clamp(14px, 4vw, 40px);
}
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; max-width: 760px; }
}

/* ---------- 编辑器 ---------- */
.editor-panel { position: sticky; top: 74px; }
@media (max-width: 1080px) { .editor-panel { position: static; } }
.editor-wrap {
  position: relative; overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--gold-deep); border-radius: var(--radius);
  box-shadow: var(--shadow);
  touch-action: none; user-select: none; cursor: grab;
  width: 100%; aspect-ratio: 1 / 1;
}
.editor-wrap:active { cursor: grabbing; }
#previewCanvas { width: 100%; height: 100%; display: block; }
.editor-tools {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; padding: 6px;
  background: rgba(255,255,255,.92); border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  backdrop-filter: blur(6px);
}
.tool-btn {
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px;
  display: grid; place-items: center; color: var(--red-dark);
  background: var(--cream); border: 1px solid var(--line); transition: all .15s;
}
.tool-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }
.editor-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #fff; padding: 4px 14px; border-radius: 999px;
  background: rgba(51,32,15,.55); backdrop-filter: blur(4px); white-space: nowrap;
}
.drop-mask[hidden] { display: none; }
.drop-mask {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center;
  background: rgba(200,16,46,.88); color: #fff;
}
.drop-box { text-align: center; padding: 30px; border: 2px dashed var(--gold-light); border-radius: 18px; }
.drop-icon { font-size: 40px; display: block; margin-bottom: 8px; color: var(--gold); }

.upload-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.mobile-download-bar {
  display: none; position: sticky; bottom: 0; z-index: 40;
  margin: 14px -14px -14px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(250,243,227,0), var(--cream) 30%);
}
.mobile-download-bar .btn { width: 100%; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 999px; font-size: 15px; font-weight: 700;
  transition: transform .15s, box-shadow .15s, filter .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--red-bright), var(--red-dark));
  box-shadow: 0 6px 16px rgba(200,16,46,.35);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(200,16,46,.4); }
.btn-ghost {
  color: var(--red-dark); background: var(--paper);
  border: 1.5px solid var(--red); 
}
.btn-ghost:hover { background: #fff0f2; }
.btn-ghost.danger { color: #a33; border-color: #c66; }
.btn-download {
  color: var(--red-deep);
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 6px 18px rgba(232,168,23,.4);
}
.btn-download:hover { filter: brightness(1.05); }
.btn.wide { width: 100%; margin-top: 12px; }

/* ---------- 控制面板 ---------- */
.controls {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.tabs { display: flex; background: var(--red-deep); }
.tab {
  flex: 1; padding: 13px 4px; font-size: 14px; font-weight: 700; color: rgba(255,255,255,.82);
  transition: all .2s; position: relative;
}
.tab.active { color: #fff; background: rgba(255,255,255,.1); }
.tab.active::after {
  content: ""; position: absolute; left: 20%; right: 20%; bottom: 0; height: 3px;
  background: var(--gold); border-radius: 3px 3px 0 0;
}
.panels { padding: 18px 16px 22px; }
.panel { display: none; animation: fadeIn .25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.section-title {
  font-size: 14px; font-weight: 800; color: var(--red-dark); margin: 14px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 0; }
.section-title::before {
  content: ""; width: 5px; height: 16px; border-radius: 3px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
}

/* 形状切换 */
.shape-switch { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border-radius: 12px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--cream); color: var(--ink-soft);
  transition: all .18s;
}
.shape-btn.active { border-color: var(--red); background: #fff0f2; color: var(--red-dark); }
.shape-ico {
  width: 26px; height: 26px; border: 2.5px solid currentColor;
  background: rgba(200,16,46,.12);
}
.ico-circle { border-radius: 50%; }
.ico-round { border-radius: 7px; }
.ico-square { border-radius: 2px; }
.ico-heart {
  border: none; background:
    radial-gradient(circle at 50% 30%, currentColor 0 42%, transparent 43%) no-repeat,
    radial-gradient(circle at 50% 30%, currentColor 0 42%, transparent 43%) no-repeat;
  width: 26px; height: 24px; position: relative;
  background-size: 52% 62%, 52% 62%; background-position: 13% 30%, 87% 30%;
  border-radius: 0;
}
.ico-heart::after {
  content: ""; position: absolute; left: 13%; right: 13%; top: 26%; height: 60%;
  background: currentColor; clip-path: polygon(50% 100%, 0 50%, 100% 50%);
}

/* 模板分类 */
.frame-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-btn {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--cream);
  transition: all .18s;
}
.cat-btn.active, .cat-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }

.frame-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-height: 430px; overflow-y: auto; padding-right: 4px;
}
.frame-card {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  border: 2px solid transparent; background: #f2ead6;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.frame-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(140,11,30,.18); }
.frame-card.active { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(232,168,23,.35); }
.frame-card img { width: 100%; height: 100%; object-fit: cover; }
.frame-card-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px;
  font-size: 11px; font-weight: 600; text-align: center; color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.55));
}

/* 滤镜 */
.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.filter-chip {
  padding: 9px 4px; border-radius: 12px; font-size: 13px; font-weight: 600; text-align: center;
  border: 1.5px solid var(--line); background: var(--cream); color: var(--ink-soft);
  transition: all .18s;
}
.filter-chip.active { border-color: var(--red); background: #fff0f2; color: var(--red-dark); }
.adjust-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.adjust-row { display: grid; grid-template-columns: 64px 1fr 36px; align-items: center; gap: 10px; margin-bottom: 8px; }
.adjust-row label { font-size: 13px; color: var(--ink-soft); }
.adjust-row output { font-size: 12px; color: var(--red-dark); font-weight: 700; text-align: right; }

/* 卡通 */
.anime-tip {
  padding: 10px 12px; border-radius: 10px; background: #fff7e2; border: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft); margin-bottom: 12px;
}
.anime-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.anime-card {
  position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1;
  border: 2px solid transparent; cursor: pointer; transition: all .18s;
  background: linear-gradient(135deg, #e8273f, #8c0b1e);
}
.anime-card img { width: 100%; height: 100%; object-fit: cover; opacity: .85; transition: opacity .18s; }
.anime-card:hover img { opacity: 1; }
.anime-card.active { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(232,168,23,.35); }
.anime-card-label {
  position: absolute; left: 6px; right: 6px; bottom: 6px; text-align: center;
  font-size: 12px; font-weight: 700; color: #fff; padding: 3px 6px; border-radius: 999px;
  background: rgba(92,8,20,.72);
}
.anime-actions { display: flex; gap: 10px; margin-top: 14px; }
.anime-actions .btn { flex: 1; }
.anime-progress { margin-top: 14px; }
.progress-bar { height: 10px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--gold-deep)); transition: width .3s; }
.anime-progress p { font-size: 13px; color: var(--ink-soft); margin-top: 6px; text-align: center; }
.anime-note { font-size: 12px; color: var(--ink-soft); margin-top: 10px; text-align: center; }

/* 文字 */
.switch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: #d8c9a4; transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--red); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.txt-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.txt-field label { font-size: 13px; color: var(--ink-soft); }
.txt-field input, .txt-field select {
  padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  font-size: 15px; background: var(--cream); color: var(--ink);
}
.txt-field input:focus { outline: none; border-color: var(--red); }
.txt-row { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 12px; margin-bottom: 12px; }
.txt-row > label { font-size: 13px; color: var(--ink-soft); }
.txt-row output { font-size: 12px; color: var(--red-dark); font-weight: 700; text-align: right; }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; background: var(--c);
  border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); transition: transform .15s;
}
.swatch.active { transform: scale(1.18); box-shadow: 0 0 0 2.5px var(--red); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg.big .seg-btn { flex: 1; }
.seg-btn {
  padding: 9px 10px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--cream); color: var(--ink-soft); transition: all .18s;
}
.seg-btn.active { background: var(--red); color: #fff; border-color: var(--red); }

/* 历史 */
.history-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.history-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); font-size: 13px; padding: 18px 0; }
.history-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--line); }
.history-item img { width: 100%; height: 100%; object-fit: cover; }
.history-item .del {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; line-height: 1;
  display: none; place-items: center;
}
.history-item:hover .del { display: grid; }

/* ---------- 步骤 ---------- */
.steps, .faq {
  max-width: 1080px; margin: 46px auto 0; padding: 0 clamp(14px, 4vw, 40px);
}
.steps h2, .faq h2 {
  text-align: center; font-family: var(--font-kai); font-size: clamp(24px, 4vw, 34px);
  color: var(--red-dark); margin-bottom: 26px; letter-spacing: 2px;
}
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 720px) { .steps-grid { grid-template-columns: 1fr; } }
.step {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; text-align: center; box-shadow: var(--shadow-sm);
  transition: transform .2s;
}
.step:hover { transform: translateY(-4px); }
.step-num {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; color: var(--red-dark);
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  box-shadow: inset 0 -2px 6px rgba(0,0,0,.12);
}
.step h3 { font-size: 17px; color: var(--red-dark); margin-bottom: 8px; }
.step p { font-size: 13.5px; color: var(--ink-soft); }

/* ---------- FAQ ---------- */
.faq { padding-bottom: 46px; }
.faq details {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.faq summary {
  cursor: pointer; padding: 15px 18px; font-weight: 700; font-size: 15px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; color: var(--red); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 18px 16px; font-size: 13.5px; color: var(--ink-soft); }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 40px; padding: 30px 20px calc(26px + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, var(--red-deep), var(--red-dark));
  color: rgba(255,255,255,.85); text-align: center;
}
.footer p { font-size: 12.5px; max-width: 900px; margin: 0 auto 8px; opacity: .9; }
.footer-copy { opacity: .7 !important; margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  padding: 11px 22px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: rgba(51,32,15,.92); color: #fff; z-index: 99;
  opacity: 0; pointer-events: none; transition: all .3s; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: rgba(153,20,20,.95); }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .mobile-download-bar { display: block; }
  .upload-row .btn { flex: 1; }
  .frame-grid { grid-template-columns: repeat(4, 1fr); max-height: none; }
  .filter-grid, .anime-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-panel { order: -1; }
  .tab { font-size: 13px; padding: 12px 2px; }
  .editor-hint { display: none; }
}
@media (max-width: 420px) {
  .frame-grid { grid-template-columns: repeat(3, 1fr); }
  .logo-text { font-size: 17px; }
  .lang-btn { padding: 5px 11px; }
}
