:root {
  color-scheme: light;
  --ink: #26313d;
  --muted: #697586;
  --line: #e7dcd2;
  --paper: #fffaf3;
  --panel: rgba(255, 255, 255, 0.86);
  --mint: #84d7b5;
  --rose: #ff8fa3;
  --sun: #ffd166;
  --sky: #84c5f4;
  --grape: #b69cff;
  --shadow: 0 18px 50px rgba(62, 48, 30, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 209, 102, 0.36), transparent 28%),
    radial-gradient(circle at 92% 6%, rgba(132, 197, 244, 0.32), transparent 27%),
    linear-gradient(135deg, #fff7ec 0%, #f3fbff 52%, #fff1f5 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 0 calc(40px + env(safe-area-inset-bottom));
}

.hero {
  min-height: 280px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: center;
  gap: 28px;
  padding: 32px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 243, 0.58)),
    repeating-linear-gradient(45deg, rgba(255, 143, 163, 0.12) 0 12px, transparent 12px 24px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 12px;
  color: #d95c73;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 680px;
  font-size: clamp(2.2rem, 5vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.subtitle {
  max-width: 530px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.install-button {
  min-height: 42px;
  background: #9be7f2;
  box-shadow: 0 8px 0 #62bfd0;
}

.install-button:hover {
  box-shadow: 0 6px 0 #62bfd0;
}

.status-chip {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 2px solid rgba(47, 53, 66, 0.12);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.68);
  color: #34745b;
  font-size: 0.82rem;
  font-weight: 900;
}

.mascot-scene {
  position: relative;
  min-height: 250px;
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(1px);
}

.blob-one {
  width: 260px;
  height: 180px;
  right: 32px;
  bottom: 18px;
  background: rgba(132, 215, 181, 0.45);
}

.blob-two {
  width: 170px;
  height: 170px;
  right: 168px;
  top: 22px;
  background: rgba(255, 209, 102, 0.45);
}

.mascot {
  position: absolute;
  right: 86px;
  bottom: 16px;
  width: 168px;
  height: 188px;
  border: 5px solid #2f3542;
  border-radius: 48% 48% 42% 42%;
  background: linear-gradient(160deg, #fff 0 38%, #ffe1e8 39% 100%);
  box-shadow: 0 16px 0 rgba(38, 49, 61, 0.08);
}

.ear {
  position: absolute;
  top: -42px;
  width: 58px;
  height: 76px;
  border: 5px solid #2f3542;
  border-bottom: 0;
  background: #fdfdfd;
}

.ear-left {
  left: 12px;
  border-radius: 36px 36px 16px 18px;
  transform: rotate(-12deg);
}

.ear-right {
  right: 12px;
  border-radius: 36px 36px 18px 16px;
  transform: rotate(12deg);
}

.face {
  position: absolute;
  inset: 36px 24px auto;
  height: 62px;
}

.eye {
  position: absolute;
  top: 10px;
  width: 17px;
  height: 23px;
  border-radius: 999px;
  background: #26313d;
}

.eye-left {
  left: 22px;
}

.eye-right {
  right: 22px;
}

.mouth {
  position: absolute;
  left: 50%;
  top: 40px;
  width: 36px;
  height: 18px;
  border-bottom: 5px solid #26313d;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.belly {
  position: absolute;
  left: 50%;
  bottom: 20px;
  display: grid;
  place-items: center;
  width: 72px;
  height: 56px;
  border-radius: 999px;
  background: #fff8c9;
  color: #e19b20;
  font-size: 2rem;
  font-weight: 900;
  transform: translateX(-50%);
}

.coin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 4px solid #2f3542;
  border-radius: 999px;
  background: var(--sun);
  font-weight: 900;
}

.coin-one {
  right: 264px;
  top: 40px;
}

.coin-two {
  right: 42px;
  top: 74px;
  background: var(--sky);
}

.coin-three {
  right: 250px;
  bottom: 42px;
  background: var(--rose);
}

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

.summary-card,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.summary-card {
  padding: 18px;
}

.summary-card span,
label,
.category-topline p,
.expense-row p {
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 2.7vw, 2.2rem);
  line-height: 1;
}

.summary-card.accent {
  background: linear-gradient(135deg, rgba(132, 215, 181, 0.95), rgba(255, 255, 255, 0.76));
}

.panel-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.panel[data-size="small"] {
  grid-column: span 3;
}

.panel[data-size="medium"] {
  grid-column: span 6;
}

.panel[data-size="large"] {
  grid-column: span 12;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 2px solid rgba(47, 53, 66, 0.12);
  border-radius: 12px;
  padding: 0;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.size-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 2px solid rgba(47, 53, 66, 0.12);
  border-radius: 12px;
  padding: 0;
  background: #fff0b8;
  box-shadow: none;
  color: #996b00;
  font-size: 0.82rem;
  font-weight: 900;
}

.size-toggle:hover,
.drag-handle:hover {
  transform: translateY(1px);
  box-shadow: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle::before {
  content: "⋮⋮";
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -2px;
  transform: rotate(90deg);
}

.panel.is-dragging {
  opacity: 0.56;
}

.panel.drag-target {
  outline: 3px solid rgba(132, 197, 244, 0.62);
  outline-offset: 4px;
}

.panel-title h2 {
  margin-right: auto;
  font-size: 1.2rem;
}

.pill {
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff0b8;
  color: #996b00;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

form,
.income-box,
.category-list,
.expense-list,
.category-form {
  display: grid;
  gap: 12px;
}

#expenseForm {
  grid-template-columns: 1fr 1fr;
}

#expenseForm label:first-child,
#expenseForm button {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  font-size: 16px;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fffdf9;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(132, 197, 244, 0.2);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  color: #26313d;
  background: var(--sun);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 #dca847;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  transform: translateY(2px);
  box-shadow: 0 6px 0 #dca847;
}

.ghost-button {
  min-height: 36px;
  background: #fff3f5;
  color: #bf4d63;
  box-shadow: none;
}

.icon-text-button {
  min-height: 36px;
  border-radius: 999px;
  padding-inline: 13px;
  background: #9be7f2;
  box-shadow: none;
}

.ghost-button.danger {
  background: #ffe9ec;
  color: #ad344d;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.income-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.category-row,
.expense-row {
  border: 1px solid #f0e4da;
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 253, 249, 0.74);
}

.category-topline,
.expense-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.category-icon,
.expense-dot {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid #2f3542;
  border-radius: 14px;
  background: var(--mint);
  font-weight: 900;
}

.category-topline h3,
.expense-row h3 {
  font-size: 1rem;
  line-height: 1.25;
}

.category-topline strong,
.expense-row strong {
  white-space: nowrap;
}

.progress-track {
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0ebe5;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sky), var(--rose));
  transition: width 220ms ease;
}

.expense-list {
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.empty-state {
  padding: 26px 14px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.6);
}

.form-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 10px;
}

input[type="color"] {
  height: 46px;
  padding: 5px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.compact-label {
  display: grid;
  grid-template-columns: auto 110px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.compact-label select {
  min-height: 36px;
  border-radius: 10px;
  padding-block: 6px;
}

.year-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.year-stats article {
  min-height: 68px;
  border: 1px solid #f0e4da;
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 253, 249, 0.72);
}

.year-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.year-stats strong {
  display: block;
  margin-top: 8px;
  font-size: 1.1rem;
}

.year-category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.year-category-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(47, 53, 66, 0.12);
  border-radius: 999px;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--chip-color) 28%, white);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

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

.month-row {
  min-height: 92px;
  border: 1px solid #f0e4da;
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 253, 249, 0.74);
}

.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.month-head h3 {
  font-size: 1rem;
}

.month-head strong {
  font-size: 0.95rem;
  white-space: nowrap;
}

.month-bars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.month-category {
  display: inline-grid;
  grid-template-columns: 24px auto;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 8px 4px 4px;
  background: rgba(255, 255, 255, 0.72);
}

.month-category > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid #2f3542;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.month-category p {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.month-category strong {
  display: none;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.mini-track {
  display: none;
  height: 7px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe8df;
}

.mini-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sky));
}

.mini-empty {
  width: 100%;
  padding: 14px 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.mini-empty.compact {
  padding: 4px 0 8px;
  text-align: left;
}

.cute-dialog {
  width: min(420px, calc(100vw - 34px));
  border: 0;
  border-radius: 28px;
  padding: 68px 24px 22px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 209, 102, 0.38), transparent 28%),
    linear-gradient(145deg, #ffffff 0%, #fff7ec 48%, #f1fbff 100%);
  box-shadow: 0 26px 80px rgba(38, 49, 61, 0.26);
  text-align: center;
  overflow: visible;
}

.cute-dialog::backdrop {
  background: rgba(38, 49, 61, 0.34);
  backdrop-filter: blur(7px);
}

.cute-dialog[open] {
  animation: popIn 180ms ease-out;
}

.dialog-mascot {
  position: absolute;
  left: 50%;
  top: -44px;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border: 4px solid #2f3542;
  border-radius: 36px 36px 42px 42px;
  background: linear-gradient(160deg, #fff 0 45%, #ffe1e8 46% 100%);
  box-shadow: 0 12px 0 rgba(38, 49, 61, 0.08);
  transform: translateX(-50%);
}

.dialog-ear {
  position: absolute;
  top: -25px;
  width: 28px;
  height: 42px;
  border: 4px solid #2f3542;
  border-bottom: 0;
  background: #fff;
}

.dialog-ear.left {
  left: 12px;
  border-radius: 20px 20px 8px 8px;
  transform: rotate(-12deg);
}

.dialog-ear.right {
  right: 12px;
  border-radius: 20px 20px 8px 8px;
  transform: rotate(12deg);
}

.dialog-face {
  display: grid;
  place-items: center;
  width: 42px;
  height: 34px;
  border-radius: 999px;
  background: #fff8c9;
  color: #d78a13;
  font-size: 1.45rem;
  font-weight: 900;
}

.cute-dialog h2 {
  font-size: 1.28rem;
}

.category-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 20px;
  text-align: left;
}

.install-dialog {
  width: min(390px, calc(100vw - 28px));
  padding: 20px;
  text-align: left;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.close-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 999px;
  padding: 0;
  background: #fff3f5;
  color: #bf4d63;
  box-shadow: none;
  font-size: 1.35rem;
  line-height: 1;
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
  padding-left: 22px;
  color: var(--ink);
  line-height: 1.55;
}

.install-steps li::marker {
  color: #d95c73;
  font-weight: 900;
}

.cute-dialog p {
  max-width: 320px;
  margin: 10px auto 20px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.65;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.danger-button {
  color: #fff;
  background: #ff6f8b;
  box-shadow: 0 8px 0 #c94c63;
}

.danger-button:hover {
  box-shadow: 0 6px 0 #c94c63;
}

.soft-button {
  background: #9be7f2;
  box-shadow: 0 8px 0 #62bfd0;
}

.soft-button:hover {
  box-shadow: 0 6px 0 #62bfd0;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .hero,
  .panel-board {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .budget-panel,
  .timeline-panel,
  .yearly-panel,
  .panel[data-size] {
    grid-column: 1;
  }

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

  .mascot-scene {
    min-height: 230px;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 14px, 1180px);
    padding-top: calc(7px + env(safe-area-inset-top));
  }

  .hero {
    position: relative;
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 13px 118px 13px 13px;
    border-radius: 18px;
    overflow: hidden;
  }

  .hero-copy {
    position: relative;
    z-index: 2;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 0.74rem;
  }

  h1 {
    font-size: clamp(1.62rem, 10vw, 2.35rem);
    line-height: 1;
  }

  .subtitle {
    margin-top: 8px;
    font-size: 0.88rem;
    line-height: 1.38;
  }

  .hero-actions,
  .install-button,
  .status-chip {
    width: 100%;
  }

  .hero-actions {
    align-items: stretch;
    margin-top: 10px;
  }

  .mascot-scene {
    position: absolute;
    top: 18px;
    right: 8px;
    display: block;
    width: 112px;
    min-height: 142px;
    z-index: 1;
    pointer-events: none;
  }

  .mascot {
    right: 14px;
    bottom: 0;
    width: 84px;
    height: 94px;
    border-width: 4px;
  }

  .ear {
    top: -26px;
    width: 28px;
    height: 42px;
    border-width: 4px;
  }

  .ear-left {
    left: 8px;
  }

  .ear-right {
    right: 8px;
  }

  .face {
    inset: 22px 14px auto;
    height: 44px;
  }

  .eye {
    top: 5px;
    width: 10px;
    height: 15px;
  }

  .eye-left {
    left: 13px;
  }

  .eye-right {
    right: 13px;
  }

  .mouth {
    top: 27px;
    width: 24px;
    height: 12px;
    border-bottom-width: 4px;
  }

  .belly {
    bottom: 10px;
    width: 42px;
    height: 32px;
    font-size: 1.15rem;
  }

  .blob-one {
    right: 0;
    bottom: 2px;
    width: 110px;
    height: 84px;
  }

  .blob-two {
    right: 50px;
    top: 4px;
    width: 72px;
    height: 72px;
  }

  .coin {
    width: 28px;
    height: 28px;
    border-width: 3px;
    font-size: 0.78rem;
  }

  .coin-one {
    right: 86px;
    top: 15px;
  }

  .coin-two {
    right: 0;
    top: 40px;
  }

  .coin-three {
    right: 86px;
    bottom: 28px;
  }

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

  .summary-card {
    padding: 13px;
  }

  .summary-card strong {
    font-size: 1.35rem;
  }

  .summary-card,
  .panel,
  .category-row,
  .expense-row,
  .month-row {
    border-radius: 16px;
  }

  .panel {
    padding: 12px;
  }

  .panel-board,
  .category-list,
  .expense-list,
  .category-form {
    gap: 10px;
  }

  .panel-title {
    align-items: flex-start;
  }

  .panel-actions {
    flex-wrap: nowrap;
  }

  .panel-actions .ghost-button {
    min-height: 34px;
    padding-inline: 10px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .panel-title h2 {
    font-size: 1.08rem;
  }

  .button-row,
  .month-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr 74px;
  }

  .year-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .year-stats article {
    min-height: 62px;
    padding: 9px;
  }

  .year-stats span {
    font-size: 0.74rem;
  }

  .year-stats strong {
    font-size: 0.88rem;
  }

  .category-topline,
  .expense-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .category-topline strong,
  .expense-row strong {
    grid-column: 2;
    justify-self: start;
  }

  .cute-dialog {
    padding-inline: 18px;
  }

  .category-dialog {
    padding: 16px;
  }

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

@media (max-width: 360px) {
  .hero {
    padding-right: 98px;
  }

  .mascot-scene {
    right: 2px;
    width: 98px;
    transform: scale(0.88);
    transform-origin: top right;
  }
}
