:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f7efd9;
  color: #29231b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(0deg, rgba(44, 36, 31, 0.035) 0 1px, transparent 1px 13px),
    repeating-linear-gradient(90deg, rgba(44, 36, 31, 0.025) 0 1px, transparent 1px 17px),
    linear-gradient(135deg, #fff7db 0%, #f7efe1 42%, #e4f2ee 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 14px;
}

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

.date {
  margin-bottom: 4px;
  color: #6d5a43;
  font-size: 14px;
  font-weight: 800;
}

h1 {
  max-width: 13ch;
  color: #2b2118;
  font-size: 34px;
  line-height: 1;
}

.badge {
  display: grid;
  place-items: center;
  flex: 0 0 76px;
  height: 76px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #ffcf4a;
  box-shadow: 0 6px 0 #2c241f;
  color: #2c241f;
  font-size: 15px;
  font-weight: 900;
  transform: rotate(3deg);
}

.badge span:first-child {
  font-size: 30px;
  line-height: 1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 12px;
}

.tab-button,
.small-button {
  min-height: 42px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 0 3px 0 #2c241f;
  color: #2c241f;
  font-weight: 900;
}

.tab-button.is-active {
  background: #9fc8ff;
  transform: translateY(2px);
  box-shadow: 0 1px 0 #2c241f;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 16px;
}

.summary-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 86px;
  padding: 12px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  box-shadow: 0 5px 0 #2c241f;
}

.today-tile {
  background: #fff0a8;
}

.bank-tile {
  background: #a9dfc2;
}

.summary-number {
  display: inline-grid;
  place-items: center;
  min-width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #fffaf0;
  color: #2c241f;
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
}

.summary-label {
  padding-left: 10px;
  color: #3f3428;
  font-size: 18px;
  font-weight: 900;
}

.view {
  display: none;
  padding-bottom: 24px;
}

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

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  font-size: 22px;
  line-height: 1.1;
}

.compact-heading {
  align-items: center;
  margin-top: 16px;
}

.mini-note {
  color: #725f48;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

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

.behavior-card {
  display: grid;
  grid-template-rows: 52px 40px 24px;
  align-items: center;
  justify-items: center;
  min-height: 142px;
  padding: 12px 8px 10px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: var(--card-bg, #ffffff);
  box-shadow: 0 5px 0 #2c241f;
  color: #2c241f;
  text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.behavior-card:active,
.small-button:active,
.action-button:active {
  box-shadow: 0 1px 0 #2c241f;
  transform: translateY(3px);
}

.behavior-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(44, 36, 31, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  font-size: 30px;
  line-height: 1;
}

.behavior-name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  color: #2c241f;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.behavior-stars {
  color: #5b4325;
  font-size: 15px;
  font-weight: 900;
}

.reward-list,
.manage-list,
.history-list {
  display: grid;
  gap: 9px;
}

.reward-row,
.manage-row,
.history-row,
.tool-panel {
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 4px 0 #2c241f;
}

.reward-row,
.manage-row,
.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px;
}

.reward-row strong,
.manage-row strong,
.history-row strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.15;
}

.reward-row span,
.manage-row span,
.history-row span {
  display: block;
  margin-top: 4px;
  color: #685640;
  font-size: 14px;
  font-weight: 800;
}

.history-row {
  grid-template-columns: 44px 1fr;
}

.history-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #2c241f;
  border-radius: 8px;
  background: #ffcf4a;
  font-size: 22px;
}

.tool-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
}

.tool-panel .field {
  margin-bottom: 0;
}

.manager-section {
  margin-top: 14px;
}

.settings-panel {
  margin-bottom: 12px;
}

.settings-panel summary {
  display: inline-grid;
  place-items: center;
  min-width: 132px;
  padding: 0 14px;
  list-style: none;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-panel .tool-panel {
  margin-top: 10px;
}

.empty-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 3px dashed #86715b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  color: #5e4d3d;
  font-size: 18px;
  font-weight: 900;
}

.behavior-grid .empty-state,
.behavior-grid .loading-state {
  grid-column: 1 / -1;
}

.dialog {
  width: min(calc(100% - 28px), 430px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(35, 28, 22, 0.52);
}

.dialog-panel {
  padding: 16px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #fff9e9;
  box-shadow: 0 8px 0 #2c241f;
}

.selected-sticker {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: -2px auto 8px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #ffcf4a;
  font-size: 38px;
  font-weight: 900;
  transform: rotate(-3deg);
}

.reward-sticker {
  background: #f5a7c8;
  font-size: 28px;
}

.dialog-title {
  min-height: 34px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 24px;
  line-height: 1.15;
}

.dialog-subtitle {
  margin-bottom: 12px;
  color: #6d5a43;
  text-align: center;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #4b3d30;
  font-size: 15px;
  font-weight: 900;
}

.field input {
  width: 100%;
  min-height: 48px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #fff;
  color: #2c241f;
  font-size: 19px;
  font-weight: 800;
  padding: 8px 10px;
}

.dialog-actions {
  display: grid;
  gap: 9px;
}

.action-button {
  min-height: 50px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  box-shadow: 0 4px 0 #2c241f;
  color: #2c241f;
  font-size: 18px;
  font-weight: 900;
}

.reward-button {
  background: #ffcf4a;
}

.work-button {
  background: #ff9a76;
}

.bank-button {
  background: #9fc8ff;
}

.cancel-button {
  background: #e7e1d4;
}

.dialog.is-reward-mode .behavior-only,
.dialog:not(.is-reward-mode) .reward-only {
  display: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  min-width: 148px;
  max-width: calc(100% - 28px);
  padding: 11px 14px;
  border: 3px solid #2c241f;
  border-radius: 8px;
  background: #2c241f;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  color: #fff8e8;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(100% + 28px));
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
  visibility: hidden;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

@media (min-width: 560px) {
  .app {
    padding: 22px;
  }

  h1 {
    font-size: 48px;
  }

  .behavior-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-panel {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }

  .tool-panel .action-button {
    min-width: 120px;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .cancel-button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 760px) {
  body {
    min-height: 100vh;
  }

  .app {
    width: min(100%, 980px);
    padding: 28px;
  }

  .topbar {
    min-height: 106px;
  }

  h1 {
    max-width: none;
    font-size: 56px;
  }

  .badge {
    flex-basis: 92px;
    height: 92px;
  }

  .badge span:first-child {
    font-size: 36px;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
  }

  .tab-button,
  .small-button {
    min-height: 48px;
  }

  .summary {
    gap: 16px;
    margin-bottom: 22px;
  }

  .summary-tile {
    min-height: 104px;
    padding: 16px;
  }

  .summary-number {
    min-width: 68px;
    height: 68px;
    font-size: 44px;
  }

  .summary-label {
    font-size: 22px;
  }

  .section-heading {
    margin-bottom: 14px;
  }

  .section-heading h2 {
    font-size: 26px;
  }

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

  .behavior-card {
    grid-template-rows: 58px 44px 26px;
    min-height: 158px;
    padding: 14px 10px 12px;
  }

  .behavior-icon {
    width: 58px;
    height: 58px;
    font-size: 34px;
  }

  .reward-list,
  .manage-list,
  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .tool-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 12px;
    padding: 14px;
  }

  .dialog {
    width: min(calc(100% - 56px), 520px);
  }

  #manageDialog {
    width: min(calc(100% - 56px), 640px);
  }

  #manageDialog .dialog-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  #manageDialog .cancel-button {
    grid-column: auto;
  }
}
