:root {
  --bg: #c5d2c3;
  --bg2: #a7bba6;
  --wash: #b3c6b4;
  --ink: #1f2b22;
  --muted: #5c6b60;
  --card: #ffffff;
  --line: rgba(31, 43, 34, 0.12);
  --shadow: 0 8px 22px rgba(40, 60, 45, 0.10);
  --purple: #3d8b6e;
  --purple-deep: #2f6e57;
  --gold: #17c47a;
  --mint: #17c47a;
  --mint-deep: #0ea968;
  --coral: #ff5d73;
  --coral-deep: #e6455c;
  --sky: #4da3ff;
  --key: #ffffff;
  --key-ink: #1f2b22;
  --key-shadow: #b4c4b3;
  --ok: #0ead69;
  --danger: #e23d4a;
  --toast: #1f2b22;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg2: #141a22;
  --wash: #000000;
  --ink: #f0f0fa;
  --muted: #8b919c;
  --card: #0a0c0e;
  --line: rgba(240, 240, 250, 0.16);
  --shadow: none;
  --mint: #3ee0a0;
  --mint-deep: #1fb87a;
  --ok: #3ee0a0;
  --key: #0a0c0e;
  --key-ink: #f0f0fa;
  --key-shadow: transparent;
  --toast: #000000;
  --radius: 10px;
  color-scheme: dark;
}

@font-face {
  font-family: D-DIN;
  src: url("fonts/D-DIN.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: D-DIN-Bold;
  src: url("fonts/D-DIN-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  font-size: 18px;
}

body {
  font-family: D-DIN, Arial, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--bg2), transparent 55%),
    radial-gradient(900px 500px at -10% 110%, var(--wash), transparent 50%),
    var(--bg);
  min-height: 100dvh;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

.app {
  width: min(430px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  position: relative;
  z-index: 1;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 0 rgba(43, 33, 80, 0.08));
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--key-shadow);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn:active {
  transform: translateY(1px);
}

.theme-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.logout {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--key-shadow);
  font-weight: 800;
  font-size: 0.95rem;
}

.logout:active {
  transform: translateY(1px);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  text-align: center;
  padding: 8px 8px 18px;
}

.mascot {
  width: 150px;
  height: 150px;
  margin: 4px auto 8px;
}

.hero h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
}

.hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.pin-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 22px 0 18px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--mint);
  background: transparent;
  transition: transform 0.12s ease, background 0.12s ease;
}

.pin-dot.filled {
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(23, 196, 122, 0.22);
  transform: scale(1.08);
}

.pin-wrap.shake {
  animation: shake 0.42s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

body.gated {
  background: #050505;
  color: #c8c8c8;
  font-family: "DejaVu Sans Mono", "Liberation Mono", "Ubuntu Mono", "Terminus", "Consolas", "Courier New", monospace;
}

body.gated .app {
  width: 100%;
  min-height: 100dvh;
  padding: 0;
}

.lock {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-bottom));
}

.lock-box {
  width: min(360px, 100%);
}

.lock-box.shake {
  animation: shake 0.42s ease;
}

.lock-input {
  width: 100%;
  min-height: 52px;
  border: 1px solid #3a3a3a;
  border-radius: 0;
  padding: 0 12px;
  background: #0a0a0a;
  color: #33cc33;
  font-family: inherit;
  font-size: 1rem;
  caret-color: #33cc33;
}

.lock-input:focus {
  outline: 1px solid #33cc33;
  outline-offset: 0;
}

.lock-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border-radius: 0;
  border: 1px solid #33cc33;
  background: #050505;
  color: #33cc33;
  font-family: inherit;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lock-btn:active {
  background: #33cc33;
  color: #050505;
}

.lock-msg {
  min-height: 24px;
  margin: 12px 0 0;
  text-align: left;
  font-size: 0.9rem;
  color: #cc3333;
}

.msg {
  min-height: 28px;
  text-align: center;
  font-weight: 800;
  color: var(--danger);
  margin: 0 0 10px;
}

.msg.ok {
  color: var(--ok);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.keypad .key:nth-child(11) {
  grid-column: 2;
}

.key {
  height: 74px;
  border-radius: 16px;
  background: var(--key);
  color: var(--key-ink);
  box-shadow: 0 2px 0 var(--key-shadow);
  font-size: 1.8rem;
  font-weight: 800;
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--key-shadow);
}

.key.ghost {
  font-size: 1.45rem;
}

.hello {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.hello > div,
.kid-info {
  min-width: 0;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  flex: 0 0 auto;
  box-shadow: 0 2px 0 rgba(43, 33, 80, 0.08);
  overflow: hidden;
  padding: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar.tap {
  box-shadow: 0 2px 0 rgba(43, 33, 80, 0.08);
}

.kid-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hello h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.hello p {
  margin: 3px 0 0;
  color: var(--muted);
}

.balance {
  padding: 22px 18px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
}

.balance::after {
  content: none;
}

.balance .label {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.balance .sum {
  margin: 4px 0 0;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
}

.balance .sum.pulse {
  animation: pulse 0.45s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

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

.big-btn {
  min-height: 84px;
  border-radius: 16px;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.big-btn span {
  font-size: 1.6rem;
  line-height: 1;
}

.big-btn.in {
  background: var(--mint-deep);
  box-shadow: 0 2px 0 #0b7a4b;
}

.big-btn.out {
  background: var(--coral-deep);
  box-shadow: 0 2px 0 #b13245;
}

.big-btn:active {
  transform: translateY(1px);
}

.section-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.tx {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  align-items: center;
}

.tx-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.3rem;
  flex: 0 0 auto;
}

.tx-badge.in {
  background: rgba(23, 196, 122, 0.18);
  color: var(--mint-deep);
}

.tx-badge.out {
  background: rgba(255, 93, 115, 0.16);
  color: var(--coral-deep);
}

[data-theme="dark"] .tx-badge.in {
  background: rgba(62, 224, 160, 0.12);
  color: #7dffc4;
}

[data-theme="dark"] .tx-badge.out {
  background: rgba(255, 93, 115, 0.12);
  color: #ff9aa8;
}

.tx-body {
  flex: 1;
  min-width: 0;
}

.tx-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.tx-note {
  color: var(--muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.tx-after {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.amount-in { color: var(--mint-deep); }
.amount-out { color: var(--coral-deep); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.panel .lead {
  margin: 0 0 16px;
  color: var(--muted);
}

.amount-show {
  text-align: center;
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  margin: 8px 0 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--line);
  font-weight: 800;
}

.chip.on {
  background: var(--mint);
  color: #fff;
  border-color: transparent;
}

.field {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: var(--card);
  padding: 0 14px;
  margin-bottom: 12px;
  font-size: 1rem;
}

.row-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  min-height: 58px;
  border-radius: 16px;
  font-weight: 900;
  font-size: 1.05rem;
}

.btn.primary {
  background: var(--mint);
  color: #fff;
  box-shadow: 0 2px 0 var(--mint-deep);
}

.btn.primary:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 var(--mint-deep);
}

.btn.good {
  background: var(--mint-deep);
  color: #fff;
  box-shadow: 0 2px 0 #0b7a4b;
}

.btn.good:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 #0b7a4b;
}

.btn.ghost {
  background: var(--card);
  box-shadow: 0 1px 0 var(--key-shadow);
}

.btn.warn {
  background: var(--coral-deep);
  color: #fff;
  box-shadow: 0 2px 0 #b13245;
}

.kid {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.kid-info {
  flex: 1;
  min-width: 0;
}

.kid-info h3 {
  margin: 0;
  font-size: 1.15rem;
}

.kid-info p {
  margin: 2px 0 0;
  color: var(--muted);
}

.kid-saldo {
  color: var(--ink) !important;
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.tiny {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(23, 196, 122, 0.16);
  font-weight: 800;
}

.hello .tiny {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 0.85rem;
  vertical-align: middle;
}

.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px 14px;
  margin-bottom: 14px;
}

.block > .section-title {
  margin: 0 0 12px;
}

.block .card {
  box-shadow: none;
}

.block .lead {
  margin: 0 0 12px;
}

.kid.allowance {
  margin-bottom: 6px;
}

.allowance-chips {
  margin: 0 0 14px;
}

.stack {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(400px, calc(100% - 24px));
  background: var(--toast);
  color: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
  z-index: 5;
  animation: up 0.25s ease;
}

@keyframes up {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.swatch,
.emo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  border: 3px solid transparent;
  font-size: 1.4rem;
}

.swatch.on,
.emo.on {
  border-color: var(--ink);
  transform: scale(1.06);
}

.emo {
  background: var(--card);
  box-shadow: 0 1px 0 var(--key-shadow);
  overflow: hidden;
}

.emo.pic {
  padding: 0;
}

.emo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

h1,
h2,
.brand h1,
.hero h2,
.hello h2,
.panel h2,
.kid-info h3,
.balance .sum,
.balance .label,
.amount-show,
.kid-saldo,
.section-title,
.btn,
.key,
.chip,
.tiny,
.logout,
.msg,
.toast,
.tx-top {
  font-family: D-DIN-Bold, Arial, Verdana, sans-serif;
  font-weight: 400;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(900px 420px at 50% -18%, #1a222c, transparent 58%),
    #000;
}

[data-theme="dark"] button:focus-visible,
[data-theme="dark"] input:focus-visible {
  outline: 1px solid #f0f0fa;
  outline-offset: 3px;
}

[data-theme="dark"] .logo-mark {
  filter: none;
}

[data-theme="dark"] .brand h1 {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-theme="dark"] .brand p,
[data-theme="dark"] .balance .label,
[data-theme="dark"] .section-title,
[data-theme="dark"] .block > .section-title {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

[data-theme="dark"] .balance .sum,
[data-theme="dark"] .amount-show,
[data-theme="dark"] .kid-saldo {
  letter-spacing: 0.02em;
}

[data-theme="dark"] .card,
[data-theme="dark"] .block {
  box-shadow: none;
  background: #0a0c0e;
}

[data-theme="dark"] .block .card {
  background: transparent;
}

[data-theme="dark"] .icon-btn,
[data-theme="dark"] .logout,
[data-theme="dark"] .btn.ghost,
[data-theme="dark"] .key,
[data-theme="dark"] .chip,
[data-theme="dark"] .emo {
  background: transparent;
  box-shadow: none;
  border: 1px solid rgba(240, 240, 250, 0.28);
}

[data-theme="dark"] .logout {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

[data-theme="dark"] .key {
  border-radius: 8px;
}

[data-theme="dark"] .chip.on {
  background: #f0f0fa;
  color: #000000;
  border-color: #f0f0fa;
}

[data-theme="dark"] .pin-dot {
  border-color: #f0f0fa;
}

[data-theme="dark"] .pin-dot.filled {
  background: #f0f0fa;
  box-shadow: 0 0 0 4px rgba(240, 240, 250, 0.16);
}

[data-theme="dark"] .avatar,
[data-theme="dark"] .avatar.tap {
  box-shadow: none;
}

[data-theme="dark"] .big-btn {
  box-shadow: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

[data-theme="dark"] .big-btn.in {
  background: transparent;
  color: #7dffc4;
  border: 1px solid rgba(62, 224, 160, 0.45);
  box-shadow: none;
}

[data-theme="dark"] .big-btn.out {
  background: transparent;
  color: #ff9aa8;
  border: 1px solid rgba(255, 93, 115, 0.45);
  box-shadow: none;
}

[data-theme="dark"] .btn.primary {
  background: #f0f0fa;
  color: #000000;
  box-shadow: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-theme="dark"] .btn.primary:active {
  box-shadow: none;
}

[data-theme="dark"] .btn.good {
  background: transparent;
  color: #7dffc4;
  border: 1px solid rgba(62, 224, 160, 0.45);
  box-shadow: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-theme="dark"] .btn.good:active {
  box-shadow: none;
}

[data-theme="dark"] .btn.warn {
  background: transparent;
  color: #ff9aa8;
  border: 1px solid rgba(255, 93, 115, 0.45);
  box-shadow: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-theme="dark"] .btn.ghost {
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-theme="dark"] .tiny {
  background: rgba(240, 240, 250, 0.08);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

[data-theme="dark"] .field {
  background: #000000;
  border: 1px solid rgba(240, 240, 250, 0.22);
  border-radius: 8px;
}

[data-theme="dark"] .toast {
  background: #000000;
  color: #f0f0fa;
  border: 1px solid rgba(240, 240, 250, 0.28);
  box-shadow: none;
  letter-spacing: 0.04em;
}

[data-theme="dark"] .amount-in {
  color: #7dffc4;
}

[data-theme="dark"] .amount-out {
  color: #ff9aa8;
}

@media (max-width: 390px) {
  .key,
  .big-btn {
    height: 70px;
    min-height: 70px;
  }
  .amount-show,
  .balance .sum {
    font-size: 2.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
