:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  --paper: #f6f1eb;
  --card: #fffcf8;
  --ink: #2d2422;
  --muted: #6c5b55;
  --line: #e7dad0;
  --wine: #6c1d2a;
  --wine-deep: #411721;
  --gold: #b58b61;
  --rose: #efe0df;
  --radius: 22px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--wine); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 23px; height: 23px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.brand-bar {
  grid-row: 1; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; min-height: 66px; padding: 6px max(20px, env(safe-area-inset-right)) 6px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--card); z-index: 1;
}
.wordmark { display: inline-flex; align-items: baseline; gap: 11px; border: 0; background: transparent; padding: 0; min-height: 44px; }
.wordmark span { font: italic 600 clamp(29px, 4vw, 37px)/1.15 Georgia, serif; letter-spacing: -.055em; color: var(--wine); }
.wordmark small { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.icon-button, .avatar-button {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--wine);
}
.icon-button:hover { background: var(--rose); }
.avatar-button { border-color: #dbc9b9; overflow: hidden; }
.avatar-button img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: center 30%; }
#main { grid-row: 2; min-width: 0; overflow: auto; overscroll-behavior: contain; }
#main:focus { outline: none; }
.primary-nav {
  grid-row: 3; z-index: 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--line); padding: 4px 8px max(5px, env(safe-area-inset-bottom));
}
.primary-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; padding: 5px 3px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); font-size: 11px; white-space: nowrap;
}
.primary-nav button[aria-current] { background: var(--rose); color: var(--wine); font-weight: 700; }
.primary-nav button:hover { color: var(--wine); }
.primary-nav .icon { width: 21px; height: 21px; }

.frame { width: min(100%, 1160px); margin: 0 auto; padding: 20px clamp(15px, 4vw, 38px) 32px; }
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  padding: 23px clamp(20px, 4vw, 33px); margin-bottom: 23px; border-radius: var(--radius);
  background: linear-gradient(113deg, var(--wine-deep), #792737);
  color: #fff8ee; box-shadow: 0 10px 25px #4117211c;
}
.hero::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none; width: 245px; height: 245px; right: -83px; top: -74px;
  border: 1px solid #e9c7a950; border-radius: 34% 66% 47% 53%;
  box-shadow: 0 0 0 15px #e9c7a91b, 0 0 0 31px #e9c7a920, 0 0 0 49px #e9c7a922; transform: rotate(-38deg);
}
.hero .overline { color: #f3d7bb; font-size: 11px; letter-spacing: .13em; font-weight: 650; }
.hero h1 { font: 580 clamp(27px, 4vw, 42px)/1.27 "Songti SC", "STSong", Georgia, serif; margin: 6px 0 10px; letter-spacing: .015em; }
.hero p:last-child { color: #f3ded5; font-size: 13px; line-height: 1.55; }
.content-grid { display: grid; gap: 21px; align-items: start; }
.section-head, .page-head, .detail-head, .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.section-head, .page-head { margin: 0 0 12px; }
.page-head h1 { font: 650 clamp(26px, 4vw, 39px)/1.18 "Songti SC", "STSong", Georgia, serif; }
.section-head h2, .context h2 { font-size: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-title { padding: 14px 16px 0; font-size: 16px; }
.filter-group { display: flex; gap: 5px; }
.pill, .action-button {
  min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  padding: 5px 11px; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.pill[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); color: var(--wine); font-weight: 700; }
.action-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 42px; font-weight: 650; color: var(--wine); }
.action-button .icon { width: 18px; height: 18px; }
.action-button.primary { background: var(--wine); border-color: var(--wine); color: white; }
.action-button:hover, .pill:hover { filter: brightness(.96); }

.row {
  width: 100%; min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  min-height: 66px; padding: 11px 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row:hover, .row:focus-visible { background: #f6ece4; }
.row:focus-visible { outline-offset: -2px; }
.row.compact { min-height: 57px; }
.row-mark {
  width: 39px; height: 39px; display: grid; place-items: center; border-radius: 13px; background: #f0e3e1;
  color: var(--wine); font-size: 13px; font-weight: 750;
}
.row-mark[data-tone="gold"] { background: #f1e7d6; color: #724c2d; }
.row-mark[data-tone="stone"] { background: #e8e8df; color: #4d574c; }
.row-mark .icon { width: 20px; height: 20px; }
.row-text { display: grid; gap: 4px; min-width: 0; }
.row-text strong { display: block; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.row-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; line-height: 1.36; }
.row-tail { display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.row-tail .icon { width: 16px; height: 16px; color: #8e756d; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wine); }
.unread .row-text strong { color: var(--wine-deep); }
.aside-panel { display: none; }
.aside-panel .panel + .panel { margin-top: 16px; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.detail-head { justify-content: flex-start; margin-bottom: 15px; }
.detail-head .icon-button { border: 1px solid var(--line); background: var(--card); }
.detail-head h1 { font: 650 clamp(22px, 4vw, 31px)/1.25 "Songti SC", "STSong", Georgia, serif; overflow-wrap: anywhere; }
.detail-head .end { margin-left: auto; }
.detail-card { padding: clamp(17px, 4vw, 29px); }
.detail-card h2 { margin-bottom: 7px; font: 650 24px/1.35 "Songti SC", "STSong", Georgia, serif; }
.detail-card p, .detail-card li { font-size: 14px; line-height: 1.65; color: var(--muted); }
.detail-card p + p, .detail-card .action-button { margin-top: 13px; }
.detail-card .context p { margin-top: 6px; }
.thread-frame { min-height: 100%; display: flex; flex-direction: column; }
.thread { min-height: 320px; flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 18px 14px; }
.message { align-self: flex-start; max-width: min(90%, 540px); min-width: 0; }
.message.own { align-self: flex-end; }
.message small { display: block; margin: 0 4px 4px; color: var(--muted); font-size: 11px; }
.message.own small { text-align: right; }
.message p { padding: 10px 13px; border-radius: 2px 13px 13px; background: #f1e8de; font-size: 14px; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.own p { background: var(--rose); border-radius: 13px 2px 13px 13px; }
.compose { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 9px; margin-top: 10px; background: var(--paper); }
.compose input, .search-field input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--card); padding: 11px 10px; color: var(--ink); }
.compose .action-button { width: 44px; padding: 0; flex: none; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: 0 0 17px; }
.week button { background: var(--card); color: var(--muted); border: 1px solid var(--line); border-radius: 14px; min-width: 0; min-height: 56px; padding: 3px 0; font-size: 11px; }
.week button strong { display: block; font-size: 17px; margin-top: 3px; color: var(--ink); }
.week button[aria-pressed="true"] { background: var(--wine); color: #fff4e6; border-color: var(--wine); }
.week button[aria-pressed="true"] strong { color: white; }
.calendar-controls { display: flex; gap: 4px; align-items: center; margin: 0 0 9px; }
.calendar-controls .icon-button { width: 38px; height: 38px; }
.calendar-controls strong { margin-right: auto; color: var(--muted); font-size: 13px; }

.profile-card { display: grid; grid-template-columns: 1fr; overflow: hidden; }
.profile-identity { padding: clamp(18px, 5vw, 29px); background: linear-gradient(130deg, var(--wine-deep), var(--wine)); color: #fff8ee; }
.profile-identity img { display: block; border-radius: 12px; object-fit: cover; object-position: center 28%; border: 1px solid #e6c5b9; background: #fff; }
.profile-identity h2 { font: 500 35px/1.15 Georgia, serif; margin: 12px 0 7px; }
.profile-identity p { font-size: 14px; color: #f2d6ce; }
.profile-facts { display: grid; align-content: center; gap: 0; margin: 0; padding: 5px 19px; }
.profile-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 1px; border-bottom: 1px solid var(--line); }
.profile-facts div:last-child { border-bottom: 0; }
.profile-facts dt { color: var(--muted); font-size: 13px; }
.profile-facts dd { margin: 0; text-align: end; font-weight: 650; font-size: 14px; }

dialog {
  max-width: min(96%, 570px); width: 100%; padding: 15px; max-height: 78dvh; margin: min(12dvh, 90px) auto auto;
  overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  box-shadow: 0 18px 45px #241a1950;
}
dialog::backdrop { background: #32212075; }
.dialog-head { margin-bottom: 9px; }
.dialog-head h2 { font-size: 19px; }
.search-field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--wine); }
.search-field .icon { width: 20px; height: 20px; }
.status {
  position: fixed; z-index: 2; bottom: calc(72px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 28px); padding: 9px 14px; border-radius: 999px; color: white; background: var(--wine-deep); font-size: 13px;
  pointer-events: none; opacity: 0; transition: opacity .2s ease;
}
.status.visible { opacity: 1; }

@media (min-width: 550px) {
  .profile-card { grid-template-columns: 1fr 1.3fr; }
}
@media (min-width: 860px) {
  .app-shell { grid-template: auto minmax(0, 1fr) / 172px minmax(0, 1fr); }
  .brand-bar { grid-area: 1 / 1 / 2 / 3; padding-inline: 26px; }
  .primary-nav {
    grid-area: 2 / 1 / 3 / 2; display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    padding: 22px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .primary-nav button { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 13px; min-height: 45px; font-size: 14px; }
  #main { grid-area: 2 / 2 / 3 / 3; }
  .frame { padding-top: 27px; }
  .status { bottom: 25px; }
}
@media (min-width: 1050px) {
  .content-grid { grid-template-columns: minmax(0, 1fr) minmax(250px, .59fr); }
  .aside-panel { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
