:root {
  color-scheme: light;
  --ink: #181914;
  --muted: #6f746e;
  --paper: #f4f3ee;
  --panel: rgba(255, 255, 251, 0.92);
  --panel-solid: #fffefa;
  --line: #dfded5;
  --line-strong: #c9c7bc;
  --good: #23865f;
  --good-soft: #e8f2ec;
  --bad: #d9574f;
  --bad-soft: #faece9;
  --aware: #b98222;
  --aware-soft: #f7eddb;
  --unclear: #8f9aa5;
  --unclear-soft: #eceff1;
  --ring: rgba(35, 134, 95, 0.22);
  --shadow-soft: 0 10px 30px rgba(40, 43, 34, 0.07);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.92), transparent 34rem),
    linear-gradient(180deg, #f8f7f2 0%, var(--paper) 48%, #eeede7 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
summary,
input,
textarea {
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.shell {
  width: min(768px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.card {
  border: 1px solid rgba(201, 199, 188, 0.86);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.today-card,
.review-hero,
.trend-card,
.review-list-card,
.reflection-card {
  padding: 18px 14px 14px;
}

.topbar,
.section-heading,
.ledger-meta,
.ledger-actions,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

h1 {
  font-size: 1.08rem;
  line-height: 1.35;
  font-weight: 760;
}

h2 {
  font-size: 0.98rem;
  line-height: 1.45;
  font-weight: 760;
}

h3 {
  margin-top: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  font-weight: 720;
}

#date-input {
  display: block;
  width: 132px;
  min-height: 24px;
  margin-top: 3px;
  border: 0;
  border-radius: 7px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip-button,
.chip-link {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 13px;
  background: #e9e8e1;
  color: #2b2b26;
  font-size: 0.8rem;
  font-weight: 740;
}

.chip-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.chip-link:hover,
.chip-button:hover,
.soft-button:hover,
.filter-toggle:hover {
  background: #deddd4;
}

.counters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 22px;
  text-align: center;
}

.counter {
  min-height: 76px;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 1px solid rgba(223, 222, 213, 0.82);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
}

.counter:nth-child(1) {
  background: linear-gradient(180deg, var(--good-soft), rgba(255, 255, 255, 0.52));
}

.counter:nth-child(2) {
  background: linear-gradient(180deg, var(--bad-soft), rgba(255, 255, 255, 0.52));
}

.counter:nth-child(3) {
  background: linear-gradient(180deg, var(--aware-soft), rgba(255, 255, 255, 0.52));
}

.counter:nth-child(4) {
  background: linear-gradient(180deg, var(--unclear-soft), rgba(255, 255, 255, 0.52));
}

.counter strong {
  font-size: 1.62rem;
  line-height: 1;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.counter span {
  margin-top: 8px;
  color: #5f635d;
  font-size: 0.73rem;
}

.seed-bank {
  margin-top: 10px;
  padding: 12px 12px 10px;
}

.dot-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.mind-dot,
.entry-dot,
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--unclear);
}

.mind-dot.good,
.entry-dot.good,
.legend-dot.good {
  background: var(--good);
}

.mind-dot.unwholesome {
  border-radius: 2px;
  transform: rotate(45deg);
  background: transparent;
  border: 1.5px solid var(--bad);
}

.mind-dot.aware {
  background: var(--aware);
}

.mind-dot.aware.diamond {
  border-radius: 2px;
  transform: rotate(45deg);
  background: transparent;
  border: 1.5px solid var(--aware);
}

.mind-dot.unclear,
.entry-dot.unclear,
.legend-dot.unclear {
  background: var(--unclear);
}

.entry-dot.unwholesome,
.legend-dot.unwholesome {
  background: var(--bad);
}

.entry-dot.aware,
.legend-dot.aware {
  background: var(--aware);
}

.mark-section {
  margin-top: 18px;
  padding: 0 12px;
}

.mark-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mark-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 760;
}

.mark-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.mark-button:active {
  transform: translateY(0);
}

.mark-button span {
  margin-right: 8px;
}

.mark-button.good {
  border-color: rgba(35, 134, 95, 0.72);
  color: #0b8f48;
  background: rgba(232, 242, 236, 0.52);
}

.mark-button.unwholesome {
  border-color: rgba(217, 87, 79, 0.32);
  color: #e63e3e;
  background: rgba(250, 236, 233, 0.55);
}

.mark-button.aware {
  background: rgba(247, 237, 219, 0.55);
}

.mark-button.unclear {
  background: rgba(236, 239, 241, 0.72);
}

.note-drawer {
  margin-top: 12px;
  border-bottom: 1px solid rgba(223, 222, 213, 0.88);
  color: var(--muted);
}

.note-drawer summary {
  min-height: 36px;
  list-style: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 36px;
}

.note-drawer summary::-webkit-details-marker {
  display: none;
}

.note-drawer summary::after {
  content: "⌄";
  float: right;
  color: #333;
}

.note-drawer[open] summary::after {
  content: "⌃";
}

#pending-note,
.reflection-card textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  line-height: 1.55;
}

#pending-note {
  margin-bottom: 12px;
}

#pending-note:focus,
.reflection-card textarea:focus {
  border-color: rgba(35, 134, 95, 0.76);
  background: var(--panel-solid);
}

.ledger-panel {
  margin-top: 20px;
  padding: 0 12px;
}

.ledger-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.filter-toggle {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 0 9px;
  background: transparent;
  color: var(--muted);
}

.filter-toggle.active {
  background: #ededdf;
  color: #31312d;
  font-weight: 740;
}

.ledger {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: grid;
  grid-template-columns: 12px minmax(88px, 1fr) auto 24px;
  grid-template-areas:
    "dot kind time delete"
    ". note note note";
  align-items: start;
  gap: 8px;
  min-height: 38px;
  padding: 5px 0;
  color: var(--ink);
  border-top: 1px solid rgba(223, 222, 213, 0.7);
}

.entry:first-child {
  border-top: 0;
}

.entry-dot {
  grid-area: dot;
  margin-top: 6px;
}

.entry-kind {
  grid-area: kind;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.entry-note {
  grid-area: note;
  min-width: 0;
  overflow-wrap: anywhere;
  margin: -3px 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.entry-note:empty {
  display: none;
}

.entry time {
  grid-area: time;
  color: #858982;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
  white-space: nowrap;
}

.delete-entry {
  grid-area: delete;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #656861;
  font-size: 1.08rem;
  line-height: 1;
}

.delete-entry:hover {
  background: #ecebe3;
  color: #24241f;
}

.empty-state {
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ledger-actions {
  min-height: 46px;
  margin-top: 8px;
  border-top: 1px solid rgba(223, 222, 213, 0.72);
}

.soft-button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.4);
  color: #494943;
  font-size: 0.88rem;
}

.soft-button.clear {
  border-color: transparent;
  background: transparent;
}

.daily-lesson {
  margin-top: 24px;
}

.daily-lesson > h2 {
  margin: 0 0 14px;
  font-size: 1.04rem;
}

.reflection-card {
  padding-bottom: 14px;
}

.quote-line {
  color: #62675f;
  font-size: 0.86rem;
}

.reflection-card textarea {
  min-height: 64px;
  margin-top: 8px;
  font-size: 0.95rem;
}

.reflection-card textarea::placeholder {
  color: #9b9d97;
}

.copy-full {
  width: 100%;
  min-height: 38px;
  margin-top: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  color: #20201c;
  font-weight: 760;
}

.copy-full:hover {
  background: #ededdf;
}

.save-state {
  display: block;
  min-height: 1.5em;
  margin-top: 10px;
  text-align: right;
  color: var(--muted);
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10;
  border-radius: 999px;
  padding: 9px 14px;
  background: #171713;
  color: white;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.toast.show {
  opacity: 1;
}

.review-shell {
  padding-bottom: 44px;
}

.subtle,
.muted-text {
  color: var(--muted);
  font-size: 0.86rem;
}

.subtle {
  margin-top: 4px;
}

.range-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
}

.range-tab {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.range-tab:hover {
  background: #efeee7;
}

.range-tab.active {
  background: #181914;
  color: white;
  box-shadow: 0 6px 18px rgba(24, 25, 20, 0.14);
}

.review-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
  text-align: center;
}

.review-summary article {
  min-height: 78px;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 1px solid rgba(223, 222, 213, 0.85);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
}

.review-summary strong {
  font-size: 1.48rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.review-summary span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.trend-card,
.review-list-card {
  margin-top: 16px;
}

.distribution {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  gap: 22px;
  margin-top: 18px;
}

.donut-chart {
  position: relative;
  width: 190px;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: drop-shadow(0 12px 18px rgba(60, 60, 50, 0.08));
}

.donut-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.donut-svg path {
  outline: none;
  transition: opacity 140ms ease, transform 140ms ease;
  transform-origin: center;
}

.donut-svg path:hover,
.donut-svg path:focus,
.chart-selected {
  opacity: 0.82;
}

.donut-svg path,
.stack-segment {
  cursor: pointer;
  touch-action: manipulation;
}

.chart-tooltip {
  position: fixed;
  z-index: 100;
  max-width: calc(100vw - 16px);
  padding: 8px 12px;
  border-radius: 6px;
  background: #262923;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.donut-hole {
  position: absolute;
  inset: 34px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px solid rgba(223, 222, 213, 0.9);
  border-radius: 50%;
  background: var(--panel-solid);
  text-align: center;
}

.donut-hole strong {
  font-size: 1.66rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.donut-hole span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.donut-legend {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 12px 1fr 42px 44px;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.legend-row strong,
.legend-row em {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.stacked-trend {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(34px, 1fr);
  align-items: end;
  gap: 8px;
  min-height: 160px;
  margin-top: 18px;
  overflow-x: auto;
  padding: 4px 2px 2px;
}

.trend-day {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 8px;
  min-width: 34px;
}

.stacked-bar {
  width: 22px;
  min-height: 0;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e7df;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.035);
}

.stack-segment {
  outline: none;
  transition: opacity 140ms ease, filter 140ms ease;
}

.stack-segment:hover,
.stack-segment:focus {
  filter: brightness(1.08);
  opacity: 0.84;
}

.stack-segment.good {
  background: var(--good);
}

.stack-segment.unwholesome {
  background: var(--bad);
}

.stack-segment.aware {
  background: var(--aware);
}

.stack-segment.unclear {
  background: var(--unclear);
}

.trend-date {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.trend-note {
  margin-top: 14px;
  border-top: 1px solid rgba(223, 222, 213, 0.9);
  padding-top: 12px;
  color: #565b54;
  font-size: 0.9rem;
  line-height: 1.55;
}

.review-days {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.review-day-card {
  border: 1px solid rgba(223, 222, 213, 0.9);
  border-radius: 14px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.52);
}

.review-day-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-day-card header span {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.day-summary {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.86rem;
}

.review-day-card dl {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px 10px;
  margin: 13px 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.review-day-card dt {
  color: var(--muted);
}

.review-day-card dd {
  margin: 0;
  min-width: 0;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 16px, 768px);
    padding-top: 8px;
  }

  .today-card,
  .review-hero,
  .trend-card,
  .review-list-card,
  .reflection-card {
    padding: 16px 10px 12px;
    border-radius: 16px;
  }

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

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .counters,
  .review-summary {
    gap: 6px;
  }

  .counter,
  .review-summary article {
    min-height: 72px;
  }

  .counter strong,
  .review-summary strong {
    font-size: 1.36rem;
  }

  .mark-buttons {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .ledger-meta {
    align-items: flex-start;
  }

  .ledger-meta {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .entry {
    grid-template-columns: 12px minmax(0, 1fr) auto 36px;
    align-items: center;
    min-height: 44px;
  }

  .entry-dot {
    margin-top: 0;
  }

  .delete-entry {
    width: 36px;
    height: 36px;
  }

  input,
  .note-drawer textarea,
  .reflection-card textarea {
    font-size: 16px;
  }

  .copy-full {
    min-height: 44px;
  }

  .ledger-actions {
    align-items: center;
  }

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

  .distribution {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 18px;
  }

  .donut-chart {
    width: min(190px, 70vw);
  }

  .donut-legend {
    width: 100%;
  }

  .review-day-card dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
