:root {
  color: #111;
  background: #ededed;
  font-family: "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: #d6d6d6;
}

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

button {
  cursor: pointer;
  transition: background-color .22s ease, color .22s ease, border-color .22s ease, box-shadow .22s ease, transform .18s ease, opacity .22s ease;
}

button:active:not(:disabled) { transform: scale(0.98); }

#shell, .gate {
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 12px 40px;
  background: #f7f7f7;
}

.gate {
  padding: 72px 20px;
  background: #f7f7f7;
}

.gate h1, .nav {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #000;
  letter-spacing: 0;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 52px;
  margin: 0 -12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ededed;
  border-bottom: 1px solid #d8d8d8;
}

.section-head, .month-bar, .item-top, .sum-line, .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint, .status, .field-label, .sum-line {
  color: #888;
}

.cat-row {
  display: flex;
  gap: 4px;
  margin: 0 0 10px;
}

.cat {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  padding: 7px 1px;
  background: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  color: #333;
  font-family: inherit;
  cursor: pointer;
}

.cat strong {
  color: #000;
  font-size: 13px;
  transition: color .22s ease;
}

.cat.on {
  background: #8a8a8a;
  color: #fff;
}

.cat.on strong { color: #fff; }

.who {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px 0 18px;
}

.avatar-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
}

.avatar {
  display: block;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #d9d9d9;
}

.avatar.letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07c160;
  color: #fff;
  font-size: 32px;
  font-weight: 600;
}

.who-name {
  width: 100%;
  margin: 8px 0 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #111;
}

.actions { margin: 10px 0 14px; }

.actions .solid {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 2px;
  font-size: 12px;
}

#stars { background: #c4a15a; }

.star-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: auto;
  margin: 4px 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #576b95;
  font-size: 15px;
  text-align: left;
}

#star-mark {
  color: #c4a15a;
  font-size: 24px;
  line-height: 1;
}

#star-mark.on { color: #e0a106; }

#export { background: #e87812; }

#charts { background: #2f6fce; }

#charts.on {
  background: #163a6b;
  box-shadow: 0 6px 14px rgba(22, 58, 107, 0.38);
  transform: translateY(-1px);
}

#charts.on:active { transform: translateY(-1px) scale(0.98); }

.chart-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px 12px 8px;
  margin-bottom: 10px;
}

.chart-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.pie { width: 180px; height: 180px; display: block; margin: 0 auto; }

.line-chart { width: 100%; height: auto; display: block; }

#pie, #line { transform-origin: center top; }

#pie.swap, #line.swap {
  animation: chart-rise .48s cubic-bezier(.2, .8, .2, 1);
}

@keyframes chart-rise {
  from { opacity: .35; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.rise {
  animation: rise .34s cubic-bezier(.2, .8, .2, 1) both;
}

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

.legend { margin-top: 8px; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
  color: #333;
}

.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: block;
}

.legend-row span { flex: 1; }

.legend-row b { font-weight: 600; color: #111; font-variant-numeric: tabular-nums; }

.sum-line { margin: 4px 2px 8px; font-size: 13px; }

#heading {
  color: #000;
  font-size: 16px;
  font-weight: 600;
}

.sum-line strong {
  color: #000;
  font-size: 16px;
}

.chips, .pills, .modes, .mini {
  display: flex;
  gap: 6px;
}

.chips { margin: 0 0 10px; flex-wrap: wrap; }

.pills { flex-wrap: wrap; }

.chip, .pill, .mode, .ghost, .text {
  border: 0;
  background: transparent;
  color: #576b95;
}

.chip, .mode {
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
}

.chip.on, .mode.on {
  background: #07c160;
  color: #fff;
}

.pill {
  border-radius: 4px;
  padding: 6px 10px;
  border: 1px solid #e5e5e5;
  background: #fff;
  color: #111;
  font-size: 14px;
}

.ghost, .solid, .text {
  border-radius: 6px;
  padding: 0 12px;
  height: 40px;
}

.ghost {
  border: 1px solid #07c160;
  color: #07c160;
  background: #fff;
}

.solid {
  border: 0;
  background: #07c160;
  color: #fff;
  font-weight: 600;
}

.solid:disabled, .ghost:disabled { opacity: 0.45; cursor: default; }

.text { color: #576b95; height: auto; padding: 8px 0; }

.custom {
  display: block;
  margin: 0 0 12px;
}

.custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-range input { width: auto; flex: 1; }

.custom .hint { margin: 8px 2px; }

input[type="date"], input[type="text"], input:not([type]), textarea {
  width: 100%;
  border: 0;
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
}

textarea { min-height: 96px; resize: vertical; }

.custom-range input { width: auto; }

.item, dialog form, .mini {
  background: #fff;
  border-radius: 8px;
}

.item {
  padding: 14px 14px 12px;
  margin-bottom: 8px;
}

.item h3 {
  margin: 8px 0 4px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: #000;
}

.tag { font-size: 12px; color: #888; font-weight: 400; }

.muted { color: #888; font-size: 12px; }

a.origin {
  display: block;
  margin-top: 6px;
  color: #576b95;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-all;
  text-decoration: none;
}

.empty {
  padding: 36px 0;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.month-bar { margin: 4px 0 8px; }

.today-link { display: block; margin: 0 auto 8px; }

.week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.week span, .day {
  text-align: center;
  min-height: 40px;
}

.week span { color: #999; font-size: 12px; padding-top: 6px; }

.day {
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #111;
}

.day span { color: #fa5151; font-size: 11px; transition: color .22s ease; }

.day.today { color: #07c160; font-weight: 600; }

.day.on, .day.on span { background: #07c160; color: #fff; }

.day:disabled { visibility: hidden; }

.mini { padding: 8px 0; margin-bottom: 8px; }

.mini div { flex: 1; text-align: center; }

.mini strong { display: block; font-size: 16px; color: #000; }

.mini span { color: #888; font-size: 12px; }

.section-head { margin: 8px 0; }

.section-head h2 { margin: 0; font-size: 16px; }

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(400px, calc(100% - 24px));
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition:
    opacity .3s ease,
    transform .3s cubic-bezier(.2, .8, .2, 1),
    overlay .3s ease allow-discrete,
    display .3s ease allow-discrete;
}

dialog[open] {
  opacity: 1;
  transform: none;
}

@starting-style {
  dialog[open] {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

dialog::backdrop {
  background-color: transparent;
  transition:
    background-color .3s ease,
    overlay .3s ease allow-discrete,
    display .3s ease allow-discrete;
}

dialog[open]::backdrop { background-color: rgba(0, 0, 0, 0.45); }

@starting-style {
  dialog[open]::backdrop { background-color: transparent; }
}

dialog form {
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -16px -16px 8px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.dialog-head h2 { margin: 0; }

.dialog-head .text { height: auto; padding: 0; font-size: 16px; }

.field-label { display: block; margin: 12px 0 6px; font-size: 13px; }

.modes, .pills { margin: 10px 0; }

#link-pane .solid, #manual-pane .solid, #save-edit, #parse, #save-links, #confirm-export {
  width: 100%;
  margin-top: 12px;
}

#export-range {
  color: #111;
  font-weight: 600;
  margin-bottom: 0;
}

#export-error { margin: 8px 0 0; font-size: 13px; }

#export-error:empty { display: none; }

.draft {
  margin-top: 10px;
  padding: 10px;
  border-radius: 6px;
  background: #f7f7f7;
}

.draft input { margin-top: 8px; }

.danger { color: #fa5151; }

#delete-edit {
  display: block;
  width: 100%;
  margin-top: 4px;
  text-align: center;
}

.status { min-height: 20px; margin: 8px 2px 0; font-size: 13px; }

.status:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
