:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #192232;
  --muted: #65728a;
  --line: #dde5f0;
  --primary: #1b6f6a;
  --primary-dark: #0f4f4c;
  --primary-soft: #dff2ee;
  --accent: #c94f32;
  --accent-soft: #fde9e1;
  --warning: #b7791f;
  --yellow-soft: #fff3c4;
  --blue: #315f9f;
  --green: #22845d;
  --shadow: 0 18px 40px rgba(32, 42, 63, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(245, 247, 251, 0.98), rgba(241, 245, 249, 0.96)),
    radial-gradient(circle at 78% 12%, rgba(27, 111, 106, 0.12), transparent 26%);
  color: var(--text);
  font-family:
    Inter,
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.brand,
.profile-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.profile-strip strong {
  display: block;
  line-height: 1.3;
}

.brand span,
.profile-strip span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.profile-strip {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.avatar {
  width: 38px;
  height: 38px;
  background: var(--accent);
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(27, 111, 106, 0.18);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.side-meter {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.side-meter span {
  color: var(--muted);
  font-size: 12px;
}

.side-meter strong {
  display: block;
  margin: 6px 0 10px;
}

.mini-progress,
.progress-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef6;
}

.mini-progress span,
.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.25s ease;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.countdown {
  min-width: 142px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: right;
}

.countdown span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.countdown strong {
  display: block;
  margin-top: 2px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.workbench,
.grid {
  display: grid;
  gap: 18px;
}

.workbench {
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  margin-bottom: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.community-grid {
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 0.58fr);
}

.resource-grid,
.account-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
}

.panel,
.checkin-panel,
.hero-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.panel,
.checkin-panel {
  padding: 20px;
}

.hero-panel {
  position: relative;
  min-height: 440px;
  overflow: hidden;
}

.hero-panel img {
  width: 100%;
  height: 100%;
  min-height: 440px;
  object-fit: cover;
  display: block;
}

.hero-panel::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(9, 26, 32, 0.12), rgba(9, 26, 32, 0.68));
}

.quick-stats {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
}

.quick-stats span,
.progress-label span,
.allowance-row,
.recent-list,
.resource-card span,
.plan-card span,
.metric-card span,
.feed-meta {
  color: var(--muted);
  font-size: 12px;
}

.quick-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 21px;
}

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

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

form {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(27, 111, 106, 0.7);
  box-shadow: 0 0 0 3px rgba(27, 111, 106, 0.12);
}

.span-2 {
  grid-column: 1 / -1;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover {
  border-color: rgba(27, 111, 106, 0.32);
  background: var(--primary-soft);
}

.danger-button {
  border: 1px solid #b42318;
  background: #b42318;
  color: #fff;
}

.danger-button:hover {
  background: #8f1b13;
}

.allowance-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.allowance-row span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--panel-soft);
}

.progress-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.progress-label strong {
  font-size: 13px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(18, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 14px);
  gap: 5px;
  max-width: 100%;
  overflow: auto;
  padding-bottom: 4px;
}

.heat-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: #e9eef6;
}

.heat-cell.level-1 {
  background: #bfe3dc;
}

.heat-cell.level-2 {
  background: #70b9a8;
}

.heat-cell.level-3 {
  background: #278a74;
}

.heat-cell.level-4 {
  background: #0f5d52;
}

.heat-cell.is-leave {
  background: repeating-linear-gradient(45deg, #f1d890 0, #f1d890 3px, #fff3c4 3px, #fff3c4 6px);
}

.heatmap-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.heatmap-key i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #e9eef6;
}

.heatmap-key i:nth-child(2) {
  background: #bfe3dc;
}

.heatmap-key i:nth-child(3) {
  background: #70b9a8;
}

.heatmap-key i:nth-child(4) {
  background: #278a74;
}

.recent-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.recent-item,
.rank-item,
.resource-card,
.plan-card,
.metric-card,
.feed-item,
.badge-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px;
}

.rank-index {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--yellow-soft);
  color: var(--warning);
  font-weight: 900;
}

.rank-item strong,
.feed-item strong,
.resource-card strong,
.plan-card strong {
  display: block;
}

.rank-item small {
  color: var(--muted);
}

.rank-value {
  font-weight: 900;
  color: var(--primary-dark);
}

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

.badge-card {
  min-height: 104px;
  padding: 13px;
}

.badge-card.is-locked {
  opacity: 0.52;
}

.badge-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 9px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.badge-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.post-form,
.plan-form,
.auth-form,
.profile-form {
  grid-template-columns: 1fr;
}

.feed-panel {
  min-height: 640px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.segmented button {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
}

.feed-list {
  display: grid;
  gap: 12px;
}

.feed-item {
  padding: 14px;
}

.feed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 5px 0 9px;
}

.feed-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.feed-item p,
.resource-card p,
.plan-card p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
}

.compact-input {
  width: min(220px, 100%);
}

.resource-list,
.plan-list {
  display: grid;
  gap: 10px;
}

.resource-card,
.plan-card {
  padding: 14px;
}

.resource-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.resource-card span,
.plan-card span {
  display: block;
  margin: 4px 0 7px;
}

.resource-type {
  align-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.plan-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.plan-card button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.chart-wrap {
  position: relative;
}

.chart-panel canvas {
  width: 100%;
  max-width: 100%;
  height: 320px;
  min-height: 320px;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(248, 250, 252, 0.92);
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.chart-empty[hidden] {
  display: none;
}

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

.metric-card {
  padding: 14px;
}

.metric-card strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
}

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

.danger-zone {
  margin-top: 18px;
}

.danger-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px;
  border: 1px solid #f1b8b0;
  border-radius: var(--radius);
  background: #fff7f5;
}

.danger-row strong {
  display: block;
}

.danger-row p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #162331;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(460px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.confirm-dialog h2 {
  margin: 4px 0 8px;
}

.confirm-dialog p:not(.eyebrow) {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-item {
    justify-content: center;
    text-align: center;
  }

  .side-meter {
    margin-top: 0;
  }

  .workbench,
  .grid.two,
  .community-grid,
  .resource-grid,
  .account-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .countdown {
    flex: 1;
    text-align: left;
  }

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

  .nav-item {
    justify-content: flex-start;
  }

  .checkin-form,
  .goal-form,
  .quick-stats,
  .badge-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .hero-panel,
  .hero-panel img {
    min-height: 360px;
  }

  .section-heading {
    flex-direction: column;
  }

  .compact-input {
    width: 100%;
  }

  .resource-card,
  .plan-card,
  .danger-row {
    grid-template-columns: 1fr;
  }
}
