:root {
  --bg: #000000;
  --card: #101012;
  --card-2: #1c1c1e;
  --text: #ffffff;
  --secondary: #98989d;
  --tertiary: #636366;
  --separator: rgba(84, 84, 88, 0.5);
  --pink: #fa114f;
  --pink-soft: #ff5e8a;
  --green: #30d158;
  --blue: #0a84ff;
  --red: #ff453a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: calc(116px + var(--safe-bottom));
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
  touch-action: manipulation;
}

input {
  font: inherit;
}

#app {
  max-width: 560px;
  margin: 0 auto;
}

.page-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 20px 20px 2px;
}

.page-sub {
  color: var(--secondary);
  font-size: 15px;
  margin: 2px 20px 18px;
}

/* ---------- 卡片与行 ---------- */
.card {
  background: var(--card);
  border-radius: 22px;
  margin: 0 16px 16px;
  overflow: hidden;
  border: 0.5px solid rgba(255, 255, 255, 0.06);
}

.card-head {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--secondary);
  padding: 15px 16px 7px;
}

.card-head.hero {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding: 20px 20px 2px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--separator);
}

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

.row-label {
  font-size: 17px;
}

.row-value {
  margin-left: auto;
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.row-value .delta-weak {
  color: var(--secondary);
  font-weight: 400;
}

.item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #2c2c2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: none;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 17px;
}

.item-sub {
  font-size: 13px;
  color: var(--secondary);
  margin-top: 1px;
}

.item-input {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.item-input input {
  width: 88px;
  text-align: right;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  padding: 2px 0;
  -webkit-appearance: none;
  appearance: none;
}

.item-input input:focus {
  outline: none;
}

.item-input input::placeholder {
  color: #48484a;
}

.item-unit {
  font-size: 14px;
  color: var(--secondary);
  white-space: nowrap;
}

.points-chip {
  font-size: 13px;
  color: var(--pink-soft);
  min-width: 52px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 圆圈 ---------- */
.day-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  color: var(--secondary);
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.cal-cell .day-circle {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.day-circle.has {
  border-color: var(--pink);
  color: var(--pink-soft);
  background: rgba(250, 17, 79, 0.08);
}

.day-circle.pass {
  background: linear-gradient(135deg, var(--pink), var(--pink-soft));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(250, 17, 79, 0.35);
}

.cal-cell .day-circle.today {
  box-shadow: 0 0 0 2px var(--blue);
}

.week-card {
  padding-top: 4px;
}

/* ---------- 本周 ---------- */
.week-row {
  display: flex;
  padding: 6px 8px 14px;
}

.week-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.week-label {
  font-size: 11px;
  color: var(--secondary);
}

.week-day.is-today .week-label {
  color: #fff;
  font-weight: 600;
}

.week-ring-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-day.is-today .week-ring-wrap {
  background: #2c2c2e;
}

.week-day.is-selected .week-ring-wrap {
  background: rgba(250, 17, 79, 0.12);
}

.week-ring {
  width: 38px;
  height: 38px;
}

.week-ring .ring-track {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 5;
}

.week-ring .ring-progress {
  stroke-width: 5;
}

/* ---------- 今日大圆环 ---------- */
.big-circle-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

.big-ring {
  width: 190px;
  height: 190px;
}

.ring-track {
  fill: none;
  stroke: #232325;
  stroke-width: 13;
}

.ring-progress {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s;
}

.ring-overlap {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

.ring-score {
  font-size: 32px;
  font-weight: 700;
  fill: var(--text);
  text-anchor: middle;
}

.ring-unit {
  font-size: 14px;
  font-weight: 600;
  fill: var(--secondary);
}

.ring-goal {
  font-size: 14px;
  font-weight: 500;
  fill: var(--tertiary);
  text-anchor: middle;
}

.ring-status {
  font-size: 13px;
  fill: var(--secondary);
  text-anchor: middle;
}

.ring-status.pass {
  fill: var(--green);
}

/* ---------- 今日柱状图 ---------- */
.chart-divider {
  height: 0.5px;
  background: var(--separator);
  margin: 8px 20px 0;
}

.bar-chart {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 12px;
  padding: 18px 24px 6px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.bar-value {
  font-size: 10px;
  color: var(--secondary);
  min-height: 13px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  width: 100%;
  max-width: 36px;
  height: 88px;
  background: #232325;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--pink-soft), var(--pink));
  border-radius: 8px;
  transition: height 0.3s;
}

.bar-label {
  font-size: 12px;
  color: var(--secondary);
}

.chart-total {
  text-align: center;
  color: var(--pink-soft);
  font-size: 15px;
  padding: 10px 0 18px;
}

.chart-total b {
  font-weight: 700;
}

/* ---------- 月历 ---------- */
.month-nav {
  display: flex;
  align-items: center;
  padding: 10px 10px;
}

.month-label {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.nav-btn {
  font-size: 26px;
  line-height: 1;
  color: var(--pink-soft);
  padding: 6px 18px;
  border-radius: 10px;
}

.nav-btn:disabled {
  color: #48484a;
}

.cal-head-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 4px 8px 2px;
}

.cal-head {
  text-align: center;
  font-size: 11px;
  color: var(--tertiary);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 8px 8px;
  row-gap: 5px;
}

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
}

.cal-score {
  font-size: 9px;
  color: var(--secondary);
  min-height: 12px;
  font-variant-numeric: tabular-nums;
}

.legend {
  text-align: center;
  font-size: 11px;
  color: var(--tertiary);
  padding: 0 12px 14px;
}

/* ---------- 设置 ---------- */
.cell-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  font-size: 17px;
  border-bottom: 0.5px solid var(--separator);
}

.cell-btn:last-child {
  border-bottom: 0;
}

.cell-btn.danger {
  color: var(--red);
  text-align: center;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 0 16px calc(10px + var(--safe-bottom));
  z-index: 20;
  pointer-events: none;
}

.tabbar-inner {
  pointer-events: auto;
  flex: 1;
  max-width: 528px;
  display: flex;
  background: rgba(28, 28, 30, 0.78);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  padding: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0 5px;
  font-size: 10px;
  color: var(--secondary);
  border-radius: 23px;
  transition: color 0.15s;
}

.tab-btn.is-active {
  color: var(--green);
  font-weight: 600;
  background: rgba(48, 209, 88, 0.12);
}

.tab-ic {
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-ic svg {
  width: 22px;
  height: 22px;
}

/* ---------- 弹窗与提示 ---------- */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 22px;
  max-width: 330px;
  width: calc(100% - 48px);
  background: var(--card-2);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
}

dialog p {
  margin: 0;
  color: var(--secondary);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
}

.btn-ghost {
  background: #2c2c2e;
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 500;
}

.hint {
  color: var(--tertiary);
  font-size: 12px;
  padding: 2px 20px 18px;
  text-align: center;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(128px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(44, 44, 46, 0.94);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  max-width: 86%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
