/**
 * shell.css — 应用外壳：左侧分组导航 + 右侧内容
 * 目标：任何时刻都能看到「我在哪、还能去哪、下一步点哪」
 */

:root {
  --nav-w: 236px;
  --header-h: 57px;
}

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  max-width: 1300px;
  margin: 0 auto;
  align-items: start;
}

.shell-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
}

.shell .app-main {
  max-width: none;
  margin: 0;
  width: 100%;
  padding: var(--space-6) var(--space-6) var(--space-8);
  flex: 1;
}

.shell .app-footer { max-width: none; margin: 0; }

/* ---------------- 侧边导航 ---------------- */
.shell-nav {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 12px 28px 18px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.shell-nav::-webkit-scrollbar { width: 6px; }
.shell-nav::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
/* 分组之间用发丝线断开，标题才不会和工具项混在一起 */
.nav-group + .nav-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

/* 分类标题：字号更小、字重更重、字距更开，右侧带工具数量角标 */
.nav-group-title {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--label-tracking, 0.08em);
  text-transform: var(--label-transform, uppercase);
  color: var(--text-faint);
}
.nav-group-title::after {
  content: attr(data-count);
  margin-left: auto;
  min-width: 18px; height: 16px; line-height: 16px; padding: 0 5px;
  border-radius: 999px; text-align: center;
  background: var(--surface-3); color: var(--text-faint);
  font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item-text { overflow: hidden; text-overflow: ellipsis; }
.nav-dot {
  margin-left: auto; width: 6px; height: 6px; flex: none;
  border-radius: 50%; background: transparent;
}
.nav-item.is-done .nav-dot { background: var(--success); }
.nav-item[aria-current="page"] .nav-dot { background: var(--accent); }

/* ---------------- 移动端 ---------------- */
.nav-toggle { display: none; }

.nav-scrim {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: var(--overlay);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.nav-scrim.is-open { opacity: 1; pointer-events: auto; }

@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .shell-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 276px;
    max-width: 84vw;
    height: auto;
    z-index: 46;
    background: var(--surface);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    border-right: 1px solid var(--border);
    box-shadow: var(--sh-card);
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
    padding-bottom: 88px;
  }
  .shell-nav.is-open { transform: none; }

  .shell .app-main { padding: var(--space-5) var(--space-4) 92px; }
  .shell .app-footer { padding: var(--space-4) var(--space-4) 88px; }

  .nav-toggle { display: inline-flex; }
  .tabbar { display: flex; }
}

/* 窄屏用短名，避免品牌名折行挤掉风格切换 */
.brand-short { display: none; }
@media (max-width: 560px) {
  .brand-stack { display: none; }
  .brand-logo { width: 24px; height: 24px; border-radius: 6px; }
  .brand-short { display: inline; font-size: 15px; font-weight: var(--title-weight); }
  .header-inner { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
  .header-actions { gap: var(--space-2); }
  .header-actions .segmented button { padding: 0 8px; font-size: var(--text-xs); min-height: 28px; }
}

/* 极窄屏（≤380px）：4 个风格按钮 + 明暗按钮必须挤在一行，缩小字号与内边距，避免横向溢出 */
@media (max-width: 380px) {
  .header-inner { padding: var(--space-2) 8px; gap: 6px; }
  .header-actions { gap: 6px; }
  .brand-logo { width: 22px; height: 22px; }
  .header-actions .segmented { padding: 2px; }
  .header-actions .segmented button { padding: 0 6px; font-size: 11px; min-height: 26px; }
  /* 微信风是没有底槽的纯文字 tab，靠 gap 分隔，第 4 个按钮进来后要收窄间距 */
  [data-skin="wechat"] .segmented { gap: 10px; }
  [data-skin="wechat"] .segmented button { font-size: 13px; padding: 4px 0; }
}

/* ---------------- 底部快捷导航（仅移动端） ---------------- */
.tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 42;
  background: var(--surface);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  border-top: 1px solid var(--line);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}
.tabbar:empty { display: none !important; }
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 44px;
  padding: 6px 4px;
  border: 0; background: none; cursor: pointer;
  font-size: 11px; font-family: inherit;
  color: var(--text-muted);
  text-decoration: none;
}
.tab-item[aria-current="page"] { color: var(--accent); }
.tab-glyph { font-size: 15px; line-height: 1; }

/* ---------------- 四套风格的差异 ---------------- */
[data-skin="apple"] .nav-item { border-radius: 10px; }
[data-skin="apple"] .nav-item[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .10);
  border-color: var(--border);
}
[data-skin="apple"] .shell-nav { border-right-color: var(--border); }

[data-skin="flat"] .nav-item { border-radius: 2px; }
[data-skin="flat"] .nav-item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: 3px 3px 0 var(--border-strong);
  transform: translate(-1px, -1px);
}
[data-skin="flat"] .nav-group-title { font-weight: 700; }
[data-skin="flat"] .shell-nav { border-right: 2px solid var(--line); }

[data-skin="wechat"] .nav-item { border-radius: 0; }
[data-skin="wechat"] .nav-item + .nav-item { border-top: 1px solid var(--line); }
[data-skin="wechat"] .nav-item[aria-current="page"] {
  background: transparent;
  color: var(--accent);
  font-weight: 400;
}
[data-skin="wechat"] .nav-group-title { text-transform: none; letter-spacing: 0.04em; font-weight: 700; }

/* 小红书资料站：胶囊/圆角小条目 + 浅橙底选中 + 左侧橙色竖条（资料站标题的标志） */
[data-skin="xhs"] .nav-item { border-radius: var(--r-md); padding-left: 7px; border-left: 3px solid transparent; }
[data-skin="xhs"] .nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  border-left-color: var(--accent);
}
[data-skin="xhs"] .nav-group-title { color: var(--text-faint); font-weight: 700; letter-spacing: 0.04em; }
/* emoji 只在第 4 套风格出现（属性由 app-shell 写入，其它风格不渲染） */
[data-skin="xhs"] .nav-item[data-emoji]::before {
  flex: none; width: 18px; text-align: center; font-size: 15px; margin-right: 0;
}
[data-skin="xhs"] .nav-item:hover[data-emoji]::before,
[data-skin="xhs"] .nav-item[aria-current="page"][data-emoji]::before { transform: scale(1.18); }
[data-skin="xhs"] .nav-group-title[data-emoji]::before { font-size: 15px; margin-right: 6px; vertical-align: -1px; }
[data-skin="xhs"] .wb-group-title[data-emoji]::before { font-size: 17px; margin-right: -2px; }
[data-skin="xhs"] .tool-name[data-emoji]::before { font-size: 16px; margin-right: 7px; }
[data-skin="xhs"] .tool-card:hover .tool-name[data-emoji]::before { transform: scale(1.14) rotate(-6deg); }
[data-skin="xhs"] .tab-item[data-emoji]::before { font-size: 17px; margin-right: 0; }
[data-skin="xhs"] .tab-item[data-emoji] .tab-glyph { display: none; }

/* ============================================================
   工作台首页：搜索 + 最近使用 + 分组工具卡
   ============================================================ */

.wb-search { position: relative; margin-bottom: var(--space-5); }
.wb-search input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 42px;
  font-size: var(--text-md);
  border-radius: var(--r-md);
  border: var(--ctrl-bw) solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.wb-search input::placeholder { color: var(--text-faint); }
.wb-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.wb-search-icon {
  position: absolute;
  left: 15px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  display: block;
}
.nav-home { font-weight: 700; color: var(--accent); }
.nav-home + .nav-group { margin-top: 22px; }

.wb-section { margin-bottom: var(--space-6); }
.wb-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--label-tracking, .06em);
  text-transform: var(--label-transform, uppercase);
  color: var(--text-faint);
  margin: 0 0 10px;
}

.wb-group { margin-bottom: var(--space-6); }
.wb-group-title {
  display: flex; align-items: baseline; gap: 10px;
  font-size: var(--text-md);
  font-weight: var(--title-weight, 600);
  color: var(--text);
  margin: 0 0 12px;
}
.wb-group-count {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-faint);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: var(--grid-gap);
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 18px;
  border: var(--ctrl-bw) solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--sh-card);
}
.tool-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tool-name { font-size: var(--text-md); font-weight: 600; }
.tool-hint { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.45; }

.recent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  text-decoration: none;
}
.recent-chip:hover { border-color: var(--accent); color: var(--accent); }

.wb-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

[data-skin="flat"] .tool-card { border-width: 1.5px; border-radius: 3px; }
[data-skin="flat"] .tool-card:hover {
  box-shadow: 3px 3px 0 var(--border-strong);
  transform: translate(-1px, -1px);
}
[data-skin="flat"] .wb-search input { border-width: 1.5px; border-radius: 3px; }

[data-skin="wechat"] .tool-card {
  border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: transparent; padding: 14px 2px;
}
[data-skin="wechat"] .tool-card:hover { transform: none; box-shadow: none; border-bottom-color: var(--accent); }
[data-skin="wechat"] .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }

@media (max-width: 640px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 页头内层与外壳同宽，避免导航与内容边缘错位 */
.app-header .header-inner { max-width: 1300px; }

/* 扁平风格：分组标题左侧加色条，强调「块面」感（中文没有大小写，靠形状区分） */
[data-skin="flat"] .wb-group-title {
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  font-weight: 700;
}
[data-skin="flat"] .nav-group-title { border-left: 3px solid var(--border-strong); padding-left: 8px; }


/* 底部导航的显隐放在文件末尾，避免被基础规则按源码顺序覆盖 */
@media (max-width: 899px) { .tabbar { display: flex; } }
@media (min-width: 900px) { .tabbar { display: none; } }

/* ============================================================
   桌面端：侧栏改为「悬停唤出」的浮层
   —— 平时不占宽度，正文用满整屏；鼠标碰到屏幕左缘才滑出，
      移开自动收起。点击按钮可固定，Esc 收起。
   ============================================================ */

.nav-edge, .nav-head { display: none; }

@media (min-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell-nav {
    position: fixed;
    top: calc(var(--header-h) + 10px);
    left: 10px;
    bottom: 12px;
    width: 272px;
    height: auto;
    max-height: none;
    z-index: 60;
    padding: 14px 12px 20px;
    border: var(--ctrl-bw) solid var(--border);
    border-right: var(--ctrl-bw) solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--sh-card);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    opacity: 0;
    visibility: hidden;
    transform: translateX(calc(-100% - 16px));
    transition: transform .24s cubic-bezier(.2, .75, .3, 1), opacity .16s ease, visibility 0s linear .24s;
  }
  .shell-nav.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: transform .24s cubic-bezier(.2, .75, .3, 1), opacity .16s ease, visibility 0s;
  }

  /* 屏幕左缘的「工具」页签：常驻可见、可点、可聚焦。
     贴边一竖条太细会被当成装饰，这里做成带图标的实体页签。 */
  .nav-edge {
    display: block;
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    width: 20px;              /* 屏幕左缘整条都能唤出，页签本体再向外多突出 10px */
    z-index: 58;
  }
  /* 左缘唤出条：平时就是一条 6×80 的主题色长条（原来是 4px 灰细条，几乎看不见） */
  .nav-edge::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 6px;
    height: 80px;
    margin-top: -40px;
    border-radius: 0 99px 99px 0;
    background: var(--accent);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .18);
    opacity: .92;
    cursor: pointer;
    pointer-events: auto;
    transition: width .2s cubic-bezier(.2, .75, .3, 1), opacity .18s ease, box-shadow .18s ease;
  }
  /* 悬停 / 键盘聚焦时变宽一档，明确「这里能拉出菜单」 */
  .nav-edge:hover::after,
  .nav-edge:focus-visible::after {
    width: 14px;
    opacity: 1;
    box-shadow: var(--sh-pop);
  }
  .nav-edge:focus-visible { outline: none; }
  .nav-edge:focus-visible::after { box-shadow: var(--sh-pop), 0 0 0 3px var(--accent-soft); }
  /* 面板滑出后长条整体隐去（保留可点区域，避免指针下的元素移开导致「开了又关」的抖动） */
  body.nav-peeked .nav-edge::after {
    opacity: 0;
    box-shadow: none;
  }
  [data-skin="flat"] .nav-edge::after { border-radius: 0; }
  @media (prefers-reduced-motion: reduce) {
    .nav-edge::after { transition: none; }
  }

  /* 面板顶部的标题与收起按钮：只出现在桌面浮层里 */
  .nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 4px 10px 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  .nav-head-title {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: var(--label-tracking, .06em);
    text-transform: var(--label-transform, uppercase);
    color: var(--text-faint);
  }
  .nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
  }
  .nav-close:hover { background: var(--surface-2); color: var(--text); }
  .nav-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

  [data-skin="flat"] .shell-nav { border-radius: 2px; border-width: 1.5px; }
  [data-skin="wechat"] .shell-nav { border-radius: 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
  [data-skin="wechat"] .nav-head { border-bottom-color: var(--line); }
}
