:root {
  --bg-a: #fff1cd;
  --bg-b: #dff2ff;
  --bg-c: #fff9ef;
  --ink: #1f2430;
  --muted: #5e6677;
  --card: rgba(255, 255, 255, 0.8);
  --card-border: rgba(255, 255, 255, 0.65);
  --line: #dfe4ef;
  --accent: #ff8a00;
  --accent-2: #ff4d8d;
  --ok: #1fa48a;
  --warn: #e49a28;
  --bad: #7f8aa3;
  --shadow: 0 14px 34px rgba(24, 33, 58, 0.12);
}

body[data-theme="ocean"] {
  --bg-a: #d5f4ff;
  --bg-b: #e0fff7;
  --bg-c: #f2fdff;
  --accent: #00a7c4;
  --accent-2: #00c3b3;
  --ok: #0f8e84;
}

body[data-theme="space"] {
  --bg-a: #e7e4ff;
  --bg-b: #f2ecff;
  --bg-c: #f7f4ff;
  --accent: #6954ff;
  --accent-2: #c05bff;
  --ok: #4c7ddd;
}

body[data-theme="festival"] {
  --bg-a: #ffe9dc;
  --bg-b: #fff9df;
  --bg-c: #fff6ec;
  --accent: #ff5f5f;
  --accent-2: #ff8b2c;
  --ok: #2f9e44;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Microsoft YaHei UI", sans-serif;
  background:
    radial-gradient(1200px 680px at -8% -10%, rgba(255, 255, 255, 0.9) 0%, transparent 45%),
    radial-gradient(800px 620px at 108% 105%, rgba(255, 255, 255, 0.65) 0%, transparent 45%),
    linear-gradient(155deg, var(--bg-a), var(--bg-b) 55%, var(--bg-c));
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -2;
  border-radius: 50%;
  filter: blur(4px);
  animation: float 14s ease-in-out infinite;
}

body::before {
  width: 260px;
  height: 260px;
  right: -70px;
  top: -60px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, white) 0%, transparent 70%);
}

body::after {
  width: 300px;
  height: 300px;
  left: -85px;
  bottom: -90px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 35%, white) 0%, transparent 72%);
  animation-delay: -6s;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(3px);
}

.bg-shape-a {
  width: 340px;
  height: 200px;
  left: -90px;
  top: 22%;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  animation: drift 16s ease-in-out infinite;
}

.bg-shape-b {
  width: 320px;
  height: 190px;
  right: -110px;
  top: 62%;
  background: color-mix(in srgb, var(--accent-2) 16%, transparent);
  animation: drift 15s ease-in-out infinite reverse;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero {
  position: relative;
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-bottom: 18px;
  animation: rise 420ms ease;
}

.hero::after {
  content: "";
  width: min(420px, 86vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 45%, #ffffff), transparent);
}

.hero-brand {
  text-align: center;
}

.hero-brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.1vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: 0.4px;
  color: #253452;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.hero-brand p {
  margin: 6px 0 0;
  color: #4f5f7f;
  font-size: 0.95rem;
  font-weight: 600;
}

.today-date {
  color: #31415f;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}

.hero-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px 5px 10px;
  border: 1px solid #d8e3f6;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 252, 255, 0.9));
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 18px rgba(38, 58, 88, 0.08);
}

.auth-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #91a0bb;
}

.auth-chip.is-authenticated::before {
  background: #2ebd85;
  box-shadow: 0 0 0 3px rgba(46, 189, 133, 0.2);
}

.auth-chip small {
  color: #43506c;
  font-weight: 700;
  font-size: 0.82rem;
}

.auth-open-btn,
.auth-logout-btn {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.auth-open-btn {
  background: linear-gradient(120deg, #6a8bd6, #7d70db);
  color: #fff;
}

.auth-logout-btn {
  background: #f6f9ff;
  border: 1px solid #dbe5f7;
  color: #4f5f7a;
}

.auth-modal-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.auth-modal-card h3 {
  color: #32486c;
}

.auth-modal-card p {
  color: #5b6983;
}

.auth-mode-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid #d8e4f7;
  background: #f4f8ff;
  margin-bottom: 10px;
}

.auth-mode-switch button {
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.auth-mode-switch button.is-active {
  background: linear-gradient(120deg, #5f84df, #4f67bc);
  color: #fff;
  border: 0;
}

.auth-hint {
  display: block;
  color: #667793;
  margin: -2px 0 10px;
}

.role-switch {
  display: inline-flex;
  gap: 7px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
}

.role-btn {
  border: 0;
  background: transparent;
  color: #3c4862;
  border-radius: 999px;
  min-height: 40px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
}

.role-btn.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 28%, transparent);
}

.theme-select {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  padding: 8px 12px;
}

.panel {
  display: grid;
  gap: 14px;
}

.welcome-card {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 1px solid #d5e0f2;
  background:
    radial-gradient(130% 140% at 6% 2%, rgba(112, 153, 255, 0.16), transparent 45%),
    linear-gradient(145deg, #f8fbff 0%, #eef4ff 55%, #f8fbff 100%);
  box-shadow: 0 18px 34px rgba(28, 46, 78, 0.16);
}

.welcome-card::before {
  display: none;
}

.welcome-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.92fr;
  gap: 14px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.welcome-copy {
  text-align: left;
  border: 1px solid #d5e1f5;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.94));
  box-shadow: 0 14px 24px rgba(36, 60, 96, 0.12);
  padding: 20px;
  border-left: 6px solid #5f84df;
}

.welcome-kicker {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #ecf2ff;
  border: 1px solid #d3e0f7;
  color: #4a6291;
  font-weight: 700;
  letter-spacing: 0.95px;
  font-size: 0.75rem;
}

.welcome-copy h2 {
  margin: 0 0 12px;
  color: #263b62;
  font-size: clamp(1.56rem, 3.05vw, 2.22rem);
  line-height: 1.1;
  letter-spacing: 0.2px;
  text-shadow: none;
}

.welcome-copy p {
  margin: 0 0 12px;
  color: #5b6c8a;
  max-width: 43ch;
}

.welcome-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.welcome-badges span {
  border: 1px solid #d8e4f8;
  border-radius: 999px;
  background: #f6f9ff;
  color: #4c6185;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
}

.welcome-actions {
  display: grid;
  gap: 9px;
  justify-items: start;
}

.welcome-note {
  color: #607190;
  font-size: 0.8rem;
}

.welcome-cta {
  min-width: 205px;
  min-height: 44px;
  border: 0;
  background: linear-gradient(120deg, #5f84df, #4f67bc);
  color: #f4f8ff;
  font-weight: 800;
  box-shadow: 0 14px 22px rgba(79, 103, 188, 0.28);
}

.welcome-preview {
  display: grid;
  gap: 10px;
  border: 1px solid #d7e4f8;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(252, 254, 255, 0.98), rgba(243, 249, 255, 0.95));
  box-shadow: 0 14px 24px rgba(34, 57, 90, 0.12);
  padding: 14px;
  align-content: start;
}

.preview-top {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
}

.planet {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #fff6cf 0%, #ffd56e 42%, #f3ac3f 100%);
  box-shadow: inset -9px -7px 0 rgba(183, 122, 20, 0.2), 0 8px 14px rgba(245, 173, 61, 0.22);
  position: relative;
}

.planet::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 27px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid rgba(246, 170, 63, 0.6);
  transform: rotate(-12deg);
}

.preview-stat {
  border: 1px solid #dce7f8;
  border-radius: 12px;
  background: linear-gradient(135deg, #edf4ff, #f7fbff);
  padding: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.preview-stat small {
  color: #607093;
  font-weight: 700;
}

.preview-stat strong {
  color: #2a3f65;
  font-size: 1.25rem;
}

.preview-list {
  display: grid;
  gap: 6px;
}

.preview-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #dfe8f8;
  border-radius: 10px;
  background: #fbfdff;
  padding: 8px 10px;
}

.preview-list b {
  color: #3b5179;
  font-size: 0.9rem;
}

.preview-list span {
  color: #41659e;
  font-weight: 700;
  font-size: 0.8rem;
}

.preview-footer {
  display: grid;
  gap: 6px;
}

.preview-footer span {
  color: #4f6183;
  font-size: 0.82rem;
}

.stack-block {
  display: grid;
  gap: 6px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setting-highlight {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, #d8e5ff);
  border-radius: 10px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 10%, #ffffff), #f8fbff);
}

.settings-col {
  border: 1px dashed #dce3f2;
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
}

.setting-note {
  display: block;
  margin: -2px 0 8px;
  color: #5a667f;
}

#syncStatusText {
  display: block;
  margin: 2px 0 8px;
}

.child-top-grid,
.parent-top-grid,
.grid {
  display: grid;
  gap: 14px;
}

.child-top-grid,
.parent-top-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.child-top-grid.streak-off {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  animation: rise 460ms ease;
}

.card::before {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  border-radius: 999px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.8;
}

.child-top-grid .card:nth-child(1),
.parent-top-grid .card:nth-child(1) {
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 13%, #ffffff), rgba(255, 255, 255, 0.84));
}

.child-top-grid .card:nth-child(2),
.parent-top-grid .card:nth-child(2) {
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent-2) 12%, #ffffff), rgba(255, 255, 255, 0.84));
}

.child-top-grid .card:nth-child(3),
.parent-top-grid .card:nth-child(3) {
  background: linear-gradient(140deg, color-mix(in srgb, var(--ok) 12%, #ffffff), rgba(255, 255, 255, 0.84));
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  color: #28334f;
}

.hidden {
  display: none !important;
}

.star-panel {
  margin: 0;
  width: fit-content;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, white);
  background: linear-gradient(120deg, #fff, color-mix(in srgb, var(--accent) 10%, #fff));
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.star-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.8) 48%, transparent 75%);
  transform: translateX(-120%);
  animation: shine 3.8s ease-in-out infinite;
}

.star-panel strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--accent);
}

.star-panel span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.count-pop {
  animation: pop 360ms ease;
}

#todayTaskSummary,
#goalMotivateText,
#makeupInfoText,
#streakHintText,
#syncStatusText {
  color: var(--muted);
}

.streak-wrap,
.goal-wrap {
  display: grid;
  gap: 6px;
}

.streak-details-btn {
  justify-self: start;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

#streakDetailPanel {
  display: grid;
  gap: 6px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed #dce4f2;
}

.streak-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.streak-stats small {
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  background: rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  padding: 6px 8px;
  color: #4e5c78;
}

.streak-month-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 138px;
  overflow: auto;
}

.streak-month-history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid #e3e9f6;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  padding: 6px 8px;
}

.streak-month-history strong {
  color: #344564;
  font-size: 0.85rem;
}

.streak-month-history small {
  color: #60708e;
}

.streak-heatmap-wrap {
  margin-top: 4px;
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed #dbe3f2;
}

.streak-heatmap-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.streak-heatmap-head strong {
  color: #324769;
}

#toggleStreakHeatmapBtn {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.streak-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #66748f;
  font-size: 0.78rem;
}

.streak-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid #dce4f2;
}

.dot.none { background: #eef3fb; }
.dot.done { background: #3abb8f; border-color: #3abb8f; }
.dot.makeup { background: #f0a43b; border-color: #f0a43b; }

.streak-heatmap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 290px;
  overflow: auto;
  padding-right: 2px;
}

.heat-card {
  border: 1px solid #e3e9f6;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  padding: 8px;
  display: grid;
  gap: 5px;
}

.heat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.heat-card-head strong {
  color: #344b71;
  font-size: 0.85rem;
}

.heat-card-head small {
  color: #66748f;
}

.heat-week-head,
.heat-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.heat-week-head span {
  text-align: center;
  color: #7a88a3;
  font-size: 0.72rem;
}

.heat-cell {
  min-height: 18px;
  border-radius: 6px;
  border: 1px solid #e4eaf6;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  color: #73819b;
  background: #eef3fb;
}

.heat-cell.empty {
  background: transparent;
  border: 0;
}

.heat-cell.none { background: #eef3fb; }

.heat-cell.done {
  background: color-mix(in srgb, var(--ok) 26%, #ffffff);
  border-color: color-mix(in srgb, var(--ok) 40%, #d9f0ea);
  color: #1d6e62;
}

.heat-cell.makeup {
  background: color-mix(in srgb, var(--warn) 28%, #ffffff);
  border-color: color-mix(in srgb, var(--warn) 45%, #f2dfbf);
  color: #8f5e1b;
}

.heat-cell.today {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 42%, #ffffff);
}

.streak-badge {
  width: fit-content;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 18px color-mix(in srgb, var(--accent) 28%, transparent);
  animation: pulse 1.8s ease-in-out infinite;
}

.streak-badge.super {
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
}

.goal-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf1fb;
}

.goal-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, white), var(--accent), var(--accent-2));
  transition: width 220ms ease;
}

.goal-fill.done {
  background: linear-gradient(90deg, #2ab97d, var(--ok), #45c2ff);
}

.milestone-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.milestone-chip {
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf1fb;
  color: #506080;
}

.milestone-chip.done {
  background: #dbf5ef;
  color: #1d786c;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 86px auto;
  gap: 8px;
  margin-bottom: 10px;
}

.compact-form {
  grid-template-columns: 1fr auto auto;
}

.goal-form {
  grid-template-columns: 1fr auto;
}

.pin-form {
  grid-template-columns: 1fr auto auto;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4d5568;
  margin: 0 0 8px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 42px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.file-btn:focus-within {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, #ffffff);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
  box-shadow: 0 10px 18px color-mix(in srgb, var(--accent) 26%, transparent);
}

button:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: #c1c8d6;
}

.btn-soft {
  background: linear-gradient(120deg, #3d5a80, #4a6f9f);
}

.btn-ghost {
  background: #ebeff8;
  color: #384156;
}

.btn-active {
  background: linear-gradient(120deg, #2aa08e, #1f8575);
}

.btn-remind {
  background: linear-gradient(120deg, #e8a73a, #cf9229);
}

.btn-passive {
  background: linear-gradient(120deg, #7b8799, #677286);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 12px;
  min-height: 42px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(120deg, #3d5a80, #4a6f9f);
}

.file-btn input {
  display: none;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.backup-reminder {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 42%, #ebddb9);
  border-radius: 10px;
  background: #fff7e9;
  color: #7c5a20;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}

.stat-item,
.stat-chart {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #f8fbff;
}

.stat-item {
  grid-column: span 3;
  display: grid;
  gap: 3px;
}

.stat-item small {
  color: #5c6983;
  font-weight: 600;
}

.stat-item b {
  display: block;
  margin-top: 1px;
  color: #2f4968;
  font-size: 1.05rem;
}

.stat-hero {
  grid-column: span 6;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, #d9e6ff);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, white), color-mix(in srgb, var(--accent-2) 12%, white));
}

.stat-live-focus {
  grid-column: span 6;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, #e7ddbd);
  background: linear-gradient(120deg, #fff8eb, #fff4e5);
}

.stat-hero b {
  font-size: 1.85rem;
  line-height: 1.05;
  color: #243657;
}

.stat-live-focus b {
  font-size: 1.45rem;
  color: #7a5416;
}

.stat-hero em {
  font-style: normal;
  color: #4e5b76;
}

.stat-live-focus em {
  font-style: normal;
  color: #775a22;
}

.stat-pill {
  background: linear-gradient(180deg, #fbfdff, #f5f9ff);
}

.chart-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.chart-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #eaf0fb;
}

.chart-fill {
  height: 100%;
  border-radius: 999px;
}

.fill-active { background: linear-gradient(90deg, #2a9d8f, #21c1ad); }
.fill-remind { background: linear-gradient(90deg, #e9a93a, #f3c267); }
.fill-passive { background: linear-gradient(90deg, #7a8699, #9ca6b7); }

.stat-rating-chart {
  grid-column: span 6;
}

.stat-trend-chart {
  grid-column: span 6;
}

.stat-rank-chart {
  grid-column: span 6;
}

.stat-chart-title {
  margin-bottom: 8px;
  color: #334769;
  font-weight: 700;
}

.stat-chart-sub {
  display: block;
  margin: -3px 0 8px;
  color: #66748f;
  font-size: 0.8rem;
}

.stat-trend-chart svg {
  width: 100%;
  height: auto;
  display: block;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid #e5ecf8;
  border-radius: 10px;
  padding: 4px;
}

.trend-midline {
  stroke: #cfd9ea;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.trend-line {
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-trend-chart circle {
  fill: #fff;
  stroke: var(--accent-2);
  stroke-width: 2;
}

.trend-labels {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.trend-labels span {
  text-align: center;
  font-size: 0.75rem;
  color: #66738e;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 8px;
  align-items: center;
  border: 1px solid #e2e9f7;
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.rank-main {
  display: grid;
  gap: 1px;
}

.rank-main strong {
  color: #30496d;
}

.rank-main small {
  color: #66748f;
}

.rank-index {
  color: #8a6781;
  font-weight: 700;
}

.rank-side {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.rank-side b {
  color: #21657e;
}

.rank-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e8eef9;
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.rank-empty {
  color: #6a768e;
  padding: 8px;
  border: 1px dashed #d5dff0;
  border-radius: 10px;
  background: #fcfdff;
}

.list,
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

#todayTaskSummary {
  display: inline-flex;
  align-items: center;
  margin: 2px 0 10px;
  padding: 6px 10px;
  border: 1px solid #dfe8f8;
  border-radius: 999px;
  background: #f7fbff;
  color: #53617d;
}

.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255, 255, 255, 0.74);
  transition: transform 130ms ease, box-shadow 130ms ease, border-color 130ms ease;
}

.item:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  box-shadow: 0 8px 16px rgba(31, 41, 73, 0.08);
}

.item.pending-highlight {
  border-color: color-mix(in srgb, var(--accent) 45%, #ffd6a0);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, white);
  background: linear-gradient(180deg, #fffdfa 0%, #ffffff 100%);
}

.item.pending-highlight strong::before {
  content: "待提交  ";
  color: color-mix(in srgb, var(--accent) 72%, #7c4e00);
  font-size: 0.74rem;
  font-weight: 700;
}

.item small {
  color: #666f83;
}

.task-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.child-task-item {
  padding: 13px;
  gap: 12px;
}

.child-task-main {
  display: grid;
  gap: 5px;
  max-width: min(100%, 520px);
}

.child-task-meta {
  color: #5f6d88;
}

.child-task-proof {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

#childTaskList .task-actions {
  min-width: 130px;
  align-content: start;
}

#childTaskList .task-actions button,
#childTaskList .task-actions .badge-ok,
#childTaskList .task-actions .badge-pending {
  justify-self: end;
}

.rate-buttons {
  display: flex;
  gap: 6px;
}

.partial-rate-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.partial-rate-row input {
  width: 76px;
}

.badge-ok,
.badge-pending {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 3px 8px;
}

.badge-ok {
  background: #daf6f1;
  color: #1b786c;
}

.badge-pending {
  background: #edf1fb;
  color: #485066;
}

.history li {
  border-left: 4px solid var(--line);
  border-radius: 10px;
  background: #fafdff;
  padding: 8px 10px;
}

.history-group {
  border-left: 0;
  background: transparent;
  padding: 2px 2px;
  color: #506080;
  font-weight: 700;
}

.plus { color: var(--ok); }
.minus { color: #cf4f62; }

.modal {
  position: fixed;
  inset: 0;
  padding: 14px;
  background: rgba(16, 22, 37, 0.42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 1200;
}

#authModal {
  z-index: 1100;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5ebf8;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  animation: rise 220ms ease;
}

.modal-card h3 {
  margin: 0 0 8px;
}

.modal-card p {
  margin: 0 0 10px;
}

.pin-modal-card {
  background: linear-gradient(180deg, #fff 0%, #f7fbff 100%);
}

.pin-title {
  color: #334a6e;
}

.pin-desc {
  color: #5a667f;
}

#pinVerifyInput,
#uiModalInput,
#authUsernameInput,
#authPasswordInput {
  width: 100%;
  min-height: 44px;
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-10px) translateX(8px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes shine {
  0% { transform: translateX(-120%); }
  48%, 100% { transform: translateX(120%); }
}

@keyframes pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@media (max-width: 860px) {
  .hero-brand p {
    font-size: 0.9rem;
  }

  .child-top-grid,
  .parent-top-grid,
  .grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .welcome-hero {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .welcome-copy {
    padding: 14px;
  }

  .streak-stats {
    grid-template-columns: 1fr;
  }

  .streak-month-history li {
    flex-direction: column;
    align-items: flex-start;
  }

  .streak-heatmap {
    grid-template-columns: 1fr;
  }

  .stat-item,
  .stat-rating-chart,
  .stat-trend-chart,
  .stat-rank-chart,
  .stat-hero {
    grid-column: span 1;
  }

  .stat-hero b {
    font-size: 1.55rem;
  }

  .rank-row {
    grid-template-columns: 1fr;
  }

  .child-task-item {
    flex-direction: column;
    align-items: stretch;
  }

  #childTaskList .task-actions {
    width: 100%;
    min-width: 0;
    justify-items: stretch;
  }

  #childTaskList .task-actions button,
  #childTaskList .task-actions .badge-ok,
  #childTaskList .task-actions .badge-pending {
    justify-self: stretch;
  }

  .inline-form,
  .compact-form,
  .goal-form,
  .pin-form {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .rate-buttons,
  .partial-rate-row {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .task-actions button,
  .file-btn,
  button {
    min-height: 44px;
  }
}
