/* ==========================================================================
   翰墨AI · 外壳层：顶部导航 / 分组下拉 / 移动抽屉 / 页脚 / 提示
   韩系风格重构：柔和圆角、细腻阴影、温润过渡、胶囊按钮
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  display: flex; align-items: center; gap: var(--g3);
  min-height: var(--topbar-h);
}

/* ---------- 品牌 ---------- */

.brand { display: inline-flex; align-items: center; gap: var(--g3); flex: none; }
.brand__glyph {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-md);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 19px; font-weight: 700; letter-spacing: 0;
  box-shadow: var(--sh-2);
}
.brand__word { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.brand__word b { color: var(--brand-deep); font-weight: 700; }
.brand__sub {
  display: block; margin-top: 2px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ---------- 主导航 ---------- */

.mainnav { display: flex; align-items: center; gap: 2px; margin-left: var(--g4); }
.mainnav__link {
  display: inline-flex; align-items: center; gap: 4px;
  height: 38px; padding-inline: 11px;
  border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
  white-space: nowrap;
  transition: background-color var(--d2) var(--ease), color var(--d2) var(--ease);
}
.mainnav__link:hover { background: var(--sunk); color: var(--ink); }
.mainnav__link[aria-current="page"] { background: var(--brand-tint); color: var(--brand-deep); font-weight: 600; }

.navgrp { position: relative; }
.navgrp.is-current > .navgrp__btn { color: var(--brand-deep); font-weight: 600; }
.navgrp[data-open="true"] > .navgrp__btn { background: var(--brand-tint); color: var(--brand-deep); }
.navgrp__chev { width: 13px; height: 13px; opacity: 0.6; transition: transform var(--d2) var(--ease); }
.navgrp[data-open="true"] .navgrp__chev { transform: rotate(180deg); }

.navdrop {
  position: absolute; top: calc(100% + 8px); right: 0; left: auto;
  transform: translateY(-6px);
  width: max-content; max-width: min(520px, 88vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  padding: var(--g4);
  opacity: 0; visibility: hidden;
  transition: opacity var(--d3) var(--ease-enter), transform var(--d3) var(--ease-enter),
              visibility 0s linear var(--d3);
}
.navgrp[data-open="true"] .navdrop {
  opacity: 1; visibility: visible; transform: translateY(0);
  transition-delay: 0s;
}
.navdrop__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--g6);
  padding: 0 var(--g2) var(--g3);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--g2);
}
.navdrop__title { font-size: var(--t-sm); font-weight: 700; }
.navdrop__count { font-size: var(--t-xs); color: var(--ink-3); }
.navdrop__grid { display: grid; grid-template-columns: 1fr; gap: 2px; min-width: 340px; }

/* 「更多」下拉：一个入口、内部按用途分区（图案印花 / 人像处理 / 日常工具），
   所以顶部不再单独占「人像处理」「日常工具」两个下拉位。
   列宽按内容自适应（不折行），面板相对按钮水平居中，避免贴右展开时左侧溢出视口。 */
.navdrop--sections {
  left: 50%; right: auto; transform: translate(-50%, -6px);
  width: min(1080px, calc(100vw - 32px));
  max-width: none;   /* 覆盖 .navdrop 基础的 520px 上限，否则三列会被压窄 */
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--g6);
  padding: var(--g4) var(--g5) var(--g5);
}
.navgrp[data-open="true"] .navdrop--sections { transform: translate(-50%, 0); }
.navdrop--sections .navdrop__sec { min-width: 0; }
.navdrop--sections .navdrop__sec + .navdrop__sec { border-left: 1px solid var(--line); padding-left: var(--g6); }
.navdrop--sections .navdrop__grid { min-width: 0; }
.navdrop--sections .navdrop__item { grid-template-columns: 30px minmax(0, 1fr); }
.navdrop--sections .navdrop__item > span { min-width: 0; }
.navdrop--sections .navdrop__name,
.navdrop--sections .navdrop__desc { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1180px) {
  .navdrop--sections { grid-template-columns: minmax(0, 1fr); width: min(560px, calc(100vw - 32px)); }
  .navdrop--sections .navdrop__sec + .navdrop__sec { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: var(--g3); margin-top: var(--g2); }
}

.navdrop__item {
  display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: var(--g3);
  padding: 9px var(--g2);
  border-radius: var(--r-md);
  transition: background-color var(--d2) var(--ease);
}
.navdrop__item:hover { background: var(--brand-tint); }
.navdrop__ico { display: grid; place-items: center; width: 30px; height: 30px; color: var(--brand-deep); }
.navdrop__ico svg { width: 20px; height: 20px; }
.navdrop__name { font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.navdrop__desc { font-size: var(--t-xs); color: var(--ink-3); margin-top: 1px; }
.navdrop__item[aria-current="page"] { background: var(--brand-tint); }
.navdrop__item[aria-current="page"] .navdrop__name { color: var(--brand-deep); }

/* ---------- 账户区 ---------- */

.topbar__side { display: flex; align-items: center; gap: var(--g2); margin-left: auto; flex: none; }
.topbar__link {
  padding: 9px 11px; border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
  white-space: nowrap;
  transition: background-color var(--d2) var(--ease), color var(--d2) var(--ease);
}
.topbar__link:hover { background: var(--sunk); color: var(--ink); }
.topbar__link[aria-current="page"] { color: var(--brand-deep); font-weight: 600; }
/* 汉堡按钮在宽屏隐藏：它同时带 .btn 类，而 .btn 定义在 blocks.css（后加载、同特异性），
   因此这里必须提高特异性，否则桌面端会跟着 .btn 的 display:inline-flex 一起显示出来。 */
.topbar__side .topbar__burger { display: none; }

/* ---------- 移动抽屉 ---------- */

.sheet {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  visibility: hidden; pointer-events: none;
  /* 关闭时面板 translateX(100%) 移到右侧边界外；这里裁掉它，避免撑大根元素滚动宽度 */
  overflow: hidden;
}
.sheet[data-open="true"] { visibility: visible; pointer-events: auto; }
.sheet__veil {
  position: absolute; inset: 0; background: var(--veil);
  opacity: 0; transition: opacity var(--d3) var(--ease);
}
.sheet[data-open="true"] .sheet__veil { opacity: 1; }
.sheet__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(380px, 88vw);
  background: var(--surface);
  box-shadow: var(--sh-4);
  padding: var(--g5);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--d4) var(--ease-enter);
}
.sheet[data-open="true"] .sheet__panel { transform: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--g5); }
.sheet__group { padding-block: var(--g4); border-top: 1px solid var(--line); }
.sheet__group:first-of-type { border-top: 0; }
.sheet__gname {
  display: flex; align-items: center; gap: var(--g2);
  font-size: var(--t-min); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--g3);
}
.sheet__item {
  display: flex; align-items: center; gap: var(--g3);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.sheet__item:last-child { border-bottom: 0; }
.sheet__item svg { width: 20px; height: 20px; color: var(--brand-deep); flex: none; }
.sheet__item b { font-size: var(--t-sm); font-weight: 600; display: block; }
.sheet__item small { font-size: var(--t-xs); color: var(--ink-3); display: block; }

/* ---------- 页脚（韩系：白底细线，温润收尾） ---------- */

.foot {background: var(--surface); border-top: 1px solid var(--line); }/** margin-top: var(--g9); **/
.foot__grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, minmax(0, 1fr));
  gap: var(--g7) var(--g5);
  padding-block: var(--g10) var(--g8);
}
@media (max-width: 900px) { .foot__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .foot__grid { grid-template-columns: 1fr; gap: var(--g5); } }
.foot__brand { grid-column: span 1; }
@media (max-width: 720px) { .foot__brand { grid-column: 1 / -1; } }
.foot__col h4 {
  font-size: var(--t-min); font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--g4);
}
.foot__col a {
  display: block; padding: 5px 0;
  font-size: var(--t-sm); color: var(--ink-2);
  transition: color var(--d2) var(--ease);
}
.foot__col a:hover { color: var(--brand-deep); }
/* 页脚品牌是 `.brand`（左"翰"色块 + 右"翰墨AI／设计图像工具集"），
   必须保持 inline-flex 左右结构；否则被上一条 `.foot__col a{display:block}`
   （特异性更高）打成块级，"翰"与文字会上下堆叠。 */
.foot__col a.brand { display: inline-flex; padding: 0; }
.foot__base {
  display: flex; align-items: center; justify-content: space-between; gap: var(--g4);
  flex-wrap: wrap;
  padding-block: var(--g5);
  border-top: 1px solid var(--line);
  font-size: var(--t-xs); color: var(--ink-3);
}

/* ---------- 提示条（韩系：圆角胶囊） ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex; flex-direction: column-reverse; gap: var(--g2);
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  display: flex; align-items: center; gap: var(--g2);
  padding: 12px 18px;
  background: var(--ink); color: var(--on-dark);
  border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 500;
  box-shadow: var(--sh-4);
  animation: toast-in var(--d4) var(--ease-enter) both;
}
.toast[data-kind="ok"] { background: var(--ok); color: #fff; }
.toast[data-kind="err"] { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 响应式：导航折叠为抽屉 ---------- */

@media (max-width: 1024px) {
  .mainnav { display: none; }
  /* 与上面的隐藏规则同特异性，否则宽屏那条会一直压住它、移动端也点不到汉堡 */
  .topbar__side .topbar__burger { display: inline-flex; }
  .topbar__link { display: none; }
}
@media (max-width: 520px) { .brand__sub { display: none; } .topbar__in { gap: var(--g2); } }
