:root {
  --paper: #ffffff;
  --paper-deep: #f3f3f3;
  --card: #ffffff;
  --ink: #111111;
  --muted: #8a8a8a;
  --line: #ececec;
  --clay: #111111;
  --clay-deep: #111111;
  --sage: #111111;
  --sage-soft: #f6f6f6;
  --danger: #9b2f2f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  --radius: 22px;
  --track: #f0f0f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
}

body {
  min-height: 100vh;
  min-height: var(--tg-h, 100dvh);
}

.paper {
  display: none;
}

#root {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 120px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.hello {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.month-nav button,
.icon-btn,
.chip,
.btn,
.fab,
.dot,
.item-main {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.month-nav button,
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.month-label {
  min-width: 92px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.slides {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.slide {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 16px 14px;
  color: inherit;
  box-shadow: var(--shadow);
}

.slide-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.slide-top span {
  font-size: 15px;
  font-weight: 700;
}

.slide-top b {
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.slide-track {
  height: 8px;
  border-radius: 99px;
  background: var(--track);
  overflow: hidden;
}

.slide-track i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: #111;
  width: 0;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 5;
  min-width: 58px;
  height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ledger-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.ledger-sum {
  margin-top: 6px;
  font-family: Fraunces, Georgia, serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.ledger-sum.tight {
  color: var(--clay-deep);
}

.rows {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.row b {
  color: var(--ink);
  font-weight: 700;
}

.ledger-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  font-weight: 700;
}

.btn.primary {
  background: #111;
  color: #fff;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.clay {
  background: var(--clay);
  color: white;
}

.btn.wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.btn.danger {
  background: transparent;
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 8px 4px 12px;
}

.section-head h2 {
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 650;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

.shelves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.shelf {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(48, 28, 12, 0.08);
  text-align: left;
  color: inherit;
}

.shelf-cover {
  height: 110px;
  background:
    linear-gradient(180deg, rgba(36, 25, 16, 0.04), rgba(36, 25, 16, 0.18)),
    var(--paper-deep);
  background-size: cover;
  background-position: center;
}

.shelf-cover.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.shelf-body {
  padding: 10px 12px 12px;
}

.shelf-body h3 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.shelf-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  grid-column: 1 / -1;
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fafafa;
}

.empty b {
  display: block;
  color: var(--ink);
  font-size: 16px;
  margin-bottom: 6px;
}

.items {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px 10px 8px 6px;
  box-shadow: 0 10px 24px rgba(48, 28, 12, 0.08);
  text-align: left;
  color: inherit;
}

.item.bought {
  opacity: 0.62;
}

.dot {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border: 1.5px solid #111;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.dot.filled {
  background: #111;
}

.item-main {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.item-photo {
  min-height: 76px;
  height: 76px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-deep) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
}

.item-body {
  padding: 4px 4px 4px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.item-body h3 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.item.bought h3 {
  text-decoration: line-through;
}

.price {
  margin-top: 4px;
  font-family: Fraunces, Georgia, serif;
  font-size: 20px;
  font-weight: 650;
}

.fab span {
  font-size: 22px;
  line-height: 1;
  margin-top: -2px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.28);
  align-items: flex-end;
  justify-content: center;
}

.overlay:not([hidden]) {
  display: flex;
}

.sheet {
  width: min(560px, 100%);
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 14px 16px 28px;
  max-height: 92vh;
  overflow: auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-head h3 {
  font-family: Fraunces, Georgia, serif;
  font-size: 24px;
  margin: 0;
}

.sheet-x {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f2f2;
  color: #111;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.now-sum {
  font-family: Fraunces, Georgia, serif;
  font-size: 36px;
  font-weight: 650;
  letter-spacing: -0.04em;
  margin-top: 8px;
}

.now-label {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 16px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.stats div {
  background: #fafafa;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.stats span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stats b {
  font-size: 13px;
}

.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.spend-box {
  margin-top: 12px;
}

.spend-list {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.spend-list h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.spend-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f2f2f2;
}

.spend-row:last-child {
  border-bottom: 0;
}

.spend-row b {
  flex-shrink: 0;
  color: #8a2a2a;
  font-size: 14px;
}

.spend-row span {
  text-align: right;
  color: var(--ink);
  font-size: 14px;
}

.choice {
  display: grid;
  gap: 8px;
  margin: 8px 0 4px;
}

.choice .btn.on {
  background: #111;
  color: #fff;
  border-color: #111;
}

.when {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sheet-lead {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  margin: 8px 0 12px;
}

.added-title {
  font-family: Fraunces, Georgia, serif;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.04em;
  margin: 8px 0 6px;
}

.item-remind {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

label.field {
  display: block;
  margin-bottom: 12px;
}

label.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 12px;
  font: inherit;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 72px;
  resize: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.chip {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.chip.on {
  background: #111;
  color: #fff;
  border-color: #111;
}

.task-row .item-main {
  grid-template-columns: 1fr;
}

.task-row.rest {
  opacity: 0.45;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.photo-pick {
  display: block;
  border: 1px dashed var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--paper);
  min-height: 160px;
  margin-bottom: 12px;
  cursor: pointer;
}

.photo-pick img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.photo-pick .hint {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 6px;
  font-weight: 700;
}

.detail-photo {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 18px;
  background: var(--paper-deep);
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ink);
  color: #fffaf2;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  max-width: 80%;
}

.toast:not([hidden]) {
  display: block;
}

.back-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.back-row button {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 700;
}

.catalog-sum {
  color: var(--muted);
  margin-bottom: 14px;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 380px) {
  .shelves {
    grid-template-columns: 1fr;
  }
  .brand {
    font-size: 30px;
  }
}
