/* 外壳：菜单栏、舞台、窗口、程序坞、小组件、提示卡、伪装层、手机布局 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.55 var(--font);
  color: var(--text);
  background: #0E0F12;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 0 5px;
  border: 1px solid var(--outline); border-radius: 4px;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px;
}
svg { flex: none; }

.app { position: fixed; inset: 0; overflow: hidden; color: var(--text); }
.wallpaper { position: absolute; inset: 0; background-color: #14171F; }

/* ---------- 菜单栏 ---------- */
.menubar {
  position: absolute; top: 0; left: 0; right: 0; height: 34px; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; z-index: 30;
  background: var(--bar); color: var(--bar-text); font-size: 13px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--bar-line);
}
.menubar a { color: inherit; text-decoration: none; }
.menubar__brand { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.menubar__current { font-weight: 700; white-space: nowrap; }
.menubar__nav { display: flex; gap: 16px; }
.menubar__nav a { color: var(--bar-muted); padding: 2px 0; border-radius: 4px; }
.menubar__nav a:hover { color: var(--bar-text); }
.menubar__nav a[aria-current="page"] { color: var(--bar-text); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1.5px; }
.menubar__spacer { flex: 1 1 0; }
.menubar__icon-btn {
  width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent;
  color: var(--bar-muted); display: flex; align-items: center; justify-content: center;
}
.menubar__icon-btn:hover { background: var(--sel); color: var(--bar-text); }
.coach-pill {
  display: flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px;
  border: 1px solid var(--good-line); background: var(--good-bg); color: var(--good);
  font-size: 12px; white-space: nowrap;
}
.coach-pill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good-dot); }
.menubar__clock { color: var(--bar-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- 舞台 ---------- */
.stage { position: absolute; top: 34px; left: 0; right: 0; bottom: 0; }
.desktop { position: absolute; inset: 0; }
.desktop__scroll {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  padding: 26px 56px 140px;
}
.widgets {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: 170px;
  grid-auto-flow: dense; gap: 16px; max-width: 1328px;
}
.m-only { display: none; }

/* ---------- 窗口 ---------- */
.win {
  position: absolute; top: 18px; bottom: 112px; left: 56px; right: 56px;
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden;
  background: rgba(var(--win-rgb), var(--win-a));
  -webkit-backdrop-filter: blur(28px) saturate(1.2); backdrop-filter: blur(28px) saturate(1.2);
  border: 1px solid var(--win-line); box-shadow: var(--win-shadow);
  animation: win-in 0.18s ease-out;
}
@keyframes win-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.win__bar {
  flex: 0 0 46px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line);
}
.win__left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.win__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dot); flex: none; }
.win__back {
  margin-left: 12px; font-size: 13px; color: var(--text2); text-decoration: none;
  padding: 4px 6px; border-radius: 6px; white-space: nowrap;
}
.win__back:hover { background: var(--sel); color: var(--text); }
.win__title { font-size: 13px; font-weight: 500; color: var(--text2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win__right { display: flex; justify-content: flex-end; }
.win__body { flex: 1 1 auto; min-height: 0; overflow: auto; }

/* ---------- 小组件 ---------- */
.widget {
  min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 18px;
  background: var(--widget); border: 1px solid var(--widget-line); box-shadow: var(--widget-shadow);
  -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2);
}
.w-s { grid-column: span 1; }
.w-m { grid-column: span 2; }
.w-l { grid-column: span 2; grid-row: span 2; }
.w-l3 { grid-column: span 3; grid-row: span 2; }
.widget__src { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
.widget__src a { margin-left: auto; color: var(--text2); text-decoration: none; }
.widget__src a:hover { text-decoration: underline; }
.widget__big { font-size: 30px; font-weight: 900; line-height: 1.2; font-variant-numeric: tabular-nums; }
.widget__foot { margin-top: auto; font-size: 12px; color: var(--text2); }
.widget__foot a { text-decoration: none; }
.widget__foot a:hover { text-decoration: underline; }
.widget__empty { font-size: 13px; color: var(--muted); margin: auto 0; }

.btn {
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font-size: 13px; font-weight: 700;
  text-decoration: none; background: var(--pri); color: var(--pri-text); cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(0.94); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--outline); font-weight: 400; }
.btn--ghost:hover { background: var(--sel); filter: none; }
.btn--quiet { background: transparent; color: var(--muted); border: 0; font-weight: 400; padding: 0 8px; }
.btn--quiet:hover { color: var(--text); filter: none; }
.btn--sm { min-height: 30px; padding: 0 12px; font-size: 12px; }

/* 助手 */
.assistant { gap: 12px; }
.assistant__hello { font-size: 26px; font-weight: 900; line-height: 1.3; }
.assistant__sub { margin-top: 2px; color: var(--text2); }
.assistant__form {
  padding: 12px 10px 10px 16px; border-radius: 14px; background: var(--field);
  border: 1px solid var(--field-line); display: flex; flex-direction: column; gap: 8px;
}
.assistant__form:focus-within { border-color: var(--outline); }
.assistant__input {
  border: 0; outline: none; resize: none; padding: 0; background: transparent;
  color: var(--text); font-size: 15px; line-height: 1.5; width: 100%;
}
.assistant__input::placeholder { color: var(--muted); }
.assistant__row { display: flex; align-items: center; gap: 8px; }
.assistant__msg { flex: 1 1 0; min-width: 0; font-size: 12px; color: var(--muted); }
.assistant__send {
  width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--pri); color: var(--pri-text);
  display: flex; align-items: center; justify-content: center;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 3px 12px; border-radius: 999px; background: var(--sel); border: 0;
  color: var(--text); font-size: 13px; text-decoration: none; cursor: pointer;
}
.chip:hover { background: var(--outline); }

/* 老板键状态 */
.boss-status__key { font-size: 30px; font-weight: 900; line-height: 1.2; }
.boss-status__ok { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--good); }
.dot-ok { width: 7px; height: 7px; border-radius: 50%; background: var(--good-dot); flex: none; }

/* 天梯 */
.ladder { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ladder li {
  display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.ladder__rank { width: 16px; font-weight: 700; color: var(--muted); }
.ladder__avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; background: var(--sel);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.ladder__who { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.ladder__who > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ladder__status { font-size: 11px; }
.st-playing { color: var(--good); }
.st-hosted { color: var(--warn); }
.st-pulse { color: var(--info); }
.st-offline { color: var(--muted); }
.ladder__me {
  margin-top: auto; padding: 8px 10px; border-radius: 10px; background: var(--sel);
  display: flex; gap: 10px; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.ladder__me span:nth-child(2) { flex: 1 1 0; }

/* 应用提供的小组件 */
.daily { flex: 1 1 auto; display: flex; gap: 14px; align-items: center; min-height: 0; }
.daily__cover { width: 96px; height: 96px; flex: 0 0 96px; border-radius: 10px; object-fit: cover; display: block; background: var(--sel); }
.daily__cover--ph { display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 900; color: var(--muted); }
.daily__info { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.daily__info h2 { font-size: 15px; font-weight: 700; }
.daily__ai { font-size: 13px; color: var(--text2); }
.daily__time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; background: var(--pri); }

.agent { flex: 1 1 auto; display: flex; align-items: center; gap: 14px; min-height: 0; }
.agent__tile {
  width: 56px; height: 56px; flex: 0 0 56px; border-radius: 14px; background: var(--pulse-tile); color: var(--pulse-fg);
  display: flex; align-items: center; justify-content: center;
}
.agent__info { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.agent__info h2 { font-size: 15px; font-weight: 700; }
.agent__info span { font-size: 13px; color: var(--text2); }

.recent { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; border-radius: 10px; }
.recent__icon { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 10px; object-fit: cover; object-position: center 30%; display: block; }
.recent__name { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__time { font-size: 12px; color: var(--muted); }
.recent > span { min-width: 0; display: flex; flex-direction: column; }

/* 通用图标方块（程序坞 / 手机图标） */
.tile {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--tile); color: var(--text); font-weight: 900; overflow: hidden; position: relative;
}
.tile img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.tile--pri { background: var(--pri); color: var(--pri-text); }
.tile--pulse { background: var(--pulse-tile); color: var(--pulse-fg); }
.tile--glyph { background: #2A3340; color: rgba(255, 255, 255, 0.75); }

/* 桌面左下角按钮 */
.desk-appearance {
  position: absolute; left: 56px; bottom: 28px; z-index: 5;
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 12px;
  background: var(--widget); border: 1px solid var(--widget-line); color: var(--text);
  text-decoration: none; font-size: 13px; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.desk-appearance:hover { background: var(--sel); }

/* ---------- 程序坞 ---------- */
.dock-wrap {
  position: absolute; left: 0; right: 0; bottom: 6px; z-index: 20;
  display: flex; justify-content: center; pointer-events: none; padding: 0 8px;
}
.dock {
  pointer-events: auto; max-width: 100%; display: flex; align-items: flex-end; gap: 4px;
  padding: 8px 10px 6px; border-radius: 22px; background: var(--dock);
  -webkit-backdrop-filter: blur(24px) saturate(1.3); backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--dock-line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.dock__item {
  position: relative; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text); text-decoration: none; border-radius: 12px; outline-offset: 2px;
}
.dock__icon { position: relative; width: 48px; height: 48px; transition: transform 0.15s ease; }
.dock__item:hover .dock__icon, .dock__item:focus-visible .dock__icon { transform: translateY(-3px); }
.dock__label {
  max-width: 66px; font-size: 11px; line-height: 1.3; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-dock-labels="off"] .dock__label { display: none; }
.dock__dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.dock__item[aria-current="page"] .dock__dot { background: var(--text); }
.dock__sep { width: 1px; height: 44px; margin: 0 6px 22px; background: var(--sep-line); }
html[data-dock-labels="off"] .dock__sep { margin-bottom: 10px; }
.dock__badge {
  position: absolute; top: -4px; right: -6px; padding: 0 5px; border-radius: 999px;
  background: var(--good-solid); color: var(--good-solid-text); font-size: 10px; font-weight: 700;
  line-height: 16px; box-shadow: 0 0 0 2px var(--badge-ring);
}
.dock__tip {
  display: none; position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  flex-direction: column; align-items: center; gap: 1px; padding: 7px 12px; border-radius: 10px;
  background: var(--tip-bg); color: var(--tip-text); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  white-space: nowrap; font-size: 12px; line-height: 1.45; z-index: 3; pointer-events: none;
}
.dock__tip b { font-weight: 700; }
.dock__tip span { opacity: 0.78; }
.dock__tip::after {
  content: ""; position: absolute; bottom: -5px; left: 50%; width: 10px; height: 10px; margin-left: -5px;
  background: var(--tip-bg); transform: rotate(45deg);
}
.dock__item:hover .dock__tip, .dock__item:focus-visible .dock__tip { display: flex; }

/* ---------- 新手提示卡 ---------- */
.coach {
  position: absolute; top: 44px; left: 0; width: 330px; max-width: calc(100vw - 16px); z-index: 60;
  padding: 16px 18px; border-radius: 14px; background: #FFFFFF; color: #111113;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 8px;
}
.coach:not([hidden]) { animation: win-in 0.16s ease-out; }
.coach__arrow { position: absolute; top: -6px; left: 140px; width: 12px; height: 12px; background: #FFFFFF; transform: rotate(45deg); }
.coach__top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #55555C; }
.coach__next { border: 0; background: transparent; color: #3A3A3C; font-size: 12px; padding: 2px 4px; border-radius: 4px; }
.coach__next:hover { color: #111113; text-decoration: underline; }
.coach h2 { font-size: 16px; font-weight: 900; }
.coach p { font-size: 13px; line-height: 1.6; color: #3A3A3C; }
.coach kbd { color: #111113; border-color: #C7C7CC; }
.coach__actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.coach .btn { background: #111113; color: #fff; }
.coach .btn--ghost { background: transparent; color: #111113; border-color: #D4D4D8; }
.coach .btn--quiet { background: transparent; color: #55555C; margin-left: auto; }
.coach :focus-visible { outline-color: #1D4ED8; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, 0.45);
}
.modal__card {
  width: 380px; max-width: 100%; padding: 22px 24px; border-radius: 18px; background: var(--sheet);
  color: var(--text); border: 1px solid var(--win-line); box-shadow: var(--sheet-shadow);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  display: flex; flex-direction: column; gap: 14px;
}
.modal__card h2 { font-size: 20px; font-weight: 900; }
.modal__x { position: absolute; }

/* ---------- 伪装层容器（模板样式在 disguise.css） ---------- */
.boss-layer { position: fixed; inset: 0; z-index: 9999; background: #fff; color: #222; overflow: hidden; font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif; }

/* ---------- 减少动效 ---------- */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation: none !important; transition: none !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .win, .coach:not([hidden]) { animation: none; }
  .dock__icon { transition: none; }
}

/* ---------- 窄桌面 ---------- */
@media (max-width: 1100px) and (min-width: 768px) {
  .widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .w-l3 { grid-column: span 4; }
  .desktop__scroll { padding-left: 24px; padding-right: 24px; }
  .win { left: 24px; right: 24px; }
  .desk-appearance { left: 24px; bottom: 112px; }
}
@media (max-height: 760px) and (min-width: 768px) {
  .desk-appearance { display: none; }
}

/* ---------- 手机 ---------- */
@media (max-width: 767px) {
  body { overflow: hidden; }
  .menubar { display: none; }
  .m-only { display: flex; }
  .d-only { display: none !important; }
  .stage { top: 0; }
  .desktop__scroll {
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(130px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 14px;
  }
  .desk-appearance { display: none; }

  .m-header { align-items: center; gap: 8px; }
  .m-brand {
    flex: 1 1 auto; display: flex; align-items: center; gap: 6px; color: var(--on-wall);
    text-decoration: none; font-weight: 900; font-size: 18px; text-shadow: var(--on-wall-shadow);
  }
  .m-round {
    width: 44px; height: 44px; border: 1px solid var(--widget-line); border-radius: 50%;
    background: var(--widget); color: var(--text); display: flex; align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  }
  .m-hide {
    height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: var(--pri); color: var(--pri-text);
    display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px;
  }
  .m-ask {
    height: 46px; padding: 0 16px; border-radius: 23px; background: var(--widget); border: 1px solid var(--widget-line);
    align-items: center; gap: 10px; color: var(--muted); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  }
  .m-ask input { flex: 1 1 auto; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--text); }
  .m-ask input::placeholder { color: var(--muted); }
  .m-ask:focus-within { border-color: var(--outline); }

  .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 150px; gap: 12px; max-width: none; }
  .widgets .w-m, .widgets .w-l, .widgets .w-l3 { grid-column: span 2; grid-row: span 1; }
  .widget { border-radius: 20px; padding: 12px 14px; }
  .w-hide-m { display: none; }
  .daily__cover { width: 80px; height: 80px; flex-basis: 80px; }

  .m-apps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; padding-top: 6px; }
  .m-app { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; border-radius: 12px; }
  .m-app .tile { width: 58px; height: 58px; border-radius: 15px; font-size: 20px; border: 1px solid var(--widget-line); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
  .m-app .tile--add { background: transparent; color: var(--on-wall); border: 1.5px dashed var(--on-wall-dash); box-shadow: none; }
  .m-app__name { font-size: 11px; color: var(--on-wall); text-shadow: var(--on-wall-shadow); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .dock-wrap { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); padding: 0; }
  .dock {
    width: 100%; height: 96px; padding: 0 18px; border-radius: 30px; align-items: center; justify-content: space-between; gap: 0;
  }
  .dock__item { width: 64px; gap: 4px; }
  .dock__icon, .dock .tile { width: 52px; height: 52px; border-radius: 14px; }
  .dock__icon { transform: none !important; }
  .dock__label { display: block !important; font-size: 11px; color: var(--text2); max-width: 64px; }
  .dock__dot, .dock__sep, .dock__tip { display: none !important; }
  .dock__item[data-m="0"] { display: none; }
  .dock__badge { display: none; }
  .dock__tip { display: none !important; }

  /* 打开任何页面：全屏，顶部有返回 */
  .app[data-view="window"] .dock-wrap { display: none; }
  .win { position: fixed; inset: 0; border-radius: 0; border: 0; animation: none; background: rgba(var(--win-rgb), 0.97); }
  .win__bar { padding: calc(env(safe-area-inset-top)) 12px 0; flex-basis: calc(52px + env(safe-area-inset-top)); }
  .win__dot { display: none; }
  .win__back { margin-left: 0; padding: 10px 10px; font-size: 15px; }
  .win__boss { display: flex !important; }

  .coach { position: fixed; top: calc(72px + env(safe-area-inset-top)); left: 16px !important; right: 16px; width: auto; max-width: none; }
  .coach__arrow { display: none; }
}
.win__boss {
  display: none; height: 34px; padding: 0 12px; border: 0; border-radius: 17px; background: var(--pri); color: var(--pri-text);
  align-items: center; gap: 4px; font-size: 13px; font-weight: 700;
}
