:root {
  color-scheme: light;
  --ink: #273044;
  --muted: #768095;
  --paper: rgba(255, 255, 255, 0.74);
  --line: rgba(103, 103, 148, 0.12);
  --lavender: #7c79d8;
  --lavender-dark: #5d5ab8;
  --mint: #65a889;
  --rose: #d97676;
  --shadow: 0 24px 70px rgba(83, 78, 130, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f7f5fc;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 2%, rgba(226, 218, 255, 0.62), transparent 34%),
    radial-gradient(circle at 95% 92%, rgba(211, 242, 228, 0.52), transparent 38%),
    linear-gradient(145deg, #fbfaff 0%, #f5f2fb 48%, #f8fbf9 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(124, 121, 216, 0.28);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(2px);
}

.ambient-one {
  top: 15%;
  left: -7rem;
  width: 19rem;
  height: 19rem;
  background: rgba(208, 195, 250, 0.22);
}

.ambient-two {
  right: -8rem;
  bottom: 8%;
  width: 23rem;
  height: 23rem;
  background: rgba(188, 226, 209, 0.2);
}

.ambient-three {
  top: -7rem;
  right: 18%;
  width: 14rem;
  height: 14rem;
  background: rgba(255, 226, 210, 0.16);
}

.home-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(100%, 1200px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) clamp(24px, 5vw, 70px)
    max(24px, env(safe-area-inset-bottom));
}

.name-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
}

.name-header h1 {
  margin: 0;
  color: #333a4f;
  font-size: clamp(1.2rem, 2.1vw, 1.6rem);
  font-weight: 650;
  letter-spacing: 0.22em;
}

.name-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a19de9, #72b59b);
  box-shadow: 0 0 0 5px rgba(124, 121, 216, 0.08);
}

.balance-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 7vh 0 4vh;
  text-align: center;
}

.eyebrow {
  margin: 0 0 20px;
  color: #85819f;
  font-size: clamp(0.76rem, 1.5vw, 0.9rem);
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.balance-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
  min-width: 0;
  color: #292c3b;
  text-shadow: 0 12px 32px rgba(60, 56, 100, 0.08);
}

.balance-number {
  font-size: clamp(4.6rem, 15vw, 11.5rem);
  font-weight: 730;
  line-height: 0.92;
  letter-spacing: -0.075em;
  font-variant-numeric: tabular-nums;
}

.balance-number.compact {
  font-size: clamp(3rem, 10vw, 7.5rem);
  letter-spacing: -0.065em;
}

.currency {
  color: #575d70;
  font-size: clamp(1.15rem, 3.5vw, 2.15rem);
  font-weight: 650;
  letter-spacing: 0.08em;
}

.warm-note {
  margin: clamp(26px, 4vw, 40px) 0 0;
  color: #888da0;
  font-size: clamp(0.88rem, 1.8vw, 1.02rem);
  letter-spacing: 0.08em;
}

.sync-status {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: #9a9dac;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.sync-status.error {
  color: #c96a6a;
}

.home-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #a1a4b1;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
}

.tiny-star {
  color: #aaa5e2;
}

/* Admin */
.admin-page {
  padding: max(24px, env(safe-area-inset-top)) 20px
    max(44px, env(safe-area-inset-bottom));
}

.admin-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  margin: 0 auto;
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(42px, 8vw, 72px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #666b7b;
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.back-link span {
  font-size: 1.15rem;
}

.admin-badge {
  padding: 8px 12px;
  border: 1px solid rgba(124, 121, 216, 0.14);
  border-radius: 999px;
  color: #6e6aa9;
  background: rgba(255, 255, 255, 0.52);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.admin-header {
  margin-bottom: 28px;
}

.admin-header .eyebrow {
  margin-bottom: 12px;
}

.admin-header h1 {
  margin: 0;
  color: #303448;
  font-size: clamp(2.15rem, 7vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.admin-header > p:last-child {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.7;
}

.admin-card {
  margin-top: 18px;
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.balance-card {
  overflow: hidden;
  background:
    radial-gradient(circle at 90% -10%, rgba(209, 203, 249, 0.42), transparent 42%),
    rgba(255, 255, 255, 0.76);
}

.balance-card > p:first-child,
.section-kicker {
  margin: 0;
  color: #8e91a0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.admin-balance-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 13px;
}

.admin-balance-line span:first-child {
  color: #303246;
  font-size: clamp(3rem, 12vw, 5.2rem);
  font-weight: 730;
  line-height: 1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.admin-balance-line span:last-child {
  color: #6f7484;
  font-size: 1.05rem;
  font-weight: 650;
}

.updated-text {
  margin: 16px 0 0;
  color: #9a9daa;
  font-size: 0.78rem;
}

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

.section-heading h2 {
  margin: 7px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.input-hint {
  color: #a0a2ad;
  font-size: 0.72rem;
  white-space: nowrap;
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  height: 72px;
  padding: 0 20px;
  border: 1px solid rgba(104, 104, 144, 0.12);
  border-radius: 20px;
  background: rgba(248, 247, 252, 0.86);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.amount-input-wrap:focus-within {
  border-color: rgba(124, 121, 216, 0.38);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 5px rgba(124, 121, 216, 0.07);
}

.input-currency {
  margin-right: 12px;
  color: #85899a;
  font-size: 1.25rem;
}

.amount-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #303347;
  background: transparent;
  font-size: clamp(1.6rem, 7vw, 2.25rem);
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.amount-input-wrap input::placeholder {
  color: #c0c1ca;
}

.amount-input-wrap input::-webkit-outer-spin-button,
.amount-input-wrap input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.amount-input-wrap input[type="number"] {
  -moz-appearance: textfield;
}

.input-unit {
  color: #8e91a0;
  font-size: 0.9rem;
}

.quick-values {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.quick-values button {
  min-height: 44px;
  border: 1px solid rgba(124, 121, 216, 0.1);
  border-radius: 14px;
  color: #66639b;
  background: rgba(124, 121, 216, 0.065);
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.quick-values button:hover {
  background: rgba(124, 121, 216, 0.12);
}

.quick-values button:active,
.action-button:active {
  transform: scale(0.98);
}

.quick-values button:disabled,
.action-button:disabled,
.amount-input-wrap input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  border: 0;
  border-radius: 17px;
  color: white;
  font-size: 0.96rem;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(60, 65, 100, 0.12);
  transition: transform 150ms ease, filter 150ms ease;
}

.action-button:hover {
  filter: brightness(1.035);
}

.action-button span {
  font-size: 1.22rem;
  line-height: 1;
}

.action-button.loading {
  filter: saturate(0.72);
}

.add-button {
  background: linear-gradient(135deg, #70b598, #5a9d82);
}

.subtract-button {
  background: linear-gradient(135deg, #e38b84, #d57373);
}

.form-message {
  min-height: 1.2em;
  margin: 14px 0 0;
  color: #74788a;
  font-size: 0.8rem;
  text-align: center;
}

.form-message.success {
  color: #4d9575;
}

.form-message.error {
  color: #c35f5f;
}

.history-card {
  margin-bottom: 30px;
}

.history-heading {
  margin-bottom: 12px;
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
}

.history-icon.add {
  color: #4d9575;
  background: rgba(101, 168, 137, 0.11);
}

.history-icon.subtract {
  color: #c96767;
  background: rgba(217, 118, 118, 0.11);
}

.history-copy strong,
.history-copy span {
  display: block;
}

.history-copy strong {
  color: #4a4d5e;
  font-size: 0.87rem;
}

.history-copy span {
  margin-top: 4px;
  color: #9a9ca7;
  font-size: 0.7rem;
}

.history-value {
  font-size: 0.92rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.history-value.add {
  color: #4d9575;
}

.history-value.subtract {
  color: #c96767;
}

.empty-history {
  margin: 0;
  padding: 22px 0 8px;
  color: #9b9da9;
  font-size: 0.84rem;
  text-align: center;
}

.storage-note {
  margin: 22px 0 8px;
  color: #9a9da9;
  font-size: 0.72rem;
  line-height: 1.7;
  text-align: center;
}

@media (max-width: 560px) {
  .home-shell {
    padding-right: 20px;
    padding-left: 20px;
  }

  .balance-line {
    gap: 8px;
  }

  .balance-number {
    font-size: clamp(4.3rem, 24vw, 7rem);
  }

  .balance-number.compact {
    font-size: clamp(2.8rem, 14vw, 4.6rem);
  }

  .admin-page {
    padding-right: 14px;
    padding-left: 14px;
  }

  .admin-card {
    border-radius: 24px;
  }

  .input-hint {
    display: none;
  }

  .history-item {
    grid-template-columns: 38px 1fr auto;
    gap: 10px;
  }

  .history-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
}

@media (max-width: 380px) {
  .quick-values {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-buttons {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .balance-hero,
  .admin-header,
  .admin-card {
    animation: gentle-in 580ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .admin-card:nth-of-type(2) {
    animation-delay: 70ms;
  }

  .admin-card:nth-of-type(3) {
    animation-delay: 120ms;
  }

  @keyframes gentle-in {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
