:root {
  color-scheme: light;
  --bg: #fbf4e7;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #fffdf8;
  --ink: #303236;
  --muted: #73777a;
  --selected: #55786d;
  --selected-strong: #42665c;
  --today: #ed8f6b;
  --rice: #f6bd60;
  --coffee: #b59072;
  --soft: #ffedb3;
  --line: rgba(48, 50, 54, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0)),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 18px 112px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 0 0 1px var(--line);
}

.icon-button:active {
  transform: scale(0.98);
}

.month-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

#monthTitle {
  text-align: center;
  font-size: 24px;
  font-weight: 850;
}

.calendar-wrap {
  margin-top: 18px;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-row {
  margin-bottom: 8px;
}

.weekday {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.weekday.sunday,
.weekday.saturday {
  font-weight: 900;
}

.weekday.sunday {
  color: #cf4e42;
}

.weekday.saturday {
  color: #3478b8;
}

.day-cell {
  position: relative;
  display: grid;
  grid-template-rows: 20px 22px;
  align-content: center;
  gap: 5px;
  width: 100%;
  aspect-ratio: 0.86;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.day-cell .number {
  font-size: 15px;
  font-weight: 800;
  line-height: 20px;
}

.day-cell .marks {
  min-width: 0;
  height: 22px;
  font-size: 14px;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.day-cell.sunday .number,
.day-cell.holiday .number {
  color: #cf4e42;
}

.day-cell.saturday:not(.holiday) .number {
  color: #3478b8;
}

.day-cell.outside {
  opacity: 0.36;
}

.day-cell.today {
  box-shadow: inset 0 0 0 2px var(--today);
}

.day-cell.selected {
  color: #ffffff;
  background: var(--selected);
  box-shadow: 0 10px 22px rgba(85, 120, 109, 0.24);
}

.day-cell.selected .number {
  color: #ffffff;
}

.selected-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-top: 14px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

#selectedRecordText {
  color: var(--selected-strong);
}

.bottom-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.86);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(50%, 260px);
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(48, 50, 54, 0.12);
}

.action-button.rice {
  background: var(--rice);
}

.action-button.coffee {
  background: var(--coffee);
}

.action-button.active-record {
  background: var(--selected);
}

.action-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: scale(0.985);
}

.modal {
  width: min(calc(100% - 32px), 460px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.modal::backdrop {
  background: rgba(48, 50, 54, 0.22);
  backdrop-filter: blur(3px);
}

.modal-content {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: 0 24px 72px rgba(48, 50, 54, 0.2);
}

.modal-handle {
  justify-self: center;
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(115, 119, 122, 0.32);
}

.modal h2 {
  font-size: 21px;
  font-weight: 850;
}

.modal p {
  color: var(--muted);
  font-weight: 700;
}

.amount-field {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.amount-field input {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(181, 144, 114, 0.42);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font-size: 21px;
  font-weight: 800;
  outline: none;
}

.amount-field input:focus {
  border-color: var(--selected);
  box-shadow: 0 0 0 3px rgba(85, 120, 109, 0.14);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  color: #ffffff;
  background: var(--selected);
}

.secondary-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}

.danger-button {
  color: #b34834;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(179, 72, 52, 0.18);
}

.danger-button[hidden] {
  display: none;
}

.modal-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

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

.stat-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.stat-row span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--soft);
  font-weight: 850;
}

.stat-row strong {
  font-size: 15px;
}

.stat-row b {
  color: var(--selected-strong);
  font-size: 16px;
}

.stat-row.total {
  background: #ffffff;
}

@media (max-width: 390px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .weekday-row,
  .calendar-grid {
    gap: 6px;
  }

  .day-cell {
    grid-template-rows: 18px 20px;
    gap: 3px;
  }

  .day-cell .number {
    font-size: 13px;
  }

  .day-cell .marks {
    font-size: 12px;
  }
}
