:root {
  --wash: #EDE6F6;
  --wash-deep: #E4D6F2;
  --shell: #FAF5FF;
  --card: #ffffff;
  --ink: #3D2E4D;
  --muted: #8A7B9A;
  --faint: #B5AAC4;
  --line: #EADFF5;
  --brand: #C9A6E8;
  --brand-deep: #B894D8;
  --brand-soft: #E8D6F5;
  --danger: #E87A9A;
  --shadow: 0 22px 50px rgba(201, 166, 232, 0.22);
  --radius: 28px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--wash);
}

button, input, a { font: inherit; color: inherit; }

.page-bg {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 50% -80px, #f4f0fb 0%, transparent 70%),
    var(--wash);
}

.app-shell {
  height: 100dvh;
  background: var(--shell);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar { display: none; }

.workspace {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 20px 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.brand-name, .slogan, .date-line, .hint, .card p, .quiet, .local-note { margin: 0; }

.brand-name { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.04em; }

.slogan, .date-line, .quiet, .local-note { color: var(--muted); }

.slogan { margin-top: 2px; font-size: 0.92rem; }

.about-link, .side-about, .text-button {
  color: var(--brand-deep);
  text-decoration: none;
  background: transparent;
  border: 0;
  padding: 8px 2px;
  cursor: pointer;
}

.date-line { margin: 12px 0 4px; font-size: 0.95rem; }

.mascot {
  display: block;
  width: 168px;
  height: auto;
  margin: 8px auto 4px;
  animation: float 3.4s ease-in-out infinite;
}

.mascot.delayed { animation-delay: 0.45s; }

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

.checkin {
  width: 100%;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px 18px;
  margin-top: 12px;
  box-shadow: 0 8px 24px rgba(98, 78, 150, 0.06);
}

.card h2, .panel h2, .stats-head h2, .about-block h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.card strong, .stat strong { display: block; font-size: 1.15rem; font-weight: 700; }

.hint { margin-top: 14px; line-height: 1.55; }

.primary, .ghost, .danger {
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: 0 18px;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 18px;
  background: var(--brand);
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
}

.backfill { width: 100%; margin: 8px 0 14px; }

.panel-actions .primary,
.modal-actions .primary,
.modal-actions .danger {
  width: auto;
  margin-top: 0;
}

.ghost, .danger {
  background: var(--card);
  border: 1px solid var(--line);
}

.danger { color: var(--danger); }

.undo {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: center;
}

.local-note { margin-top: 18px; font-size: 0.82rem; line-height: 1.5; }

.banner {
  background: #FFE4EC;
  color: #E87A9A;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
}

.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  background: #E8D6F5;
  border-radius: 999px;
  margin: 8px 0 16px;
}

.switch button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-height: 40px;
  cursor: pointer;
}

.switch button[aria-selected="true"] {
  background: white;
  color: var(--brand-deep);
  font-weight: 700;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 220px;
  padding-top: 8px;
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar-days { font-size: 0.78rem; color: var(--muted); }

.bar {
  width: 100%;
  max-width: 46px;
  border-radius: 12px 12px 6px 6px;
  background: linear-gradient(#8d7cc4, #c3b4e6);
}

.bar-label { font-size: 0.75rem; color: var(--faint); text-align: center; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stat {
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
}

.stat span { color: var(--muted); font-size: 0.78rem; }

.record-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }

.record {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.record p { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.record-actions { display: flex; gap: 8px; flex-shrink: 0; }

.record-actions button {
  min-height: 40px;
  padding: 0 12px;
}

.panel {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(98, 78, 150, 0.06);
}

.field { display: grid; gap: 6px; margin-top: 12px; }

.field span { font-size: 0.85rem; color: var(--muted); }

.field input {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fcfbfe;
  padding: 0 12px;
}

.panel-actions, .modal-actions { display: flex; gap: 10px; margin-top: 16px; }

.panel-actions button, .modal-actions button { flex: 1; }

.alert { color: var(--danger); margin: 10px 0 0; }

.empty { color: var(--muted); line-height: 1.6; }

.about-block + .about-block { margin-top: 18px; }

.about-block p { margin: 0; line-height: 1.7; color: var(--muted); }

.loading { color: var(--muted); padding: 24px 0; }

.tabbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(247, 244, 251, 0.96);
  border-top: 1px solid var(--line);
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
  z-index: 5;
}

.tabbar a, .side-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--faint);
  min-height: 48px;
  justify-content: center;
  border-radius: 14px;
}

.tabbar a[aria-current="page"], .side-nav a[aria-current="page"] {
  color: var(--brand-deep);
  font-weight: 700;
}

.tabbar svg, .nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal, .success-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal { background: rgba(47, 41, 66, 0.28); }

.modal-card, .success-card {
  width: min(100%, 380px);
  background: white;
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.success-overlay { background: rgba(228, 220, 244, 0.2); pointer-events: none; }

.success-card { text-align: center; font-size: 1.15rem; font-weight: 700; }

.quiet { margin-top: 12px; line-height: 1.5; }

.modal h2 { margin: 0 0 8px; font-size: 1.15rem; }

.modal p { margin: 0; color: var(--muted); line-height: 1.6; }

@media (min-width: 900px) {
  .page-bg {
    background:
      radial-gradient(1000px 520px at 50% -120px, #FAF5FF 0%, transparent 62%),
      linear-gradient(#E8D6F5, var(--wash-deep));
  }

  .app-shell {
    width: clamp(720px, 66.67vw, 1200px);
    height: auto;
    min-height: calc(100vh - 80px);
    margin: 40px auto;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 18px;
    background: #F4ECFB;
    border-right: 1px solid var(--line);
  }

  .brand {
    display: flex;
    gap: 10px;
    align-items: center;
    text-decoration: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: white;
    font-weight: 700;
  }

  .brand-copy { display: grid; }
  .brand-copy small { color: var(--muted); }

  .side-nav { display: grid; gap: 6px; }

  .side-nav a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
  }

  .nav-icon { display: grid; }

  .side-about { margin-top: auto; padding-left: 12px; }

  .topbar { display: none; }

  .workspace {
    overflow: visible;
    padding: 32px 36px 36px;
  }

  .tabbar { display: none; }

  .checkin {
    width: min(100%, 460px);
    margin-inline: auto;
  }
}

@media (hover: hover) and (pointer: fine) {
  .primary:hover { background: var(--brand-deep); }
  .ghost:hover, .text-button:hover, .about-link:hover, .side-about:hover { background: var(--brand-soft); }
  .tabbar a:hover, .side-nav a:hover { background: var(--brand-soft); }
  .danger:hover { background: #FFE4EC; }
}

.primary:focus-visible, .ghost:focus-visible, .danger:focus-visible, a:focus-visible, .switch button:focus-visible, input:focus-visible {
  outline: 3px solid #c8b6ee;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .mascot { animation: none; }
}
