:root {
  color-scheme: light;
  --bg: #e9eee6;
  --app: #f7f8f4;
  --surface: #ffffff;
  --soft: #eef4ec;
  --ink: #17201a;
  --muted: #65706a;
  --line: #dce4d9;
  --green: #188b5b;
  --green-soft: #e3f5eb;
  --coral: #df6d50;
  --coral-soft: #ffebe6;
  --gold: #c9942e;
  --gold-soft: #fff4d8;
  --control: #ffffff;
  --active-surface: #ffffff;
  --chart-bg: #fbfcfa;
  --header-bg: rgba(247, 248, 244, 0.94);
  --shell-glow: rgba(24, 139, 91, 0.08);
  --tooltip-bg: rgba(23, 32, 26, 0.93);
  --shadow: 0 14px 32px rgba(28, 42, 34, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b09;
  --app: #101613;
  --surface: #17201b;
  --soft: #202b25;
  --ink: #edf5ef;
  --muted: #9ba9a0;
  --line: #314039;
  --green: #71d89e;
  --green-soft: #193526;
  --coral: #ff8c72;
  --coral-soft: #3b211c;
  --gold: #e6bf65;
  --gold-soft: #3a321b;
  --control: #101713;
  --active-surface: #24322b;
  --chart-bg: #111916;
  --header-bg: rgba(16, 22, 19, 0.94);
  --shell-glow: rgba(113, 216, 158, 0.08);
  --tooltip-bg: rgba(4, 8, 6, 0.96);
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

body[data-theme="pink"] {
  --bg: #f3e8ee;
  --app: #fff7fa;
  --surface: #ffffff;
  --soft: #f8eaf1;
  --ink: #261922;
  --muted: #7b6370;
  --line: #ead2dd;
  --green: #d95787;
  --green-soft: #fde5ef;
  --coral: #e26755;
  --coral-soft: #ffe8e3;
  --gold: #c08b25;
  --gold-soft: #fff1cf;
  --shell-glow: rgba(217, 87, 135, 0.1);
}

body[data-theme="blue"] {
  --bg: #e7edf7;
  --app: #f7f9fd;
  --surface: #ffffff;
  --soft: #eaf1fb;
  --ink: #172033;
  --muted: #657087;
  --line: #d4deee;
  --green: #2f73d9;
  --green-soft: #e1ecff;
  --coral: #df6d50;
  --coral-soft: #ffebe6;
  --gold: #b88923;
  --gold-soft: #fff1cf;
  --shell-glow: rgba(47, 115, 217, 0.1);
}

body[data-theme="orange"] {
  --bg: #f4ede3;
  --app: #fff9f1;
  --surface: #ffffff;
  --soft: #f8ecdd;
  --ink: #271d14;
  --muted: #7d6a58;
  --line: #ead8c1;
  --green: #df7b24;
  --green-soft: #fff0dd;
  --coral: #d95745;
  --coral-soft: #ffe7df;
  --gold: #b88b22;
  --gold-soft: #fff0c9;
  --shell-glow: rgba(223, 123, 36, 0.1);
}

body[data-theme="cyan"] {
  --bg: #e5f1f1;
  --app: #f6fbfb;
  --surface: #ffffff;
  --soft: #e5f4f3;
  --ink: #132323;
  --muted: #5d7474;
  --line: #cde3e2;
  --green: #159c9a;
  --green-soft: #dbf4f3;
  --coral: #df7055;
  --coral-soft: #ffe9e2;
  --gold: #b88f23;
  --gold-soft: #fff2cf;
  --shell-glow: rgba(21, 156, 154, 0.1);
}

body[data-theme="purple"] {
  --bg: #ece8f4;
  --app: #faf8ff;
  --surface: #ffffff;
  --soft: #efe8fb;
  --ink: #221a2d;
  --muted: #70617f;
  --line: #ddd2ee;
  --green: #7d58d6;
  --green-soft: #eee7ff;
  --coral: #df6d61;
  --coral-soft: #ffe8e5;
  --gold: #b88a25;
  --gold-soft: #fff1cd;
  --shell-glow: rgba(125, 88, 214, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.phone-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background:
    linear-gradient(180deg, var(--shell-glow), transparent 260px),
    var(--bg);
}

.phone-app {
  position: relative;
  width: min(100vw, 430px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app);
  box-shadow: 0 0 0 1px rgba(23, 32, 26, 0.08);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.eyebrow,
.label {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
}

.app-header h1 {
  margin-top: 0;
  font-size: 1.34rem;
  line-height: 1.1;
}

.icon-button,
.round-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--app);
  flex: 0 0 auto;
}

.icon-button.light {
  background: var(--soft);
  color: var(--ink);
}

svg {
  width: 18px;
  height: 18px;
}

.page-stack {
  flex: 1;
  min-height: 0;
}

.page {
  display: none;
  padding: 8px 14px 92px;
}

.page.active {
  display: block;
}

.hero-card,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 18px;
  margin-bottom: 12px;
}

.card {
  padding: 15px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h2,
.hero-card h2 {
  font-size: 1.05rem;
  line-height: 1.25;
}

.hero-card .card-head h2,
.hero-weight-line h2 {
  margin-top: 7px;
  font-size: 2rem;
  line-height: 1;
}

.hero-main {
  min-width: 0;
}

.hero-weight-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
}

.hero-bmi {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.hero-bmi::before {
  content: "|";
  margin: 0 7px 0 9px;
  color: #c4cec7;
  font-weight: 800;
}

.hero-bmi span,
.hero-bmi strong,
.hero-bmi em {
  display: inline;
}

.hero-bmi span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.hero-bmi strong {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1;
}

.hero-bmi em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.card p,
.hero-card p,
.muted-line {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.muted-line {
  margin-top: 8px;
}

.weight-progress {
  margin-top: 14px;
}

.weight-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.weight-progress-title {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.weight-progress-title em {
  color: var(--ink);
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 900;
}

.weight-progress-title small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.weight-progress-head strong {
  color: var(--green);
  font-size: 0.82rem;
}

.weight-progress-track {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.weight-progress-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #67c18e);
  transition: width 0.25s ease;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #146d49;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.single-input-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--control);
  color: var(--ink);
  outline: none;
  font-size: 1rem;
}

textarea {
  min-height: 142px;
  resize: vertical;
  line-height: 1.45;
}

select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--control);
  color: var(--ink);
  outline: none;
  font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 139, 91, 0.14);
}

.primary-button,
.ghost-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: var(--radius);
  border: 0;
  font-weight: 900;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
}

.primary-button.wide {
  width: 100%;
  margin-top: 14px;
}

.ghost-button.wide {
  width: 100%;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--control);
  color: var(--ink);
  font-size: 0.78rem;
}

.mini-stat-row span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

.range-switch-wrap {
  display: flex;
  margin-top: 12px;
}

.range-switch {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.range-switch button {
  min-width: 0;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.range-switch button.active {
  background: var(--active-surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(31, 43, 36, 0.08);
}

.chart-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.chart-window-label {
  flex: 1;
  margin-top: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.chart-toggle {
  min-height: 30px;
  padding: 0 9px;
  color: var(--muted);
}

.chart-toggle.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.chart-box {
  position: relative;
  height: 218px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--chart-bg);
  touch-action: pan-y;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 142px;
  max-width: 210px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: var(--tooltip-bg);
  color: #ffffff;
  font-size: 0.76rem;
  line-height: 1.38;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -106%);
  transition: opacity 120ms ease;
}

.chart-tooltip.show {
  opacity: 1;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 3px;
}

.chart-tooltip span {
  display: block;
  color: #d6e4d8;
}

.chart-tooltip span + span {
  margin-top: 2px;
}

#weightChart {
  display: block;
  width: 100%;
  height: 100%;
}

.mini-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.mini-stat-row div {
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--soft);
}

.mini-stat-row strong {
  display: block;
  margin-top: 5px;
  font-size: 0.92rem;
}

.report-poster {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.poster-image {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--soft);
}

.poster-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-copy {
  padding: 14px;
}

.poster-copy span {
  display: block;
}

.poster-copy span {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 900;
}

.poster-copy .poster-weight {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.poster-copy h3 {
  margin-top: 6px;
  font-size: 1.42rem;
  line-height: 1.1;
}

.poster-copy h3:first-child {
  margin-top: 0;
}

.leaderboard {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

.period-switch,
.rank-switch {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.group-switch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.group-pills {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.group-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.group-pills::-webkit-scrollbar {
  display: none;
}

.group-pill,
.group-add-button,
.group-icon-button {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.group-pill {
  padding: 0 12px;
}

.group-pill.active {
  border-color: rgba(24, 139, 91, 0.38);
  background: var(--green-soft);
  color: var(--green);
}

.group-icon-button.active {
  border-color: rgba(24, 139, 91, 0.38);
  background: var(--green-soft);
  color: var(--green);
}

.group-add-button {
  padding: 0 10px;
}

.group-icon-button {
  width: 34px;
  padding: 0;
}

.group-add-button svg,
.group-icon-button svg {
  width: 14px;
  height: 14px;
}

.group-admin-panel {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.group-admin-button {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.group-admin-button svg {
  width: 14px;
  height: 14px;
}

.group-admin-button.danger {
  color: #b44a3b;
  background: rgba(223, 109, 80, 0.1);
}

.join-requests {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.join-request-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 8px;
}

.join-request-card strong,
.join-request-card span {
  display: block;
  min-width: 0;
}

.join-request-card strong {
  font-size: 0.82rem;
}

.join-request-card span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.join-request-card button {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  padding: 0 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.join-request-card button[data-join-action="approve"] {
  background: var(--green);
  color: white;
}

.join-request-card button[data-join-action="reject"] {
  background: rgba(223, 109, 80, 0.12);
  color: #a33f32;
}

.period-switch {
  grid-template-columns: repeat(3, 1fr);
}

.rank-switch {
  grid-template-columns: repeat(3, 1fr);
}

.period-switch button,
.rank-switch button {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.period-switch button {
  min-height: 46px;
}

.period-switch button span,
.period-switch button small {
  display: block;
  min-width: 0;
}

.period-switch button small {
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.1;
  opacity: 0.78;
  white-space: nowrap;
}

.period-switch button.active,
.rank-switch button.active {
  background: var(--active-surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(31, 43, 36, 0.08);
}

.rank-row {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 62px;
  border: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.rank-row:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.rank-row:active {
  transform: scale(0.99);
}

.rank-no {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #7c581a;
  border: 2px solid rgba(124, 88, 26, 0.18);
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(124, 88, 26, 0.08);
}

.rank-no.rank-1 {
  background: #ffefb8;
  color: #7c5100;
  border-color: #e1ad36;
}

.rank-no.rank-2 {
  background: #eef1f4;
  color: #59636c;
  border-color: #bbc4cc;
}

.rank-no.rank-3 {
  background: #ffe1c2;
  color: #8b4c1a;
  border-color: #d08a48;
}

.rank-no.rank-pig {
  background: #ffd9d6;
  color: #9c3f37;
  border-color: #e68b82;
  font-size: 1.1rem;
}

.rank-main {
  min-width: 0;
  overflow: hidden;
}

.rank-main strong,
.rank-main > span {
  display: block;
}

.rank-name-line,
.bmi-name-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  flex-wrap: nowrap;
}

.player-name-text {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-tags {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  max-width: 116px;
  min-width: 22px;
  overflow: visible;
  white-space: nowrap;
}

.pk-tag-chip {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 2px;
}

.pk-tag-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 999px;
}

.pk-tag-count {
  position: absolute;
  right: -1px;
  bottom: -1px;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  border-radius: 999px;
  background: #2f3430;
  color: #ffffff;
  border: 1px solid var(--surface);
  font-size: 0.56rem;
  line-height: 13px;
  font-weight: 900;
}

.pk-tag-more {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  height: 22px;
  min-width: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.rank-main > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  vertical-align: 2px;
}

.rank-loss {
  color: var(--green);
  font-size: 0.92rem;
  font-weight: 900;
  white-space: nowrap;
}

.bmi-board {
  gap: 10px;
}

.bmi-band {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.bmi-band-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.bmi-band-head strong {
  font-size: 0.92rem;
}

.bmi-band-head small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.bmi-band-list {
  display: grid;
  gap: 7px;
}

.bmi-player {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  border: 0;
  padding: 9px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.bmi-player:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.bmi-player:active {
  transform: scale(0.99);
}

.bmi-player-main {
  min-width: 0;
}

.bmi-player-main strong,
.bmi-player-main > span {
  display: block;
}

.bmi-player-main > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bmi-value {
  display: grid;
  justify-items: end;
  gap: 3px;
  color: var(--green);
  font-weight: 900;
  white-space: nowrap;
}

.bmi-value small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.bmi-track {
  position: relative;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(31, 43, 36, 0.08);
  overflow: hidden;
}

.bmi-segment {
  position: absolute;
  top: 0;
  bottom: 0;
}

.bmi-segment-under {
  background: #8bbdff;
}

.bmi-segment-normal {
  background: #7fd399;
}

.bmi-segment-over {
  background: #f0c85e;
}

.bmi-segment-obese {
  background: #ee985c;
}

.bmi-track i {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 2px 8px rgba(31, 43, 36, 0.22);
  transform: translate(-50%, -50%);
}

.bmi-empty {
  padding: 10px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.muted-band {
  opacity: 0.82;
}

.weight-calendar {
  display: block;
  margin-top: 12px;
  overflow: hidden;
}

.calendar-pager {
  touch-action: pan-y;
}

.calendar-month-nav {
  display: grid;
  grid-template-columns: 34px 34px;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-month-nav button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.calendar-month-nav button:disabled {
  opacity: 0.28;
}

.calendar-month {
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.calendar-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
}

.calendar-title small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.calendar-weekdays,
.calendar-week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 50px;
  gap: 4px;
}

.calendar-weekdays {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.calendar-grid {
  display: grid;
  gap: 4px;
  margin-top: 5px;
}

.calendar-day {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  padding: 5px 3px;
  text-align: center;
  cursor: pointer;
}

.calendar-day em,
.calendar-day strong,
.calendar-day small {
  display: block;
  font-style: normal;
}

.calendar-day em {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.calendar-day strong {
  color: var(--green);
  font-size: 0.72rem;
  line-height: 1.1;
}

.calendar-day small {
  color: #b1bbb5;
  font-size: 0.68rem;
}

.calendar-day.has-weight {
  background: var(--control);
  border-color: rgba(24, 139, 91, 0.22);
}

.calendar-day.adjacent-month {
  opacity: 0.48;
}

.calendar-day.adjacent-month.has-weight {
  opacity: 0.74;
}

.calendar-day.has-weight.trend-down {
  background: #e5f5ec;
  border-color: rgba(24, 139, 91, 0.32);
}

.calendar-day.has-weight.trend-up {
  background: #ffebe6;
  border-color: rgba(223, 109, 80, 0.34);
}

.calendar-day.has-weight.trend-flat {
  background: #f1f3f0;
  border-color: #dce4d9;
}

body[data-theme="dark"] .calendar-day.has-weight.trend-down {
  background: #173321;
  border-color: #2d6841;
}

body[data-theme="dark"] .calendar-day.has-weight.trend-up {
  background: #3a211d;
  border-color: #7b3e31;
}

body[data-theme="dark"] .calendar-day.has-weight.trend-flat {
  background: #202823;
  border-color: #35443b;
}

.calendar-day.trend-up strong {
  color: #b84d3c;
}

.calendar-day.trend-flat strong {
  color: #65706a;
}

.calendar-day.has-behavior {
  box-shadow: inset 0 -3px 0 rgba(201, 148, 46, 0.22);
}

.calendar-day.has-outlier {
  box-shadow: inset 0 -3px 0 rgba(223, 109, 80, 0.28);
}

.calendar-day.has-behavior.has-outlier {
  box-shadow:
    inset 0 -3px 0 rgba(223, 109, 80, 0.28),
    inset 0 -6px 0 rgba(201, 148, 46, 0.18);
}

.calendar-week-summary {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 3px;
  text-align: center;
}

.calendar-week-summary span,
.calendar-week-summary strong {
  display: block;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.05;
}

.calendar-week-summary strong {
  color: #65706a;
}

.calendar-week-summary .diff-down {
  color: var(--green);
}

.calendar-week-summary .diff-up {
  color: #b84d3c;
}

.calendar-day.today {
  border-color: var(--green);
}

.invite-friend-button {
  width: 100%;
  margin-top: 12px;
}

.summary-history {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.history-report {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 8px;
  color: var(--ink);
  text-align: left;
}

.history-report img {
  display: block;
  width: 96px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
}

.history-report span,
.history-report strong,
.history-report em {
  display: block;
  min-width: 0;
}

.history-report strong {
  font-size: 0.9rem;
  line-height: 1.25;
}

.history-report em {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  font-style: normal;
  line-height: 1.45;
}

.dialog-summary {
  display: block;
}

.dialog-summary .report-poster {
  margin-top: 0;
}

.import-dialog {
  width: min(410px, calc(100vw - 24px));
}

.import-preview {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 10px;
}

.import-preview p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.import-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.import-row {
  display: grid;
  grid-template-columns: 74px 56px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  border-radius: 6px;
  background: var(--control);
  padding: 7px 8px;
  font-size: 0.8rem;
}

.import-row strong {
  font-size: 0.86rem;
}

.import-row span,
.import-row em {
  color: var(--muted);
  font-style: normal;
}

.import-row.invalid {
  grid-template-columns: 1fr;
  color: var(--coral);
  background: var(--coral-soft);
}

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 9px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
}

.tab-button {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.tab-button.active {
  background: var(--green-soft);
  color: var(--green);
}

.tab-button svg {
  margin-top: 5px;
}

.profile-dialog {
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  overflow: auto;
  box-shadow: 0 24px 70px rgba(23, 32, 26, 0.28);
}

.profile-dialog::backdrop {
  background: rgba(23, 32, 26, 0.42);
}

.profile-dialog form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.profile-dialog input,
.profile-dialog select,
.profile-dialog textarea {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
}

#behaviorDateInput {
  box-sizing: border-box;
  inline-size: 100% !important;
  max-inline-size: 100% !important;
  min-inline-size: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  -webkit-appearance: none;
  appearance: none;
}

#behaviorDateInput::-webkit-date-and-time-value {
  min-width: 0;
  text-align: left;
}

#behaviorDateInput::-webkit-calendar-picker-indicator {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 10px;
}

.account-strip span,
.account-strip strong {
  display: block;
}

.account-strip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.account-strip strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 0.9rem;
  word-break: break-all;
}

.account-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 7px;
}

.account-actions .small-button {
  width: 82px;
}

.login-dialog.force-auth button[value="cancel"] {
  display: none;
}

.friend-detail-body {
  display: grid;
  gap: 8px;
}

.friend-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border-radius: var(--radius);
  background: var(--soft);
  padding: 10px 12px;
}

.friend-detail-row span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.friend-detail-row strong {
  color: var(--ink);
  font-size: 0.94rem;
  white-space: nowrap;
}

.friend-detail-action {
  margin-top: 4px;
}

.tag-picker {
  display: grid;
  gap: 8px;
  border-radius: var(--radius);
  background: var(--soft);
  padding: 10px;
}

.tag-picker strong {
  font-size: 0.84rem;
}

.tag-picker-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.tag-picker-button {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 4px;
  font-size: 0.6rem;
  font-weight: 900;
}

.tag-picker-button img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.tag-picker-button.active {
  border-color: rgba(24, 139, 91, 0.45);
  background: var(--green-soft);
  color: var(--green);
}

.tag-detail-body {
  display: grid;
  gap: 8px;
}

.tag-detail-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border-radius: var(--radius);
  background: var(--soft);
  padding: 8px 10px;
}

.tag-detail-row img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.tag-detail-row strong,
.tag-detail-row span {
  display: block;
}

.tag-detail-row strong {
  font-size: 0.86rem;
}

.tag-detail-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(223, 109, 80, 0.12);
  color: #a33f32;
  font-size: 0.88rem;
  font-weight: 900;
}

.invite-link-box {
  display: grid;
  gap: 8px;
}

.invite-link-box span,
.invite-link-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.invite-link-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.invite-link-actions {
  display: grid;
  gap: 10px;
}

.invite-link-note {
  margin: -2px 0 0;
  line-height: 1.5;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.sheet-head h2 {
  margin-top: 4px;
  font-size: 1.16rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 20;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 760px) {
  .phone-shell {
    align-items: center;
    padding: 18px 0;
  }

  .phone-app {
    min-height: calc(100vh - 36px);
    border-radius: 28px;
    overflow: hidden;
    box-shadow:
      0 24px 80px rgba(23, 32, 26, 0.18),
      0 0 0 1px rgba(23, 32, 26, 0.08);
  }

  .app-header {
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
  }
}

@media (max-width: 360px) {
  .page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }

}
