* {
  box-sizing: border-box;
}

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

body {
  background: #f4f3f0;
  color: #20201f;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}


/* =========================
   整体
   ========================= */

.home-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;

  margin: 0 auto;

  padding:
    calc(22px + env(safe-area-inset-top))
    0
    calc(24px + env(safe-area-inset-bottom));
}


/* =========================
   顶部
   ========================= */

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 22px;

  margin-bottom: 24px;
}

.home-eyebrow {
  margin: 0 0 3px;

  color: #989892;

  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.home-header h1 {
  margin: 0;

  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.home-avatar {
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #deddd8;

  color: #555550;

  font-size: 14px;
  font-weight: 600;
}


/* =========================
   横向桌面
   ========================= */

.desktop-pages {
  display: flex;

  width: 100%;

  overflow-x: auto;
  overflow-y: hidden;

  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

  scrollbar-width: none;
}

.desktop-pages::-webkit-scrollbar {
  display: none;
}

.desktop-page {
  flex: 0 0 100%;

  /*
    非常重要：
    防止里面的横向 Widget 把整个桌面页撑宽
  */
  width: 100%;
  min-width: 0;

  scroll-snap-align: start;
  scroll-snap-stop: always;

  padding: 0 22px 20px;

  min-height: 650px;
}


/* =========================
   日历小组件
   ========================= */

.calendar-widget {
  padding: 20px 17px 18px;

  margin-bottom: 26px;

  background: #ffffff;

  border: 1px solid #e7e6e1;
  border-radius: 24px;

  box-shadow:
    0 8px 28px rgba(30, 30, 30, 0.035);
}

.calendar-title {
  text-align: center;

  margin-bottom: 17px;
}

.calendar-title strong {
  font-size: 20px;
  font-weight: 600;
}

.calendar-week,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);

  text-align: center;
}

.calendar-week {
  margin-bottom: 9px;

  color: #9b9a94;

  font-size: 11px;
}

.calendar-grid {
  row-gap: 7px;

  font-size: 12px;
  font-weight: 500;
}

.calendar-grid > span {
  min-height: 31px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 1px;
}

.calendar-day.today b {
  width: 26px;
  height: 26px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #2f302e;
  color: #ffffff;

  font-size: 12px;
}

.calendar-day.today small {
  color: #9a9a95;

  font-size: 5px;
  letter-spacing: 2px;
}


/* =========================
   App 网格
   ========================= */

.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);

  column-gap: 11px;
  row-gap: 22px;
}

.app-grid.large-gap {
  margin-top: 36px;

  row-gap: 34px;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 8px;

  text-align: center;
}

.app-icon {
  width: 58px;
  height: 58px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 17px;

  border: 1px solid rgba(0, 0, 0, 0.035);

  font-size: 21px;
  font-weight: 500;

  box-shadow:
    0 5px 14px rgba(20, 20, 20, 0.035);
}

.app-item > span {
  max-width: 80px;

  color: #555550;

  font-size: 11px;
  line-height: 1.3;
}


/* App 暂定配色 */

.chat-icon {
  background: #dce9df;
}

.moments-icon {
  background: #e2e5f0;
}

.signal-icon {
  background: #e9e2db;
}

.tarot-icon {
  background: #e8e1ed;
}

.diary-icon {
  background: #e9e5d8;
}

.mail-icon {
  background: #e1e7eb;
}

.timeline-icon {
  background: #e4e1dd;
}

.music-icon {
  background: #eadfe1;
}

.wallet-icon {
  background: #e4eadf;
}

.shop-icon {
  background: #e8e1d8;
}

.library-icon {
  background: #e0e6e5;
}

.search-icon {
  background: #e6e3df;
}

.backup-icon {
  background: #dfe4e9;
}

.settings-icon {
  background: #e4e4e1;
}


/* =========================
   页面标题
   ========================= */

.page-heading {
  margin-top: 22px;
}

.page-heading small {
  color: #a1a09a;

  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.page-heading h2 {
  margin: 5px 0 0;

  font-size: 24px;
  font-weight: 600;
}


/* =========================
   底部分页点
   ========================= */

.desktop-dots {
  display: flex;
  justify-content: center;

  gap: 6px;

  padding-top: 8px;
}

.dot {
  width: 5px;
  height: 5px;

  border-radius: 50%;

  background: #c9c8c2;
}

.dot.active {
  width: 6px;
  height: 6px;

  background: #666660;
}


/* =========================
   电脑预览
   ========================= */

@media (min-width: 700px) {
  .home-shell {
    padding-top: 48px;
  }
}

/* =========================
   Home 2.0 分组
   ========================= */

.home-app-group {
  margin-bottom: 27px;
}

.group-heading {
  display: flex;
  flex-direction: column;

  gap: 3px;

  padding: 0 4px;
  margin-bottom: 14px;
}

.group-heading span {
  color: #aaa79f;

  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.group-heading strong {
  color: #55534e;

  font-size: 11px;
  font-weight: 600;
}


/* 分组以后稍微收紧 App 间距 */

.home-app-group .app-grid {
  row-gap: 19px;
}


/* 三个金融 App 不需要强行撑满四个 */

.finance-grid {
  grid-template-columns: repeat(4, 1fr);
}


/* 系统区只有两个 App，也保持和其他图标同样宽度 */

.system-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* =========================
   Home Widget Carousel
   ========================= */

.home-widget-section {
  width: 100%;
  min-width: 0;
  max-width: 100%;

  overflow: hidden;

  margin-bottom: 24px;
}

.home-widget-track {
  display: flex;

  width: 100%;
  min-width: 0;
  max-width: 100%;

  overflow-x: auto;
  overflow-y: hidden;

  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

  overscroll-behavior-x: contain;

  scrollbar-width: none;

  border-radius: 24px;
}

.home-widget-track::-webkit-scrollbar {
  display: none;
}


/* 单张 Widget */

.home-widget-card {
  flex: 0 0 100%;

  width: 100%;
min-width: 100%;

  box-sizing: border-box;

  min-height: 310px;

  padding: 23px 22px 20px;

  border: 1px solid rgba(60, 58, 53, 0.07);
  border-radius: 24px;

  background:
    rgba(255, 255, 255, 0.72);

  backdrop-filter: blur(18px);

  scroll-snap-align: start;
}


/* 顶部 */

.widget-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;

  margin-bottom: 22px;
}

.widget-eyebrow {
  display: block;

  margin-bottom: 5px;

  color: #aaa69e;

  font-size: 8px;
  font-weight: 700;

  letter-spacing: 0.18em;
}

.widget-topline h2 {
  margin: 0;

  color: #3f3e3a;

  font-size: 22px;
  font-weight: 600;
}

.widget-date-number {
  color: #3f3e3a;

  font-size: 37px;
  font-weight: 300;

  line-height: 1;
}

.widget-symbol {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  border-radius: 50%;

  background: rgba(80, 78, 72, 0.055);

  color: #6b6963;

  font-size: 18px;
}


/* Calendar */

.mini-calendar {
  width: 100%;
}

.calendar-week,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);

  text-align: center;
}

.calendar-week {
  margin-bottom: 8px;

  color: #aaa79f;

  font-size: 9px;
}

.calendar-days {
  row-gap: 6px;

  color: #57554f;

  font-size: 10px;
}

.calendar-days span {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 26px;
  height: 26px;

  margin: auto;

  border-radius: 50%;
}

.calendar-days .muted {
  color: #ccc9c1;
}

.calendar-days .today {
  background: #55534d;
  color: white;
}


/* 通用底部 */

.widget-footer-line {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-top: 17px;
  padding-top: 14px;

  border-top:
    1px solid rgba(70, 68, 62, 0.07);

  font-size: 9px;
}

.widget-footer-line span {
  color: #aaa69e;
}

.widget-footer-line strong {
  color: #66635d;

  font-weight: 500;
}


/* Cycle */

.widget-feature {
  display: flex;
  flex-direction: column;

  margin: 30px 0 30px;
}

.feature-label {
  margin-bottom: 5px;

  color: #aaa69e;

  font-size: 8px;
  letter-spacing: 0.15em;
}

.feature-big {
  color: #484641;

  font-size: 34px;
  font-weight: 400;
}

.feature-sub {
  margin-top: 5px;

  color: #99968f;

  font-size: 10px;
}

.widget-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 10px;
}

.widget-info-grid > div {
  padding: 12px;

  border-radius: 15px;

  background:
    rgba(80, 77, 70, 0.045);
}

.widget-info-grid span,
.body-status-list span {
  display: block;

  margin-bottom: 4px;

  color: #aaa69e;

  font-size: 8px;
}

.widget-info-grid strong {
  color: #5d5a55;

  font-size: 10px;
  font-weight: 500;
}


/* Sleep */

.sleep-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  margin: 29px 0 32px;
}

.sleep-main strong {
  color: #45433f;

  font-size: 39px;
  font-weight: 300;
}

.sleep-main small {
  color: #8c8982;

  font-size: 12px;
  font-weight: 400;
}

.sleep-main > span {
  margin-bottom: 7px;

  color: #8f8c85;

  font-size: 10px;
}

.sleep-line {
  display: flex;
  align-items: center;

  padding: 14px 0;
}

.sleep-line > div:not(.sleep-line-rule) {
  flex: 0 0 70px;
}

.sleep-line span {
  display: block;

  color: #aaa69e;

  font-size: 8px;
}

.sleep-line strong {
  color: #595751;

  font-size: 11px;
  font-weight: 500;
}

.sleep-line-rule {
  flex: 1;

  height: 1px;

  margin: 0 14px;

  background:
    rgba(80, 78, 72, 0.1);
}


/* Body */

.body-status-list {
  display: flex;
  flex-direction: column;

  gap: 10px;
}

.body-status-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: 43px;

  padding: 0 13px;

  border-radius: 14px;

  background:
    rgba(80, 77, 70, 0.04);
}

.body-status-list span {
  margin: 0;
}

.body-status-list strong {
  color: #625f59;

  font-size: 10px;
  font-weight: 500;
}

.status-dots {
  display: flex;

  gap: 4px;
}

.status-dots i {
  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: #ddd9d0;
}

.status-dots i.active {
  background: #78756e;
}


/* Intimacy */

.intimacy-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 155px;

  text-align: center;
}

.intimacy-center > span {
  color: #aaa69e;

  font-size: 8px;
  letter-spacing: 0.12em;
}

.intimacy-center strong {
  margin: 8px 0 19px;

  color: #55534e;

  font-size: 15px;
  font-weight: 500;
}

.intimacy-center button {
  padding: 9px 15px;

  border: 0;
  border-radius: 14px;

  background:
    rgba(80, 77, 70, 0.065);

  color: #69665f;

  font-size: 9px;

  cursor: pointer;
}


/* Widget 分页圆点 */

.home-widget-dots {
  display: flex;
  justify-content: center;

  gap: 6px;

  margin-top: 11px;
}

.home-widget-dots button {
  width: 5px;
  height: 5px;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: #d4d1ca;

  transition:
    width 0.2s ease,
    background 0.2s ease;
}

.home-widget-dots button.active {
  width: 16px;

  border-radius: 999px;

  background: #77746e;
}

.odds-icon {
  background: #e7e1e8;
}

.app-link {
  color: inherit;
  text-decoration: none;

  cursor: pointer;
  pointer-events: auto;

  touch-action: manipulation;
  -webkit-tap-highlight-color:
    transparent;
}

.companion-icon {
  background: #e5e3eb;
}


/* =========================
   Mobile · Phase 1
   ========================= */

@media (max-width: 767px) {

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .home-shell {
    min-height: 100dvh;
    overflow-x: clip;
  }

  .home-header {
    padding-right:
      max(16px, env(safe-area-inset-right));
    padding-left:
      max(16px, env(safe-area-inset-left));
  }

  .desktop-pages,
  .home-widget-track {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .desktop-page {
    padding-right:
      max(16px, env(safe-area-inset-right));
    padding-left:
      max(16px, env(safe-area-inset-left));
  }

  .app-grid,
  .finance-grid,
  .system-grid {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
    column-gap: 8px;
  }

  .app-item {
    min-width: 0;
    min-height: 88px;
    overflow-wrap: anywhere;
  }

  .home-widget-card {
    max-width: 100%;
    min-width: 100%;
  }

  .widget-topline,
  .sleep-main,
  .widget-footer-line {
    min-width: 0;
  }

  .widget-topline > *,
  .sleep-main > *,
  .widget-footer-line > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .intimacy-center button {
    min-height: 44px;
    padding-right: 18px;
    padding-left: 18px;
  }

}


@media (max-width: 374px) {

  .home-header,
  .desktop-page {
    padding-right:
      max(14px, env(safe-area-inset-right));
    padding-left:
      max(14px, env(safe-area-inset-left));
  }

  .home-widget-card {
    padding-right: 17px;
    padding-left: 17px;
  }

  .app-icon {
    width: 54px;
    height: 54px;
  }

}
