/*
 * V2 外壳：侧栏（≥1024）/ 顶栏 + 底部标签栏（<1024）、页面大标题行。
 * 以及复用的 V1 浮层（数据管理、设置、确认框）在 V2 下的统一外观。
 */

.v2-app { min-height: 100dvh; }
.v2-col { min-width: 0; }

.v2-skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.v2-skip:focus { position: fixed; left: 8px; top: 8px; z-index: 2000; background: var(--surface); padding: 8px 12px; border-radius: var(--r-item); box-shadow: var(--shadow-pop); }

/* ── 主内容 ───────────────────────────────────────────────────────── */

.v2-main {
  display: block;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
  min-width: 0;
}
.v2 #view-home { display: block; margin: 0; padding: 0; }
.v2 #view-home[hidden] { display: none; }

.v2-pagehead__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: var(--gap-block); }
.v2-pagehead__titles { min-width: 0; }
.v2-pagehead__title { font-size: var(--t-title); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
.v2-pagehead__sub { font-size: var(--t-sm); color: var(--text-3); margin-top: 2px; }
.v2-pagehead__actions { display: flex; align-items: center; gap: 8px; flex: none; min-height: 34px; }
.v2-backlink {
  position: relative;
  display: inline-flex; align-items: center; gap: 2px; margin-bottom: 8px;
  font-size: var(--t-sm); font-weight: 500; color: var(--accent);
}
.v2-backlink::after { content: ""; position: absolute; inset: calc((1.4em - max(var(--hit), 1.4em)) / 2) -4px; }
/* 手机上名称可能很长：详情页的操作落到标题下面，不把标题挤成一条窄列 */
@media (max-width: 599px) {
  .v2-pagehead__row:has([data-act="hd-primary"]) { flex-wrap: wrap; gap: 8px; }
  .v2-pagehead__row:has([data-act="hd-primary"]) .v2-pagehead__titles { flex: 1 0 100%; }
}
/* 窄屏的返回在顶栏，标题行不重复。--inline 是页内的返回（路由没有换层级），一直显示 */
@media (max-width: 1023px) { .v2-backlink:not(.v2-backlink--inline) { display: none; } }
.v2-backlink--inline { margin-bottom: 0; }

.v2-page-error { color: var(--text-2); padding: 24px 0; }
.v2-page-loading { display: grid; gap: 16px; }

.v2-footer {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  margin-top: 48px;
  font-size: var(--t-xs); color: var(--text-3);
}
.v2-footer a { position: relative; }
.v2-footer a::after { content: ""; position: absolute; inset: calc((1.4em - max(var(--hit), 1.4em)) / 2) -4px; }
.v2-footer a:hover { color: var(--text-1); }

/* 品牌字标：图形加 17/600，公开页 .brand 同一组值 */
.v2-wordmark { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); text-decoration: none; white-space: nowrap; }
.v2-wordmark__mark { flex: none; display: block; }

/* ── 窄屏：顶栏 + 标签栏（默认） ──────────────────────────────────── */

.v2-sidebar { display: none; }

.v2-topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(246, 245, 241, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  padding-top: env(safe-area-inset-top);
  border-bottom: 0.5px solid transparent;
  transition: border-color var(--motion) var(--ease);
}
.v2-topbar.is-scrolled { border-bottom-color: var(--line); }
.v2-topbar__row {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: var(--topbar-h);
  padding: 0 calc(var(--gutter) - 6px);
}
.v2-topbar__left { flex: 1 1 auto; display: flex; align-items: center; justify-content: flex-start; gap: 4px; min-width: 0; }
.v2-topbar__right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; flex: none; }
.v2-topbar__title {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 50%;
  font-size: var(--t-md); font-weight: 600;
  opacity: 0; transition: opacity var(--motion) var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.v2-topbar.is-scrolled .v2-topbar__title { opacity: 1; }
.v2-topbar__notice { min-width: 0; padding-left: 6px; transition: opacity var(--motion) var(--ease); }
.v2-notice__lead, .v2-notice__link { white-space: nowrap; }
.v2-notice__group { display: inline-block; white-space: nowrap; }
/* 大标题滚走后，顶栏中间要放标题，提示让位 */
.v2-topbar.is-scrolled .v2-topbar__notice { opacity: 0; pointer-events: none; }

.v2-notice { font-size: var(--t-xs); line-height: 1.4; color: var(--text-3); text-wrap: balance; }
@media (max-width: 1023px) {
  .v2-notice__lead { color: var(--text-2); font-weight: 500; }
}
.v2-notice__link { position: relative; color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.v2-notice__link::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: max(var(--hit), 24px); transform: translateY(-50%); }

/* 手机上并排的文字链接点不准：提示条只留第一个动作（试用账本是「注册并保存」，示例账本是「立即试用」），
   其余的（查看示例账本、回到首页）账号菜单里都有。开发指南 6.1「顶部的状态提示」 */
@media (max-width: 599px) {
  .v2-notice__group .v2-notice__link ~ .v2-notice__link,
  .v2-notice > .v2-notice__link ~ .v2-notice__link { display: none; }
}

/* 汇率取不到：外壳说明一句，占位块停止呼吸 */
.v2-shell-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: var(--gap-section); padding: 12px var(--card-pad);
  border-radius: var(--r-card); background: var(--surface);
  font-size: var(--t-sm); color: var(--text-1);
}
.v2-shell-notice p { margin: 0; text-wrap: pretty; }
/* 手机上只包着一句话的卡片去掉（开发指南 6.1「页面的容器」）：这句话直接写在页面上，下面一道细线 */
@media (max-width: 699px) { .v2-shell-notice { padding: 0 0 12px; border-radius: 0; background: none; border-bottom: 0.5px solid var(--line); } }
body[data-v2-fx-unavailable] .v2-ph.is-breathing { animation: none; }

/* 底部标签栏有两种形态，理由见开发指南 6.1「导航」：
   - 在浏览器里贴底通栏。iOS 26 的 Safari 自己的地址栏就是浮在底部的一条，网页再浮一条会叠成两条，中间露出一截页面。
   - 加到主屏幕以后（display-mode: standalone，没有浏览器的栏）用 HIG 现行的形态：浮在内容上面的半透明胶囊，
     内容从它下面滚过去，当前项是胶囊里的一块底色；有底部横条的手机上落在横条上方一点，宽屏不拉满。 */
.v2-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  background: rgba(251, 250, 247, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
}
.v2-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: var(--tabbar-h);
  font-size: var(--t-xs); font-weight: 500; line-height: 1.2; color: var(--text-3);
  -webkit-tap-highlight-color: transparent;
}
/* 选中是「能点的东西的当前状态」：蓝色。第二轮改成灰的决定作废，理由见设计理由清单第三轮 V 小节 */
.v2-tab.is-on { color: var(--accent); }
/* 当前项除了变色还有一块圆角底色，两种形态共用：通栏时是项里的一块，胶囊时填满这一项 */
.v2-tab { position: relative; z-index: 0; }
.v2-tab::before { content: ""; position: absolute; z-index: -1; inset: 4px 8px; border-radius: 14px; background: transparent; transition: background var(--motion) var(--ease); }
.v2-tab.is-on::before { background: var(--accent-lt); }
@media (display-mode: standalone) {
  :root { --tabbar-h: 72px; }
  .v2-tabbar {
    left: 50%; right: auto; transform: translateX(-50%);
    width: min(calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)), 460px);
    bottom: max(8px, calc(env(safe-area-inset-bottom) - 8px));
    padding: 4px; border-radius: 999px; border-top: 0;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
    box-shadow: 0 0 0 0.5px var(--line), 0 8px 28px rgba(60, 50, 30, 0.14);
  }
  .v2-tab { min-height: 48px; }
  .v2-tab::before { inset: 0; border-radius: 999px; }
}
.v2-navicon { position: relative; display: inline-flex; flex: none; }
/* 总览上「要做的事」的数量。手机压在图标右上角，侧栏靠行尾。橙色 = 需要处理；不用红色，红色可能表示涨 */
.v2-navbadge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--warn); color: #fff;
  font-size: var(--t-xs); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.v2-navbadge[hidden] { display: none; }
.v2-tab .v2-navbadge { position: absolute; top: -4px; left: 16px; box-shadow: 0 0 0 1.5px var(--bg-page); }
.v2-nav__item .v2-navbadge { margin-left: auto; }
.v2-tab:hover { color: var(--text-1); }
.v2-tab.is-on:hover { color: var(--accent); }

/* 底部多留一条提示的高度（40 + 上下 16）：提示条浮在标签栏上方，不能盖住最后一行 */
.v2-main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 72px); padding-top: 4px; }
.v2-toast-root { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }

.v2-avatar {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--accent-lt); color: var(--accent);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.v2-avatar::after { content: ""; position: absolute; inset: calc((32px - max(var(--hit), 32px)) / 2); border-radius: 50%; }
.v2-avatar:hover, .v2-avatar[aria-expanded="true"] { background: var(--accent-lt-2); }
.v2-avatar.has-dot::before {
  content: ""; position: absolute; top: 0; right: 0; width: 8px; height: 8px;
  border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--bg-page);
}

/* ── 宽屏：侧栏 ───────────────────────────────────────────────────── */

@media (min-width: 1024px) {
  .v2-app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .v2-topbar, .v2-tabbar { display: none; }
  .v2-main { padding-top: 32px; padding-bottom: 48px; }
  .v2-toast-root { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); }

  .v2-sidebar {
    position: sticky; top: 0; height: 100dvh;
    display: flex; flex-direction: column;
    padding: 24px 12px 16px;
    background: var(--bg-page);
    border-right: 0.5px solid var(--line);
  }
  .v2-sidebar .v2-wordmark { padding: 0 12px; margin-bottom: 16px; }
  .v2-nav { display: flex; flex-direction: column; gap: 2px; }
  .v2-nav__item {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 12px; border-radius: 10px;
    font-size: var(--t-md); font-weight: 500; color: var(--text-2);
    transition: background var(--motion) var(--ease), color var(--motion) var(--ease);
  }
  .v2-nav__item:hover { background: var(--fill-1); color: var(--text-1); }
  .v2-nav__item.is-on { background: var(--accent-lt); color: var(--accent); font-weight: 600; }
  .v2-sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
  .v2-sidebar .v2-notice { padding: 0 8px; }
  .v2-statusline {
    position: relative;
    display: flex; align-items: baseline; gap: 6px;
    width: 100%; padding: 4px 8px; border: 0; border-radius: var(--r-item);
    background: transparent; text-align: left;
    font-size: var(--t-xs); line-height: 1.4; color: var(--text-3); cursor: pointer;
    font-variant-numeric: tabular-nums;
  }
  .v2-statusline:hover { background: var(--fill-1); color: var(--text-1); }
  .v2-statusline.has-trouble { color: var(--warn); }
  .v2-statusline__dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--warn); align-self: center; }
  .v2-sidebar__actions { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 0; }
}
/* 宽屏 iPad：侧栏同样是手指操作 */
@media (min-width: 1024px) and (pointer: coarse) {
  .v2-nav__item { height: 44px; }
  .v2-sidebar .v2-wordmark { min-height: 44px; display: flex; margin-bottom: 12px; }
  .v2-statusline { min-height: 44px; align-items: center; }
}

/* ── 状态详情 ─────────────────────────────────────────────────────── */

.v2-status-detail { min-width: 240px; font-size: var(--t-sm); }
.v2-status-detail__row { display: grid; grid-template-columns: 5em 1fr; gap: 8px; padding: 3px 0; }
.v2-status-detail__row dt { color: var(--text-3); }
.v2-status-detail__row dd { color: var(--text-1); overflow-wrap: anywhere; }
.v2-status-detail__row.is-warn dd { color: var(--warn); }
.v2-status-detail__actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── 加载与错误页 ─────────────────────────────────────────────────── */

.v2 #app-loading { display: none; }
.v2 #app-error { padding: 48px 0; }
.v2 #app-error .card { background: var(--surface); border-radius: var(--r-card); padding: var(--card-pad); max-width: 560px; }

