:root {
  color-scheme: light dark;
  --bg: #f3f4f0;
  --surface: rgba(255,255,255,.82);
  --surface-solid: #fff;
  --ink: #171914;
  --muted: #73766e;
  --line: rgba(31,34,27,.09);
  --accent: #2b674c;
  --accent-soft: #dcebe2;
  --expense: #a34b43;
  --expense-soft: #f5e4e0;
  --income: #347053;
  --income-soft: #dfede5;
  --transfer: #4d5f8a;
  --transfer-soft: #e3e8f3;
  --shadow: 0 22px 60px rgba(41,45,36,.10);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100svh; color: var(--ink); background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 2px; }

.app-page {
  background:
    radial-gradient(circle at 8% -4%, color-mix(in srgb, var(--accent-soft) 50%, transparent), transparent 33rem),
    var(--bg);
}

.app-shell { width: min(100%, 780px); min-height: 100svh; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 18px calc(104px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 24px; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(30px, 8vw, 42px); line-height: 1; letter-spacing: -.04em; }
.eyebrow, .card-kicker { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 21px; cursor: pointer; transition: transform .16s ease, background .16s ease; }
.icon-button:active { transform: scale(.94); }
.logout-button { min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 680; cursor: pointer; transition: transform .16s ease, color .16s ease, background .16s ease; }
.logout-button:active { transform: scale(.96); color: var(--ink); background: var(--surface-solid); }

.view { display: none; animation: view-in .24s ease both; }
.view.is-active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

.balance-card { position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,.56); border-radius: var(--radius-xl); padding: 24px; background: linear-gradient(145deg, rgba(255,255,255,.94), rgba(247,249,244,.78)); box-shadow: var(--shadow); }
.balance-card::after { content: ""; position: absolute; width: 220px; height: 220px; right: -90px; top: -110px; border-radius: 50%; background: color-mix(in srgb, var(--accent-soft) 72%, transparent); filter: blur(2px); }
.total-balance { position: relative; z-index: 1; margin: 10px 0 26px; font-size: clamp(39px, 11vw, 58px); font-weight: 680; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.currency { color: var(--muted); font-size: .42em; letter-spacing: 0; margin-left: 5px; }
.accounts { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.account { padding: 13px 12px; border-radius: var(--radius-md); background: rgba(237,240,234,.78); border: 1px solid rgba(255,255,255,.56); min-width: 0; }
.account-name { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.account-value { display: block; overflow: hidden; font-size: clamp(14px, 4vw, 18px); font-weight: 650; letter-spacing: -.02em; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 34px; }
.action-button { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-height: 92px; padding: 15px; border: 0; border-radius: var(--radius-lg); font-size: 14px; font-weight: 650; cursor: pointer; transition: transform .16s ease, filter .16s ease; }
.action-button span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-size: 20px; font-weight: 720; box-shadow: 0 5px 14px rgba(24,28,22,.12); }
.action-button:active { transform: scale(.96); filter: brightness(.97); }
.action-button.expense { color: var(--expense); background: var(--expense-soft); }
.action-button.income { color: var(--income); background: var(--income-soft); }
.action-button.transfer { color: var(--transfer); background: var(--transfer-soft); }
.action-button.expense span { background: var(--expense); }
.action-button.income span { background: var(--income); }
.action-button.transfer span { background: var(--transfer); }

.analytics-entry { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 72px; margin: -16px 0 34px; padding: 12px 15px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: left; cursor: pointer; transition: transform .16s ease, background .16s ease; }
.analytics-entry:active { transform: scale(.985); background: var(--surface-solid); }
.analytics-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; color: var(--accent); background: var(--accent-soft); font-size: 24px; font-weight: 750; }
.analytics-entry strong, .analytics-entry small { display: block; }
.analytics-entry strong { font-size: 15px; }
.analytics-entry small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.analytics-entry > i { color: var(--muted); font-size: 27px; font-style: normal; }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 10px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-heading span { color: var(--muted); font-size: 12px; }
.recent-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.recent-item { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; width: 100%; min-height: 72px; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.recent-item:last-child { border-bottom: 0; }
.recent-item:active { background: color-mix(in srgb, var(--surface-solid) 60%, var(--accent-soft)); }
.recent-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: var(--bg); font-size: 17px; }
.recent-icon.expense { color: var(--expense); background: var(--expense-soft); }
.recent-icon.income { color: var(--income); background: var(--income-soft); }
.recent-icon.transfer { color: var(--transfer); background: var(--transfer-soft); }
.recent-main strong, .recent-main small { display: block; }
.recent-main strong { font-size: 15px; }
.recent-main small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.recent-amount { font-weight: 670; font-variant-numeric: tabular-nums; }
.recent-amount.income { color: var(--income); }
.recent-amount.expense { color: var(--expense); }
.recent-amount.transfer { color: var(--transfer); }
.empty-state { margin: 0; padding: 26px; color: var(--muted); text-align: center; }
.empty-state.compact { padding: 20px; font-size: 13px; }

.analytics-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.analytics-heading h2 { margin: 0; font-size: 32px; letter-spacing: -.045em; }
.analytics-heading p { margin: 7px 0 20px; color: var(--muted); line-height: 1.45; }
.period-filter { display: flex; gap: 5px; overflow-x: auto; margin: 0 -2px 26px; padding: 2px 2px 5px; scrollbar-width: none; }
.period-filter::-webkit-scrollbar { display: none; }
.period-button { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.period-button.is-active { border-color: transparent; color: #fff; background: var(--accent); }
.analytics-content { display: grid; gap: 26px; }
.analytics-loading { padding: 40px; color: var(--muted); text-align: center; }
.analytics-section-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 9px; }
.analytics-section-heading h3 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.analytics-section-heading span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.analytics-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.analytics-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 10px; align-items: center; gap: 10px; width: 100%; min-height: 68px; padding: 10px 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.analytics-row:last-child { border-bottom: 0; }
.analytics-row:active { background: var(--bg); }
.analytics-row-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; font-size: 16px; }
.analytics-row-icon.expenses { color: var(--expense); background: var(--expense-soft); }
.analytics-row-icon.income { color: var(--income); background: var(--income-soft); }
.analytics-row-icon.transfers { color: var(--transfer); background: var(--transfer-soft); }
.analytics-row-main { min-width: 0; }
.analytics-row-main strong, .analytics-row-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analytics-row-main strong { font-size: 14px; }
.analytics-row-main small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.analytics-row-total { font-size: 13px; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.analytics-row > i { color: var(--muted); font-size: 20px; font-style: normal; }
.analytics-detail-list { display: grid; gap: 10px; }
.analytics-detail-item { padding: 15px; border-radius: var(--radius-md); background: var(--bg); }
.analytics-detail-item > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.analytics-detail-item strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.analytics-detail-item span, .analytics-detail-item small { color: var(--muted); font-size: 12px; }
.analytics-detail-item small { display: block; margin-top: 7px; }
.analytics-detail-item p { margin: 9px 0 0; font-size: 13px; line-height: 1.45; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; width: min(calc(100% - 32px), 450px); padding: 6px; border: 1px solid rgba(255,255,255,.56); border-radius: 23px; background: color-mix(in srgb, var(--surface-solid) 84%, transparent); box-shadow: 0 16px 45px rgba(31,35,28,.16); backdrop-filter: blur(18px); transform: translateX(-50%); }
.nav-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 0; border-radius: 17px; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-button span { font-size: 17px; }
.nav-button.is-active { color: var(--ink); background: var(--surface-solid); box-shadow: 0 4px 14px rgba(24,27,21,.08); }
.nav-button:active { transform: scale(.97); }

.emotion-intro { position: relative; overflow: hidden; min-height: 490px; padding: 28px; border-radius: var(--radius-xl); background: linear-gradient(160deg, #f7eee6, #e7eee7 55%, #dfe6ef); box-shadow: var(--shadow); }
.emotion-intro h2 { position: relative; margin: 118px 0 10px; max-width: 320px; font-size: clamp(36px, 10vw, 52px); line-height: .98; letter-spacing: -.055em; }
.emotion-intro p:not(.card-kicker) { position: relative; max-width: 340px; margin: 0 0 26px; color: #5f675f; font-size: 16px; line-height: 1.5; }
.soft-orb { position: absolute; width: 225px; height: 225px; right: -42px; top: -45px; border-radius: 48% 52% 57% 43%; background: radial-gradient(circle at 36% 32%, #fff6d9, #dbb9ad 48%, #9dabb8); filter: blur(.2px); box-shadow: inset -18px -24px 60px rgba(61,61,72,.18); }
.emotion-flow { min-height: 560px; }
.flow-topline { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.text-button { min-height: 42px; padding: 0; border: 0; background: transparent; color: var(--accent); font-weight: 650; cursor: pointer; }
.progress-track { overflow: hidden; height: 4px; margin: 8px 0 28px; border-radius: 5px; background: var(--line); }
.progress-track i { display: block; width: 20%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .28s ease; }
.step h2 { margin: 0 0 8px; font-size: 30px; line-height: 1.06; letter-spacing: -.045em; }
.step-copy { margin: 0 0 20px; color: var(--muted); line-height: 1.45; }
.segment-control { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 15px; padding: 4px; border-radius: 16px; background: var(--line); scrollbar-width: none; }
.segment-control::-webkit-scrollbar { display: none; }
.segment-button { flex: 1 0 auto; min-height: 38px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 620; cursor: pointer; }
.segment-button.is-active { color: var(--ink); background: var(--surface-solid); box-shadow: 0 2px 10px rgba(28,31,25,.06); }
.chip-grid { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 238px; }
.choice-chip { min-height: 42px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; cursor: pointer; transition: transform .14s ease, color .14s ease, background .14s ease; }
.choice-chip:active { transform: scale(.96); }
.choice-chip.is-selected { border-color: transparent; color: #f6faf7; background: var(--accent); }
.flow-next { width: 100%; margin-top: 24px; }
.range-card { padding: 28px 22px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); }
.range-value { margin: 0 0 16px; font-size: 66px; font-weight: 690; letter-spacing: -.065em; text-align: center; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 32px; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

.emotion-result article { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); }
.result-check { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 20px; border-radius: 50%; color: #fff; background: var(--accent); font-size: 24px; }
.emotion-result h2 { margin: 0 0 18px; font-size: 30px; letter-spacing: -.04em; }
.summary-text { padding: 18px; border-radius: var(--radius-md); background: var(--bg); white-space: pre-wrap; font-size: 14px; line-height: 1.65; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.primary-button, .secondary-button, .danger-button { min-height: 52px; padding: 0 20px; border: 0; border-radius: 17px; font-weight: 680; cursor: pointer; transition: transform .15s ease, opacity .15s ease; }
.primary-button { color: #fff; background: var(--accent); }
.secondary-button { background: var(--line); }
.danger-button { color: #fff; background: var(--expense); }
.primary-button:active, .secondary-button:active, .danger-button:active { transform: scale(.97); }
.primary-button:disabled { opacity: .55; cursor: wait; }

.sheet { width: 100%; max-width: none; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; }
.sheet::backdrop { background: rgba(18,20,17,.34); backdrop-filter: blur(3px); }
.sheet[open] { display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: min(100%, 560px); max-height: min(88svh, 760px); overflow: auto; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; background: var(--surface-solid); box-shadow: 0 -18px 60px rgba(20,22,18,.16); animation: sheet-up .25s cubic-bezier(.2,.8,.25,1) both; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .5; } }
.sheet-handle { width: 38px; height: 5px; margin: 0 auto 16px; border-radius: 10px; background: var(--line); }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.sheet-heading h2, .compact-sheet h2 { margin: 3px 0 0; font-size: 28px; letter-spacing: -.04em; }
.field { display: block; margin-bottom: 20px; }
.field > span { display: block; margin: 0 0 8px 3px; color: var(--muted); font-size: 13px; font-weight: 620; }
.field input { width: 100%; height: 58px; padding: 0 17px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.option-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.option-button { min-height: 50px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 13px; cursor: pointer; }
.option-button.is-selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 680; }
.category-options { grid-template-columns: repeat(2, 1fr); }
.form-error { min-height: 18px; margin: 10px 0; color: var(--expense); font-size: 13px; }
#money-submit { width: 100%; }
.compact-sheet .sheet-card { padding-top: 12px; }
.muted-copy { color: var(--muted); line-height: 1.5; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); padding: 12px 17px; border-radius: 999px; color: #fff; background: #242720; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.login-page { display: grid; place-items: center; padding: 28px 20px; background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 36rem), var(--bg); }
.login-shell { width: min(100%, 390px); padding: 34px; border: 1px solid rgba(255,255,255,.6); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); }
.login-mark { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 30px; border-radius: 17px; color: #fff; background: var(--accent); font-size: 22px; font-weight: 750; }
.login-shell h1 { margin: 6px 0 10px; font-size: 34px; letter-spacing: -.045em; }
.login-copy { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }
.login-form label { display: block; margin-bottom: 15px; }
.login-form label span { display: block; margin: 0 0 7px 3px; color: var(--muted); font-size: 13px; }
.login-form input { width: 100%; height: 52px; padding: 0 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--bg); }
.login-form .primary-button { width: 100%; }

@media (min-width: 700px) {
  .app-shell { padding-top: 42px; }
  .balance-card { padding: 32px; }
  .accounts { grid-template-columns: repeat(4, 1fr); }
  .action-button { min-height: 106px; }
  .emotion-intro { min-height: 560px; padding: 36px; }
  .emotion-intro h2 { margin-top: 154px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11130f;
    --surface: rgba(31,34,29,.82);
    --surface-solid: #20231e;
    --ink: #f2f3ee;
    --muted: #999d94;
    --line: rgba(235,239,230,.10);
    --accent: #7ebb9a;
    --accent-soft: #223d2f;
    --expense: #e18b82;
    --expense-soft: #392421;
    --income: #8fc7a5;
    --income-soft: #20352a;
    --transfer: #a5b5dd;
    --transfer-soft: #252d42;
    --shadow: 0 22px 65px rgba(0,0,0,.28);
  }
  .balance-card { border-color: var(--line); background: linear-gradient(145deg, #252922, #1b1e1a); }
  .account { border-color: var(--line); background: rgba(12,14,11,.28); }
  .bottom-nav { border-color: var(--line); background: rgba(26,29,24,.86); }
  .emotion-intro { background: linear-gradient(160deg, #312823, #233029 55%, #222a35); }
  .emotion-intro p:not(.card-kicker) { color: #b4bab2; }
  .soft-orb { opacity: .72; filter: brightness(.68) saturate(.7); }
  .choice-chip.is-selected, .primary-button, .period-button.is-active { color: #102117; }
  .login-shell { border-color: var(--line); }
}

@media (max-width: 410px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .balance-card { padding: 21px; }
  .recent-item { grid-template-columns: 40px minmax(0, 1fr) auto; padding-left: 11px; padding-right: 11px; }
  .recent-amount { font-size: 12px; }
  .analytics-row { grid-template-columns: 38px minmax(0, 1fr) auto 8px; gap: 8px; padding-left: 10px; padding-right: 10px; }
  .analytics-row-total { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
