:root {
  --bg: #f6f7f9;
  --fg: #16181d;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --accent: #2f6fed;
  --shadow: 0 1px 2px rgb(22 24 29 / 0.04), 0 12px 32px rgb(22 24 29 / 0.06);
  --glass: rgb(255 255 255 / 0.72);
  --radius: 18px;
  /* 子站 blog.css 同名变量；「设置」按钮/面板在主站也用，必须在这里定义 */
  --text-2: #5b6472;
  --text-3: #8b93a1;
  --accent-soft: rgb(47 111 237 / 0.09);
  /* 状态语义色（与 blog.css 同名同步；小鼠状态卡用） */
  --ok: #15803d;
  --warn: #b45309;
  --danger: #e5484d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e8eaee;
    --muted: #8b929e;
    --card: #171a20;
    --line: #252a33;
    --accent: #6c9cff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px rgb(0 0 0 / 0.35);
    --glass: rgb(23 26 32 / 0.72);
    --text-2: #8d97a8;
    --text-3: #77808f;
    --accent-soft: rgb(108 156 255 / 0.14);
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #e5484d;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

/* ── 壁纸：轻度模糊掩盖分辨率不足，遮罩保证前景对比度 ── */

/* 壁纸：用背景图而不是 <img>，这样能靠 media query 按视口选图——
   电脑版 1920×1080、手机版 1080×2400，各自只下载一张。
   --wallpaper 由 wallpaper.js 在用户手动锁定时覆盖，默认交给下面的 media query。 */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.wallpaper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--wallpaper, url("/wallpaper-mobile.webp"));
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(1.25) brightness(1.18);
}

@media (min-width: 900px) {
  .wallpaper::before {
    background-image: var(--wallpaper, url("/wallpaper-desktop.webp"));
  }
}

.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(246 247 249 / 0.1) 0%, rgb(246 247 249 / 0.3) 100%);
}

@media (prefers-color-scheme: dark) {
  .wallpaper::before {
    filter: saturate(0.95) brightness(0.62);
  }

  .wallpaper::after {
    background: linear-gradient(180deg, rgb(15 17 21 / 0.3) 0%, rgb(15 17 21 / 0.6) 100%);
  }
}

/* ── 画布与 bento 网格 ───────────────────────────────── */

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-height: 100vh;
  padding: 40px 24px 24px;
}

.bento {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-auto-rows: min-content;
  gap: 16px;
  width: min(100%, 1000px);
}

.tile {
  position: relative;
  padding: 22px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* profile 左上；导航右上与它同高；额度卡第二行跨两列 */
.tile--profile {
  grid-row: 1;
  text-align: center;
}

/* 名片内容由 app.js 渲染进 #profile；居中排布跟着内容走，不跟着卡片 */
#profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.tile--nav {
  grid-row: 1;
  display: flex;
  flex-direction: column;
}

.tile--quota {
  grid-column: 1 / -1;
}

.tile__title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.tile__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tile__head .tile__title {
  margin: 0;
}

/* ── profile 卡 ──────────────────────────────────────── */

.tile--profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile__avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--card);
  box-shadow: 0 6px 20px rgb(22 24 29 / 0.16);
}

.profile__name {
  margin: 14px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.profile__sign {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 500;
}

.profile__place {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.profile__place svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 社交：图标 + 文字的横向胶囊 */
.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.socials a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13px;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.socials a:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}

.socials svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 联系方式：账号类小字，两列排布压紧高度；点一下复制 */
.contacts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  width: 100%;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* 五项时最后一项独占一行，居中 */
.contacts > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
  justify-self: center;
}

.contact {
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease;
}

.contact:hover {
  color: var(--accent);
}

.flag {
  margin-left: 4px;
  color: var(--accent);
  font-size: 11px;
}

/* ── 导航卡：搜索 + 紧凑列表 ─────────────────────────── */

.search {
  position: relative;
  margin-bottom: 10px;
}

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 15px;
  height: 15px;
  margin-top: -7.5px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  font-size: 13px;
}

.search input::placeholder {
  color: var(--muted);
}

.navlist {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* .tile--nav 是纵向 flex 容器：子项默认 min-width:auto 会被长网址撑宽，整页横向溢出。
   统一允许子项收缩，溢出交给各自的 overflow 处理（与 blog.css 的 .sheet > * 同理）；
   右上角的「编辑」是绝对定位的小按钮，按内容宽度，不参与撑满。 */
.tile--nav > *:not(.tile__edit) {
  width: 100%;
  min-width: 0;
}

.navlist__item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.navlist__item:last-child {
  border-bottom: 0;
}

.navlist__item[hidden] {
  display: none;
}

.navlist__link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 0;
  color: inherit;
  text-decoration: none;
}

.navlist__link:hover .navlist__name {
  color: var(--accent);
}

.navlist__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.navlist__icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.navlist__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.navlist__name {
  font-size: 14px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.navlist__desc {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navlist__local {
  flex: none;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  text-decoration: none;
}

.navlist__local:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

/* ── 额度卡：自用数据，视觉降权（无阴影、小字、等宽数字） */

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: start;
  gap: 12px;
}

.quota__loading,
.quota-reason {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.quota-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.quota-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.quota-primary {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.quota-caption,
.quota-row {
  color: var(--muted);
  font-size: 12px;
}

.quota-row {
  display: flex;
  justify-content: space-between;
}

.quota-bar-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.quota-bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

/* A <progress> element, so the fill needs no inline style (the page's CSP blocks those). */
.quota-bar {
  display: block;
  width: 100%;
  height: 4px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  overflow: hidden;
}

/* Chromium/Safari and Firefox each paint the filled part with their own pseudo-element. */
.quota-bar::-webkit-progress-bar {
  background: transparent;
}

/* One pseudo-element per rule: an unknown one makes the browser drop the whole rule. */
.quota-bar::-webkit-progress-value {
  border-radius: inherit;
  background: var(--accent);
}

.quota-bar::-moz-progress-bar {
  border-radius: inherit;
  background: var(--accent);
}

.quota-bar.hot::-webkit-progress-value {
  background: #e5484d;
}

.quota-bar.hot::-moz-progress-bar {
  background: #e5484d;
}

.quota-bar-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.quota-bar-note > span {
  white-space: nowrap;
}

/* ── 底部胶囊：时钟 / 问候 / 天气 ────────────────────── */

.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 10px;
  padding: 8px 16px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.strip__sep {
  opacity: 0.5;
}

/* 页脚的「管理」已去掉：密钥框改为点卡片右上角「编辑」时才弹出（见 .modal） */

/* ── 按钮与输入：与 blog.css 的 .btn / .unlock 同形（胶囊按钮、10px 圆角输入） ── */

[hidden] {
  display: none !important;
}

.btn {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn--ghost {
  background: transparent;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  color: #fff;
  opacity: 0.9;
}

/* 只有图标的按钮：正方形，图标居中 */
.btn--icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
}

.btn--icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 卡片右上角的「编辑」，只有解锁后才出现 */
.tile__edit {
  position: absolute;
  top: 14px;
  right: 14px;
}

.field {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  font-size: 13px;
}

.field::placeholder {
  color: var(--muted);
}

/* ── 名片密钥输入框（模态） ─────────────────────────────
   不常驻页面：点卡片右上角「编辑」、且这个浏览器还没记住密钥时才弹出来。
   形状与 eworker 的弹窗同形（遮罩 + 白卡 + 圆角 18px）。 */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(15 17 21 / 0.45);
  backdrop-filter: blur(4px);
}

.modal__box {
  width: min(100%, 400px);
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal__title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
}

.modal__hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.modal__note {
  margin: 8px 0 0;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* ── 名片与导航的编辑态 ─────────────────────────────── */

.editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
}

.editor__avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.editor__upload {
  cursor: pointer;
}

.editor__field {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.editor__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.editor__legend {
  color: var(--muted);
  font-size: 12px;
}

/* 一行三个控件：图标/名称 + 内容 + 删除；网址这类长字段另起一行占满 */
.editor__row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
}

.editor__row .field--wide {
  grid-column: 1 / -1;
}

.editor__add {
  align-self: flex-start;
}

.editor__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.editor__note {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
}

.navlist__add {
  padding-top: 10px;
}

/* ── 窄屏：单列堆叠 ──────────────────────────────────── */

@media (max-width: 860px) {
  .stage {
    padding: 28px 16px 20px;
  }

  .bento {
    grid-template-columns: 1fr;
  }

  .tile--profile,
  .tile--nav,
  .tile--quota {
    grid-row: auto;
    grid-column: auto;
  }

  /* 窄屏卡片变窄后，编辑行里的图标列再收一点 */
  .editor__row {
    grid-template-columns: 80px minmax(0, 1fr) 30px;
  }

  .tile__edit {
    top: 10px;
    right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .socials a {
    transition: none;
  }

  .socials a:hover {
    transform: none;
  }

  .btn {
    transition: none;
  }
}

/* ── 左下角「设置」：壁纸切换 ─────────────────────────── */

.wall-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.wall-fab svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wall-fab:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.wall-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* 选项列表 */
.wall-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px;
}

.wall-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.wall-option:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.wall-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wall-option input {
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.wall-option__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wall-option__label {
  color: var(--fg);
  font-size: 14px;
}

.wall-option__hint {
  color: var(--text-3);
  font-size: 12px;
}

@media (max-width: 640px) {
  .wall-fab {
    left: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wall-fab,
  .wall-option {
    transition: none;
  }
}