:root {
  color: #3f3128;
  background: #f4e7d3;
  font-family:
    "Trebuchet MS",
    "Microsoft YaHei",
    "PingFang SC",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 6%, rgba(255, 248, 235, 0.88), transparent 28rem),
    linear-gradient(180deg, #f4e7d3 0%, #f0dbc0 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 32rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.wallet-workspace {
  padding-top: max(2rem, env(safe-area-inset-top));
}

.wallet-title-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.wallet-title-row h1 {
  margin: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.28rem;
  font-weight: 900;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 999px;
  background: #fff8ee;
  color: #8c4e23;
  box-shadow: 0 0.5rem 1.5rem rgba(94, 55, 27, 0.12);
  font-size: 1.2rem;
  font-weight: 800;
}

.balance-card {
  position: relative;
  min-height: 14.5rem;
  padding: 2.4rem 1.5rem 1.8rem;
  overflow: hidden;
  border-radius: 2rem;
  background:
    linear-gradient(145deg, rgba(255, 251, 244, 0.95), rgba(247, 213, 168, 0.98)),
    #fff6e9;
  box-shadow: 0 1rem 2.6rem rgba(93, 57, 29, 0.18);
  text-align: center;
}

.balance-card p {
  position: relative;
  z-index: 1;
  margin: 0 0 0.9rem;
  color: #806b58;
  font-size: 0.95rem;
  font-weight: 700;
}

.balance-value {
  position: relative;
  z-index: 1;
  color: #5b331f;
  font-size: clamp(2.45rem, calc(22rem / max(var(--balance-length, 6), 6)), 5.25rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

.balance-orb {
  position: absolute;
  border-radius: 999px;
  opacity: 0.32;
}

.balance-orb-right {
  right: -3.5rem;
  top: -3.3rem;
  width: 9rem;
  height: 9rem;
  background: #d99b58;
}

.balance-orb-left {
  left: -2.8rem;
  bottom: -3.4rem;
  width: 7.5rem;
  height: 7.5rem;
  background: #8c4e23;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin: 1.15rem 0 1.6rem;
}

.action-button {
  display: flex;
  min-width: 0;
  height: 4.4rem;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border-radius: 1.45rem;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 0.75rem 1.8rem rgba(93, 57, 29, 0.14);
}

.action-button-primary {
  background: linear-gradient(135deg, #9a5929, #6d3d22);
  color: #fffaf2;
}

.action-button-secondary {
  background: #fff8ee;
  color: #7b4a2d;
}

.action-icon {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #7b4a2d;
  font-size: 1.35rem;
  line-height: 1;
}

.history-section {
  padding-bottom: 2rem;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.history-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0;
}

.history-header span {
  color: #8a735f;
  font-size: 0.88rem;
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 0.75rem;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.05rem;
  border-radius: 1.35rem;
  background: rgba(255, 248, 238, 0.92);
  box-shadow: 0 0.45rem 1.4rem rgba(93, 57, 29, 0.09);
}

.history-main {
  min-width: 0;
}

.history-title-line {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 0.55rem;
}

.history-type {
  flex: 0 0 auto;
  font-weight: 900;
}

.history-note {
  min-width: 0;
  overflow: hidden;
  color: #817060;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  margin-top: 0.35rem;
  color: #9b8774;
  font-size: 0.82rem;
  font-weight: 700;
}

.history-amount {
  font-size: 1.08rem;
  font-weight: 900;
  white-space: nowrap;
}

.money-in {
  color: #287248;
}

.money-out {
  color: #b25536;
}

.history-empty {
  padding: 1.5rem 1rem;
  border-radius: 1.3rem;
  color: #8a735f;
  background: rgba(255, 248, 238, 0.72);
  text-align: center;
  font-size: 0.94rem;
  font-weight: 700;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(54, 37, 25, 0.42);
}

.modal-mask[hidden] {
  display: none;
}

.transaction-modal {
  width: min(88vw, 26rem);
  border-radius: 2rem;
  background: #fff8ee;
  box-shadow: 0 1.4rem 3rem rgba(51, 30, 19, 0.24);
}

.transaction-header {
  position: relative;
  padding: 1.35rem 3.4rem 1rem;
}

.transaction-header h2 {
  margin: 0;
  text-align: center;
  font-size: 1.22rem;
  font-weight: 900;
  letter-spacing: 0;
}

.modal-close {
  position: absolute;
  right: 1rem;
  top: 0.85rem;
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: 999px;
  background: #f2e2cd;
  color: #68402a;
  font-size: 1.5rem;
  line-height: 1;
}

.transaction-form {
  display: grid;
  gap: 1rem;
  padding: 0.4rem 1.25rem 1.45rem;
}

.form-field {
  display: grid;
  gap: 0.45rem;
  color: #51443b;
  font-weight: 800;
}

.form-field input,
.amount-input-shell {
  width: 100%;
  height: 3.35rem;
  border: 0;
  border-radius: 999px;
  outline: 0;
  background: #f3e6d5;
  color: #49372c;
  font-weight: 800;
}

.form-field input {
  padding: 0 1.05rem;
}

.amount-input-shell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 1.05rem;
}

.amount-prefix {
  color: #8d5f39;
  font-weight: 900;
}

.amount-input-shell input {
  height: 100%;
  padding: 0;
  background: transparent;
}

.form-error {
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  background: rgba(178, 85, 54, 0.12);
  color: #9c442f;
  font-size: 0.9rem;
  font-weight: 800;
}

.form-error[hidden] {
  display: none;
}

.submit-button {
  display: flex;
  width: 100%;
  height: 3.75rem;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #9a5929, #6d3d22);
  color: #fffaf2;
  font-size: 1.08rem;
  font-weight: 900;
  box-shadow: 0 0.75rem 1.8rem rgba(93, 57, 29, 0.16);
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.submit-icon {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border-radius: 999px;
  background: #fffaf2;
  color: #7b4a2d;
  font-size: 1.18rem;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(90vw, 24rem);
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: rgba(55, 37, 24, 0.9);
  color: #fffaf2;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

@media (min-width: 46rem) {
  body {
    padding: 2rem 0;
  }

  .app-shell {
    min-height: calc(100vh - 4rem);
    border-radius: 2.3rem;
    background: rgba(244, 231, 211, 0.68);
    box-shadow: 0 1rem 3.5rem rgba(78, 48, 27, 0.14);
  }
}
