:root {
    --ink: #12100f;
    --paper: #e9e4d9;
    --white: #f6f1e8;
    --red: #b84a38;
    --red-deep: #913929;
    --red-soft: #c8624f;
    --acid: #d5dc8c;
    --line: rgba(18, 16, 15, .22);
    --pad: clamp(20px, 3.4vw, 58px);
    --sans: Arial, Helvetica, "PingFang SC", "Microsoft YaHei", sans-serif;
    --serif: Georgia, "Times New Roman", "Songti SC", serif;
    --mono: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { background: var(--ink); scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.5;
    letter-spacing: .028em;
    text-rendering: optimizeLegibility;
}

body.dialog-open { overflow: hidden; }

button,
input,
select { font: inherit; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

button,
a { color: inherit; }

a { text-decoration: none; }

button { cursor: pointer; }

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

[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    width: 100%;
    padding: 20px var(--pad);
    color: var(--ink);
    mix-blend-mode: difference;
    pointer-events: none;
}

.site-header > * { pointer-events: auto; }

.brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
    width: max-content;
    color: var(--white);
}

.brand strong {
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -.05em;
}

.brand span,
.header-line,
.profile-button,
.agent-button {
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .17em;
}

.header-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--white);
}

.agent-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid currentColor;
    padding: 8px 10px;
    background: transparent;
}

.agent-button:hover { background: var(--white); color: var(--ink); }
.agent-button.is-connected { border-color: var(--acid); color: var(--acid); }
.agent-button.is-connected::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.agent-button.is-connected.is-active::before { box-shadow: 0 0 0 4px rgba(213, 220, 140, .2); }

.sync-state {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 8px;
    letter-spacing: .13em;
}

.sync-state i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 0 rgba(246, 241, 232, .65);
    animation: sync-pulse 2.2s ease-out infinite;
}

.sync-state.is-offline { opacity: .58; }
.sync-state.is-offline i { animation: none; }
.sync-state b { font-weight: 700; }

@keyframes sync-pulse {
    55% { box-shadow: 0 0 0 0 rgba(246, 241, 232, .55); }
    100% { box-shadow: 0 0 0 7px rgba(246, 241, 232, 0); }
}

.header-line {
    margin: 2px 0 0;
    color: var(--white);
}

.profile-button {
    justify-self: end;
    border: 0;
    border-bottom: 1px solid currentColor;
    padding: 0 0 5px;
    background: transparent;
    color: var(--white);
}

.profile-short { display: none; }

.setup-screen {
    display: grid;
    min-height: 100svh;
    grid-template-columns: minmax(0, .82fr) minmax(540px, 1.18fr);
    background: #0c0d0b;
    color: #ded9cf;
}

.setup-intro {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100svh;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, .24);
    padding: clamp(96px, 12vh, 150px) var(--pad) clamp(34px, 5vh, 64px);
}

.setup-intro::after {
    position: absolute;
    right: 0;
    bottom: 30%;
    left: 0;
    height: 1px;
    background: rgba(255, 255, 255, .16);
    box-shadow: 0 11vh 0 rgba(255, 255, 255, .08), 0 22vh 0 rgba(255, 255, 255, .05);
    content: "";
}

.kicker,
.form-heading > span,
.panel-heading span,
.account-label > span,
.result-card > span {
    margin: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .2em;
}

.setup-intro .kicker { color: var(--acid); font-family: var(--mono); }

.setup-intro h1 {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    margin: auto 0;
    color: #e49345;
    font-family: var(--mono);
    font-size: clamp(96px, 11vw, 190px);
    font-weight: 900;
    line-height: .72;
    letter-spacing: -.065em;
    animation: title-in 850ms cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes title-in {
    from { opacity: 0; transform: translateY(34px); letter-spacing: -.11em; }
}

.setup-intro h1 span { transform: translateX(-.035em); }

.setup-intro h1 em {
    align-self: flex-end;
    margin-top: .18em;
    padding-right: .05em;
    font-family: var(--mono);
    font-style: normal;
    font-weight: 800;
    letter-spacing: -.07em;
}

.setup-lead {
    position: relative;
    z-index: 1;
    max-width: 19em;
    margin: 0;
    color: rgba(255, 255, 255, .54);
    font: 10px/1.8 var(--mono);
    letter-spacing: .04em;
    animation: fade-up 700ms 220ms ease both;
}

@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } }

.future-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(90px, 10vh, 130px) var(--pad) 40px;
    border-left: 1px solid rgba(255, 255, 255, .08);
    background: #111210;
    color: #ded9cf;
}

.form-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
    border-bottom: 1px solid rgba(255, 255, 255, .38);
    padding-bottom: 18px;
}

.form-heading p {
    max-width: 23em;
    margin: 0;
    color: rgba(255, 255, 255, .44);
    font-family: var(--mono);
    font-size: 9px;
    line-height: 1.6;
    text-align: right;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
}

.field-row > label {
    min-width: 0;
    padding: 23px 0 22px;
}

.field-row > label + label {
    border-left: 1px solid rgba(255, 255, 255, .2);
    padding-left: 26px;
}

.field-row label > span:first-child,
.optional-field > span:first-child,
.borrow-fields label > span {
    display: block;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
}

.future-form .form-heading > span,
.future-form .field-row label > span:first-child,
.future-form .growth-options legend,
.future-form .optional-field > span:first-child { color: var(--acid); font-family: var(--mono); font-size: 9px; letter-spacing: .13em; }

.input-unit {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.input-unit input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 0;
    background: transparent;
    color: #e49345;
    font-family: var(--mono);
    font-size: clamp(36px, 4vw, 64px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.035em;
}

.input-unit input::placeholder { color: rgba(255, 255, 255, .18); }

.input-unit i {
    font-size: 15px;
    font-style: normal;
    font-weight: 700;
}

.growth-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    padding: 22px 0 24px;
}

.growth-options legend {
    width: 100%;
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
}

.growth-options label { position: relative; }
.growth-options input { position: absolute; opacity: 0; }

.growth-options label span {
    display: flex;
    flex-direction: column;
    min-height: 63px;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, .2);
    border-right: 0;
    padding: 10px 12px;
    cursor: pointer;
}

.growth-options label:last-child span { border-right: 1px solid rgba(255, 255, 255, .2); }
.growth-options input:checked + span { background: var(--acid); color: var(--ink); }
.growth-options input:focus-visible + span { outline: 3px solid var(--acid); outline-offset: 2px; }
.growth-options b { font-size: 13px; }
.growth-options small { font-size: 10px; letter-spacing: .1em; }

.optional-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    padding: 16px 0;
}

.optional-field > span:first-child { margin: 0; }
.optional-field small { color: rgba(255, 255, 255, .38); font-weight: 400; }

.optional-field select,
.borrow-fields select,
.borrow-fields input {
    border: 1px solid var(--line);
    border-radius: 0;
    outline: 0;
    padding: 12px 14px;
    background: transparent;
    color: var(--ink);
}

.future-form .optional-field select { border-color: rgba(255, 255, 255, .24); background: #111210; color: #ded9cf; }

.optional-field select:focus,
.borrow-fields select:focus,
.borrow-fields input:focus { border-color: var(--ink); }

.calculate-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 24px;
    border: 0;
    padding: 18px 21px;
    background: var(--acid);
    color: var(--ink);
    font-size: clamp(18px, 1.55vw, 24px);
    font-weight: 800;
    letter-spacing: .035em;
    transition: background 180ms ease, color 180ms ease;
}

.calculate-button:hover { background: #e49345; color: var(--ink); }
.calculate-button b { font-size: 30px; font-weight: 400; transition: transform 220ms ease; }
.calculate-button:hover b { transform: translate(4px, 4px); }

.account-screen { min-height: 100svh; background: var(--paper); }

.account-hero {
    position: relative;
    min-height: 100svh;
    overflow: hidden;
    padding: 96px var(--pad) 34px;
    background: #0c0d0b;
    color: #ded9cf;
}

.terminal-meta {
    position: absolute;
    top: 88px;
    right: var(--pad);
    left: var(--pad);
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, .35);
    padding-top: 11px;
    color: rgba(255, 255, 255, .48);
    font: 9px/1.65 var(--mono);
    letter-spacing: .04em;
}

.terminal-meta p { margin: 0; }
.terminal-meta p:last-child { color: var(--acid); text-align: right; }

.terminal-facts {
    position: absolute;
    right: var(--pad);
    bottom: 112px;
    left: var(--pad);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid rgba(255, 255, 255, .4);
}

.terminal-facts > div {
    min-height: 82px;
    border-left: 1px solid rgba(255, 255, 255, .2);
    padding: 10px 12px;
}

.terminal-facts > div:first-child { border-left: 0; }
.terminal-facts b,
.terminal-facts strong,
.terminal-facts small { display: block; font-family: var(--mono); }
.terminal-facts b { color: var(--acid); font-size: 8px; letter-spacing: .12em; }
.terminal-facts strong { margin-top: 12px; color: #ded9cf; font-size: 18px; line-height: 1; }
.terminal-facts small { margin-top: 7px; color: rgba(255, 255, 255, .38); font-size: 8px; letter-spacing: .03em; }

.account-hero::before {
    position: absolute;
    right: -7vw;
    bottom: -20vw;
    width: 46vw;
    height: 46vw;
    border: 1px solid rgba(213, 220, 140, .08);
    border-radius: 50%;
    content: "";
}

.account-label {
    position: absolute;
    top: 31%;
    left: var(--pad);
    z-index: 1;
    color: var(--acid);
    font: 9px/1 var(--mono);
    letter-spacing: .17em;
    animation: fade-up 700ms 80ms ease both;
}

.account-label p {
    margin: 9px 0 0;
    color: rgba(255, 255, 255, .44);
    font: 10px/1.4 var(--mono);
    letter-spacing: .05em;
}

.balance-wrap {
    position: absolute;
    top: 39%;
    right: var(--pad);
    left: var(--pad);
    z-index: 1;
    display: flex;
    align-items: baseline;
    max-width: 100%;
    white-space: nowrap;
    animation: balance-in 900ms 120ms cubic-bezier(.16, 1, .3, 1) both;
}

.balance-frame {
    --arm: 22px;
    position: absolute;
    top: -28px;
    right: -16px;
    bottom: -20px;
    left: -16px;
    z-index: 2;
    color: var(--red-soft);
    pointer-events: none;
    animation: balance-frame-in 800ms 620ms cubic-bezier(.16, 1, .3, 1) both;
}

.balance-frame i {
    position: absolute;
    width: var(--arm);
    height: var(--arm);
    border: 1.5px solid currentColor;
}

.balance-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.balance-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.balance-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.balance-frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }

@keyframes balance-frame-in {
    from { opacity: 0; transform: scale(1.035); }
}

@keyframes balance-in {
    from { opacity: 0; transform: translateY(45px); filter: blur(8px); }
}

.currency {
    margin-right: .12em;
    color: var(--amber, #e39045);
    font: 800 clamp(34px, 4vw, 68px)/1 var(--mono);
    font-weight: 800;
    line-height: 1;
}

.balance-wrap strong {
    display: flex;
    min-width: 0;
    color: #e49345;
    font: 800 clamp(100px, 17.5vw, 300px)/.86 var(--mono);
    letter-spacing: -.1em;
    font-variant-numeric: tabular-nums lining-nums;
}

.odometer {
    display: flex;
    height: .86em;
    overflow: hidden;
    transform: scaleX(.88);
    transform-origin: left center;
}

.odometer-digit {
    position: relative;
    display: inline-block;
    width: .61em;
    height: .86em;
    overflow: hidden;
}

.odometer-track {
    display: flex;
    flex-direction: column;
    transition: transform 1050ms cubic-bezier(.15, .78, .18, 1);
    will-change: transform;
}

.odometer-track i {
    display: block;
    flex: 0 0 .86em;
    height: .86em;
    font-style: normal;
    line-height: .86em;
}

.odometer-separator {
    align-self: flex-end;
    width: .31em;
    margin: 0 .01em .1em .03em;
    color: var(--acid);
    font-size: .42em;
    line-height: 1;
    letter-spacing: 0;
}

.balance-note {
    position: absolute;
    bottom: 24px;
    left: var(--pad);
    z-index: 1;
}

.balance-note p {
    margin: 0 0 6px;
    color: rgba(255, 255, 255, .55);
    font: 9px/1.65 var(--mono);
    letter-spacing: .03em;
}

.balance-note span {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.borrow-trigger {
    position: absolute;
    right: var(--pad);
    bottom: 24px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 28px;
    border: 1px solid var(--acid);
    padding: 14px 14px 14px 20px;
    background: var(--acid);
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .08em;
}

.borrow-trigger b {
    display: grid;
    width: 33px;
    height: 33px;
    place-items: center;
    background: transparent;
    color: var(--ink);
    font-size: 26px;
    font-weight: 300;
    line-height: 1;
    transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
}

.borrow-trigger:hover { background: transparent; color: var(--acid); }
.borrow-trigger:hover b { transform: rotate(90deg); }

.damage-panel,
.ledger-section { padding: clamp(86px, 10vw, 150px) var(--pad); }
.damage-panel { background: var(--ink); color: var(--white); }

.panel-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: clamp(54px, 8vw, 112px);
}

.panel-heading h2 {
    margin: 20px 0 0;
    font-size: clamp(43px, 6.2vw, 100px);
    line-height: 1.1;
    letter-spacing: .045em;
}

.panel-heading > p {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(18px, 2vw, 30px);
    line-height: 1.5;
    text-align: right;
}

.damage-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    border-top: 1px solid rgba(255, 255, 255, .45);
    border-bottom: 1px solid rgba(255, 255, 255, .45);
}

.damage-card {
    display: flex;
    min-height: 300px;
    flex-direction: column;
    justify-content: space-between;
    border-left: 1px solid rgba(255, 255, 255, .32);
    padding: 24px;
    transition: background 260ms ease, transform 260ms ease;
}

.damage-card:hover { transform: translateY(-8px); }

.damage-card:first-child { border-left: 0; }
.damage-card--red { background: var(--red-soft); color: var(--ink); }
.damage-card > span { font-size: 10px; font-weight: 700; letter-spacing: .15em; }

.damage-card strong {
    font-size: clamp(44px, 5vw, 82px);
    line-height: .95;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums lining-nums;
}

.damage-card p {
    max-width: 18em;
    margin: 0;
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.55;
}

.ledger-section { background: var(--paper); }
.panel-heading--ledger { align-items: end; }
.panel-heading--ledger h2 { font-size: clamp(60px, 10vw, 170px); line-height: .9; letter-spacing: -.045em; }
.ledger-heading-aside { display: flex; align-items: flex-end; flex-direction: column; }
.ledger-heading-aside p { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.5; text-align: right; }
.ledger-heading-aside button {
    display: flex;
    min-width: 210px;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    margin-top: 24px;
    border: 1px solid var(--ink);
    padding: 13px 15px;
    background: var(--ink);
    color: var(--white);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    transition: background 180ms ease, color 180ms ease;
}
.ledger-heading-aside button:hover { background: var(--red-soft); color: var(--ink); }
.ledger-heading-aside button b { font-size: 16px; }

.insights-dialog[open] { display: grid; place-items: center; padding: 22px; }

.insights-panel {
    position: relative;
    width: min(1120px, 100%);
    max-height: calc(100svh - 44px);
    overflow: auto;
    background: var(--paper);
    box-shadow: 0 26px 90px rgba(0, 0, 0, .28);
    animation: result-in 420ms cubic-bezier(.16, 1, .3, 1);
}

.insights-close {
    position: absolute;
    top: 17px;
    right: 19px;
    z-index: 2;
    border: 0;
    padding: 0;
    background: transparent;
    font-size: 40px;
    font-weight: 200;
    line-height: 1;
}

.ledger-insights {
    border: 1px solid var(--ink);
}

.ledger-insight-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
    padding: 28px 70px 28px 28px;
}

.ledger-insight-heading span,
.ledger-analysis-grid header span,
.ledger-stat-grid small {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .17em;
}

.ledger-insight-heading h3 { margin: 5px 0 0; font-size: clamp(28px, 3vw, 48px); line-height: 1; letter-spacing: .02em; }
.ledger-insight-heading p { max-width: 20em; margin: 0; font-family: var(--serif); font-size: 13px; text-align: right; }

.ledger-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
}

.ledger-stat-grid article {
    display: flex;
    min-width: 0;
    min-height: 150px;
    flex-direction: column;
    justify-content: space-between;
    border-left: 1px solid var(--line);
    padding: 18px;
}

.ledger-stat-grid article:first-child { border-left: 0; background: var(--ink); color: var(--white); }
.ledger-stat-grid article > span { font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.ledger-stat-grid strong { overflow: hidden; font-size: clamp(25px, 3vw, 44px); line-height: 1; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger-stat-grid small { opacity: .52; }

.ledger-analysis-grid { display: grid; grid-template-columns: 1fr 1.15fr; }
.ledger-analysis-grid > article { min-width: 0; padding: 24px; }
.ledger-analysis-grid > article + article { border-left: 1px solid var(--ink); }
.ledger-analysis-grid header { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.ledger-analysis-grid header strong { font-family: var(--serif); font-size: 16px; font-weight: 400; }

.category-row + .category-row { margin-top: 16px; }
.category-row > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 7px; }
.category-row strong { font-size: 13px; }
.category-row span { color: rgba(18, 16, 15, .55); font-family: var(--serif); font-size: 11px; }
.category-track { height: 8px; background: rgba(18, 16, 15, .09); }
.category-track i { display: block; height: 100%; background: var(--red-soft); transform-origin: left; animation: analysis-grow 720ms cubic-bezier(.16, 1, .3, 1); }
@keyframes analysis-grow { from { transform: scaleX(0); } }

.analysis-empty { margin: 75px 0; color: rgba(18, 16, 15, .45); font-family: var(--serif); text-align: center; }

.month-chart {
    display: grid;
    height: 220px;
    grid-template-columns: repeat(6, minmax(34px, 1fr));
    gap: clamp(7px, 1.2vw, 18px);
    align-items: end;
    border-bottom: 1px solid var(--ink);
}

.month-column { display: grid; height: 100%; grid-template-rows: 24px 1fr 25px; align-items: end; text-align: center; }
.month-column strong { overflow: hidden; font-family: var(--mono); font-size: 8px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.month-column i { display: block; min-height: 2px; background: var(--ink); transform-origin: bottom; animation: analysis-rise 720ms cubic-bezier(.16, 1, .3, 1); }
.month-column:last-child i { background: var(--red-soft); }
.month-column span { align-self: center; font-size: 8px; font-weight: 700; letter-spacing: .05em; }
@keyframes analysis-rise { from { transform: scaleY(0); } }

.ledger-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 13px;
}

.ledger-toolbar label > span { display: block; margin-bottom: 5px; font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.ledger-toolbar input,
.ledger-toolbar select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 9px 12px;
    background: transparent;
    color: var(--ink);
    font-size: 11px;
    outline: 0;
}
.ledger-toolbar input:focus,
.ledger-toolbar select:focus { box-shadow: inset 0 0 0 2px var(--red-soft); }
.ledger-search { min-width: 0; }

.ledger-result-meta {
    display: flex;
    min-height: 28px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: rgba(18, 16, 15, .5);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
}

.ledger-list { border-top: 1px solid var(--ink); }

.ledger-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) 150px 190px 82px;
    gap: 22px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 23px 0;
    transition: padding 220ms ease, background 220ms ease;
}

.ledger-row:hover { margin: 0 calc(var(--pad) * -.35); padding-right: calc(var(--pad) * .35); padding-left: calc(var(--pad) * .35); background: rgba(18, 16, 15, .045); }

.ledger-row time,
.ledger-row small,
.empty-ledger span { font-size: 10px; font-weight: 700; letter-spacing: .13em; }

.ledger-main { min-width: 0; }
.ledger-main strong { display: block; overflow: hidden; font-size: clamp(22px, 2.3vw, 34px); letter-spacing: .02em; text-overflow: ellipsis; white-space: nowrap; }
.ledger-main small { display: block; margin-top: 4px; color: rgba(10, 10, 10, .48); }
.ledger-work { font-family: var(--serif); font-size: 15px; }
.ledger-amount { font-size: clamp(24px, 2.5vw, 38px); font-weight: 800; letter-spacing: -.025em; text-align: right; font-variant-numeric: tabular-nums; }

.motion-ready .damage-card,
.motion-ready .ledger-row {
    opacity: 0;
    transform: translateY(28px);
}

.motion-ready .damage-card.is-inview,
.motion-ready .ledger-row.is-inview {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 620ms ease, transform 620ms cubic-bezier(.16, 1, .3, 1), background 260ms ease;
}

.motion-ready .damage-card:nth-child(2) { transition-delay: 90ms; }
.motion-ready .damage-card:nth-child(3) { transition-delay: 180ms; }

.ledger-actions { display: flex; justify-content: flex-end; gap: 4px; }

.edit-entry,
.delete-entry {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid transparent;
    background: transparent;
    font-size: 20px;
    opacity: .38;
}

.edit-entry { font-size: 10px; font-weight: 800; }
.edit-entry:hover,
.delete-entry:hover { border-color: var(--ink); opacity: 1; }

.empty-ledger {
    display: flex;
    min-height: 240px;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    border-bottom: 1px solid var(--ink);
}

.empty-ledger p {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(24px, 3.2vw, 48px);
}

.empty-ledger button {
    border: 0;
    border-bottom: 1px solid var(--ink);
    padding: 5px 0;
    background: transparent;
    font-weight: 700;
}

.empty-ledger--filtered { min-height: 180px; }

.ledger-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid var(--ink);
}

.ledger-pagination button {
    border: 0;
    padding: 17px 0;
    background: transparent;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
}
.ledger-pagination button:first-child { text-align: left; }
.ledger-pagination button:last-child { text-align: right; }
.ledger-pagination button:disabled { cursor: default; opacity: .25; }
.ledger-pagination span { font-family: var(--mono); font-size: 10px; }

.app-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    border-top: 1px solid rgba(255, 255, 255, .38);
    padding: 38px var(--pad);
    background: var(--ink);
    color: var(--white);
}

.app-footer p { max-width: 44em; margin: 0; color: rgba(255, 255, 255, .55); font-family: var(--serif); font-size: 12px; }
.app-footer a { font-size: 10px; font-weight: 700; letter-spacing: .16em; }

dialog {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink);
}

dialog::backdrop { background: rgba(10, 10, 10, .72); backdrop-filter: blur(8px); }

.borrow-dialog[open] { display: grid; place-items: end; }

.borrow-dialog form {
    width: min(760px, 100%);
    min-height: 100%;
    padding: clamp(28px, 4vw, 58px);
    background: var(--paper);
    animation: slide-in 420ms cubic-bezier(.22, .61, .36, 1);
}

@keyframes slide-in { from { transform: translateX(100%); } }

.borrow-dialog header,
.result-card > button:first-child {
    display: flex;
    align-items: start;
    justify-content: space-between;
}

.borrow-dialog header > div span { font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.borrow-dialog h2 { margin: 10px 0 0; font-size: clamp(38px, 5vw, 74px); line-height: 1; letter-spacing: .02em; }
.borrow-dialog header > button,
.result-card > button:first-child { border: 0; padding: 0; background: transparent; font-size: 44px; font-weight: 200; line-height: 1; }

.borrow-amount {
    display: flex;
    align-items: baseline;
    border-bottom: 2px solid var(--ink);
    margin: clamp(58px, 9vh, 110px) 0 34px;
}

.borrow-amount span { font-size: clamp(34px, 4vw, 60px); font-weight: 800; }
.borrow-amount input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 0; background: transparent; font-size: clamp(82px, 11vw, 160px); font-weight: 900; line-height: .9; letter-spacing: -.08em; }
.borrow-amount input::placeholder { color: rgba(10, 10, 10, .15); }

.borrow-fields {
    display: grid;
    grid-template-columns: 1.5fr .7fr;
    gap: 18px;
}

.borrow-date { grid-column: 1 / -1; }

.borrow-fields input,
.borrow-fields select { width: 100%; min-height: 52px; }

.borrow-preview {
    margin-top: 26px;
    border-left: 5px solid var(--red);
    padding: 14px 18px;
    background: rgba(184, 74, 56, .1);
    font-family: var(--serif);
    font-size: 16px;
}

.confirm-borrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 26px;
    border: 0;
    padding: 20px;
    background: var(--red);
    font-size: 19px;
    font-weight: 800;
}

.confirm-borrow b { font-size: 10px; letter-spacing: .12em; }
.confirm-borrow:hover { background: var(--ink); color: var(--white); }

.result-dialog[open] { display: grid; place-items: center; padding: 20px; }

.result-card {
    position: relative;
    width: min(620px, 100%);
    padding: clamp(28px, 5vw, 56px);
    background: var(--red-soft);
    text-align: center;
    animation: result-in 360ms cubic-bezier(.22, .61, .36, 1);
}

@keyframes result-in { from { opacity: 0; transform: scale(.86) rotate(-2deg); } }

.result-card > button:first-child { position: absolute; top: 20px; right: 20px; }
.result-card > p { margin: 58px 0 5px; font-family: var(--serif); font-size: 18px; }
.result-card > strong { display: block; font-size: clamp(72px, 11vw, 130px); line-height: .9; letter-spacing: -.08em; }
.result-verdict { min-height: 4.4em; margin: 40px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 20px 0; font-family: var(--serif); font-size: clamp(19px, 2.4vw, 28px); line-height: 1.55; }
.result-card > button:last-child { border: 1px solid var(--ink); padding: 14px 18px; background: var(--ink); color: var(--white); font-weight: 700; }

.agent-dialog[open] { display: grid; place-items: center; padding: 22px; }

.agent-panel {
    width: min(920px, 100%);
    max-height: calc(100svh - 44px);
    overflow: auto;
    padding: clamp(28px, 4vw, 56px);
    background: var(--paper);
    box-shadow: 0 26px 90px rgba(0, 0, 0, .28);
    animation: result-in 420ms cubic-bezier(.16, 1, .3, 1);
}

.agent-panel > header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 30px;
}

.agent-panel > header span {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .2em;
}

.agent-panel > header h2 {
    margin: 13px 0 0;
    font-size: clamp(44px, 6vw, 82px);
    line-height: 1.06;
    letter-spacing: .025em;
}

.agent-panel > header button {
    border: 0;
    padding: 0;
    background: transparent;
    font-size: 45px;
    font-weight: 200;
    line-height: 1;
}

.agent-intro {
    max-width: 32em;
    margin: 26px 0 38px;
    font-family: var(--serif);
    font-size: 18px;
    line-height: 1.72;
    letter-spacing: .035em;
}

.agent-connection-note {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: -22px 0 30px;
    color: rgba(18, 16, 15, .55);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
}
.agent-connection-note i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: rgba(18, 16, 15, .25); }
.agent-connection-note.is-connected { color: var(--ink); }
.agent-connection-note.is-connected i { background: var(--red-soft); }
.agent-connection-note.is-active i { background: #6d772d; box-shadow: 0 0 0 4px rgba(109, 119, 45, .12); }

.sync-key-card {
    margin: 0 0 30px;
    border: 1px solid var(--ink);
    background: rgba(255, 255, 255, .28);
}

.sync-key-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--ink);
    padding: 18px 20px;
}

.sync-key-heading span {
    display: block;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .19em;
}

.sync-key-heading h3 {
    margin: 4px 0 0;
    font-size: 21px;
    letter-spacing: .04em;
}

.sync-key-heading .sync-key-badge {
    border: 1px solid var(--ink);
    padding: 6px 8px;
    background: var(--ink);
    color: var(--white);
}

.sync-key-value {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: 18px 20px 10px;
}

.sync-key-value code {
    min-width: 0;
    overflow: hidden;
    font: 13px/1.5 Menlo, Monaco, Consolas, monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sync-key-value button,
.sync-key-connect button,
.sync-key-rotate button {
    border: 1px solid var(--ink);
    padding: 9px 12px;
    background: transparent;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
}

.sync-key-value button:hover,
.sync-key-connect button:hover,
.sync-key-rotate button:hover { background: var(--ink); color: var(--white); }

.sync-key-warning {
    margin: 0;
    padding: 3px 20px 19px;
    color: rgba(18, 16, 15, .63);
    font-family: var(--serif);
    font-size: 12px;
    line-height: 1.65;
    letter-spacing: .025em;
}

.sync-key-connect {
    border-top: 1px solid var(--line);
    padding: 18px 20px;
}

.sync-key-connect > label {
    display: block;
    margin-bottom: 10px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
}

.sync-key-connect > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.sync-key-connect input {
    min-width: 0;
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 11px 12px;
    background: rgba(255, 255, 255, .46);
    color: var(--ink);
    font: 12px Menlo, Monaco, Consolas, monospace;
    outline: 0;
}

.sync-key-connect input:focus { box-shadow: inset 0 0 0 2px var(--acid); }
.sync-key-connect button { background: var(--ink); color: var(--white); }
.sync-key-connect button:hover { background: var(--red); color: var(--ink); }
.sync-key-connect button:disabled,
.sync-key-rotate button:disabled { cursor: wait; opacity: .48; }

.sync-key-connect > p {
    margin: 9px 0 0;
    color: rgba(18, 16, 15, .58);
    font-family: var(--serif);
    font-size: 11px;
    line-height: 1.5;
}

.sync-key-connect > p.is-error { color: #9b231c; }

.sync-key-rotate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--line);
    padding: 16px 20px;
}

.sync-key-rotate strong,
.sync-key-rotate span { display: block; }
.sync-key-rotate strong { margin-bottom: 4px; font-size: 11px; }
.sync-key-rotate span { color: rgba(18, 16, 15, .58); font-family: var(--serif); font-size: 10px; line-height: 1.5; }
.sync-key-rotate button { flex: none; color: #9b231c; }

.agent-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--ink);
}

.agent-tabs button {
    border: 0;
    padding: 14px;
    background: transparent;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .17em;
}

.agent-tabs button + button { border-left: 1px solid var(--ink); }
.agent-tabs button.is-active { background: var(--ink); color: var(--white); }

.agent-tab-panel { padding-top: 24px; }

.agent-step {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 18px 0;
}

.agent-step > b { font-size: 11px; letter-spacing: .12em; }
.agent-step > div { min-width: 0; }
.agent-step span { display: block; margin-bottom: 6px; font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.agent-step code { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.agent-step button,
.config-block button {
    border: 1px solid var(--ink);
    padding: 8px 11px;
    background: transparent;
    font-size: 10px;
    font-weight: 700;
}

.agent-step button:hover,
.config-block button:hover { background: var(--ink); color: var(--white); }

.config-block {
    margin-top: 8px;
    background: var(--ink);
    color: var(--white);
}

.config-block > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    padding: 11px 14px;
}

.config-block > div span { font-size: 9px; font-weight: 700; letter-spacing: .15em; }
.config-block button { border-color: rgba(255, 255, 255, .5); color: var(--white); }
.config-block button:hover { background: var(--white); color: var(--ink); }
.config-block pre { margin: 0; overflow: auto; padding: 18px; font: 12px/1.7 Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

.agent-hint {
    margin: 12px 0 0;
    color: rgba(18, 16, 15, .58);
    font-family: var(--serif);
    font-size: 12px;
}

.doubao-steps { border-top: 1px solid var(--line); }
.doubao-steps p { display: grid; grid-template-columns: 52px 1fr; margin: 0; border-bottom: 1px solid var(--line); padding: 17px 0; }
.doubao-steps b { font-size: 11px; letter-spacing: .12em; }
.doubao-steps span { font-family: var(--serif); font-size: 15px; }

.agent-panel > footer {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 30px;
    margin-top: 30px;
    border-top: 1px solid var(--ink);
    padding-top: 16px;
}

.agent-panel > footer p { max-width: 46em; margin: 0; color: rgba(18, 16, 15, .6); font-family: var(--serif); font-size: 11px; line-height: 1.6; }
.agent-panel > footer span { flex: none; font-size: 8px; font-weight: 700; letter-spacing: .13em; }

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 100;
    max-width: min(390px, calc(100vw - 44px));
    padding: 13px 17px;
    background: var(--acid);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

.mobile-tabbar { display: none; }

@media (max-width: 980px) {
    .setup-screen { grid-template-columns: 1fr; }
    .setup-intro { min-height: 76svh; border-right: 0; border-bottom: 1px solid var(--ink); }
    .setup-intro h1 { font-size: clamp(100px, 25vw, 190px); }
    .setup-intro::after { width: 60vw; height: 60vw; }
    .future-form { min-height: 100svh; }
    .damage-grid { grid-template-columns: 1fr 1fr; }
    .damage-card:first-child { grid-column: span 2; border-bottom: 1px solid rgba(255, 255, 255, .32); }
    .damage-card:nth-child(2) { border-left: 0; }
    .ledger-stat-grid { grid-template-columns: 1fr 1fr; }
    .ledger-stat-grid article:nth-child(3) { border-top: 1px solid var(--line); border-left: 0; }
    .ledger-stat-grid article:nth-child(4) { border-top: 1px solid var(--line); }
    .ledger-analysis-grid { grid-template-columns: 1fr; }
    .ledger-analysis-grid > article + article { border-top: 1px solid var(--ink); border-left: 0; }
    .ledger-toolbar { grid-template-columns: 1fr 1fr 1fr; }
    .ledger-search { grid-column: 1 / -1; }
    .ledger-row { grid-template-columns: 78px minmax(0, 1fr) 150px 82px; }
    .ledger-work { display: none; }
}

@media (max-width: 640px) {
    html { scroll-padding-top: calc(64px + env(safe-area-inset-top)); }
    body { overflow-x: hidden; overscroll-behavior-y: none; }

    .site-header {
        grid-template-columns: 1fr auto;
        align-items: center;
        min-height: calc(60px + env(safe-area-inset-top));
        padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
        background: rgba(12, 13, 11, .94);
        color: var(--white);
        mix-blend-mode: normal;
        box-shadow: 0 1px 0 rgba(255, 255, 255, .12);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    .header-line { display: none; }
    .brand { min-height: 44px; align-items: center; gap: 9px; }
    .brand strong { font-size: 15px; }
    .header-actions { gap: 7px; }
    .sync-state { display: none; }
    .agent-button { min-height: 44px; padding: 9px 10px; font-size: 8px; }
    .profile-button { min-width: 44px; min-height: 44px; border: 1px solid currentColor; padding: 0 8px; font-size: 8px; }
    .profile-long { display: none; }
    .profile-short { display: inline; }

    .setup-intro { min-height: 67svh; padding-top: calc(92px + env(safe-area-inset-top)); padding-bottom: 28px; }
    .setup-intro h1 { margin: auto 0; font-size: 27vw; line-height: .76; }
    .setup-intro h1 em { align-self: flex-start; margin-left: 17vw; }
    .setup-lead { font-size: 19px; }

    .future-form { min-height: auto; padding-top: 64px; padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
    .form-heading { display: block; }
    .form-heading p { margin-top: 9px; text-align: left; }
    .field-row { grid-template-columns: 1fr; }
    .field-row > label + label { border-top: 1px solid rgba(255, 255, 255, .2); border-left: 0; padding-left: 0; }
    .input-unit input { font-size: 48px; }
    .growth-options label span { min-height: 70px; padding: 9px; }
    .growth-options b { font-size: 12px; }
    .optional-field { align-items: flex-start; }
    .future-form input,
    .future-form select,
    .borrow-fields input,
    .borrow-fields select,
    .sync-key-connect input,
    .ledger-toolbar input,
    .ledger-toolbar select { font-size: 16px; }
    .growth-options label span,
    .optional-field select,
    .calculate-button { min-height: 48px; }

    .account-screen { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
    .account-hero,
    .damage-panel,
    .ledger-section { scroll-margin-top: calc(60px + env(safe-area-inset-top)); }
    .account-hero { min-height: 100svh; padding: calc(78px + env(safe-area-inset-top)) 20px calc(104px + env(safe-area-inset-bottom)); }
    .terminal-meta { top: calc(76px + env(safe-area-inset-top)); right: 20px; left: 20px; font-size: 7px; }
    .account-label { top: 24%; left: 20px; }
    .balance-wrap { top: 34%; right: 20px; left: 20px; display: block; overflow: visible; }
    .balance-frame { --arm: 15px; top: -43px; right: -8px; bottom: -15px; left: -8px; }
    .currency { position: absolute; top: -28px; left: 2px; margin: 0; font-size: 20px; }
    .balance-wrap strong { width: max-content; font-size: clamp(96px, 27vw, 116px); line-height: .82; letter-spacing: -.115em; }
    .odometer { transform: scaleX(.64); transform-origin: left center; }
    .terminal-facts { right: 20px; bottom: calc(94px + env(safe-area-inset-bottom)); left: 20px; grid-template-columns: repeat(2, 1fr); }
    .terminal-facts > div { min-height: 65px; padding: 8px; }
    .terminal-facts > div:nth-child(3) { border-left: 0; }
    .terminal-facts strong { margin-top: 8px; font-size: 15px; }
    .terminal-facts small { margin-top: 4px; font-size: 7px; }
    .balance-note { top: 49%; right: 20px; bottom: auto; left: 20px; }
    .balance-note p { max-width: 34em; margin-bottom: 5px; font-size: 9px; }
    .balance-note span { display: block; color: rgba(255, 255, 255, .38); font-size: 7px; }
    .borrow-trigger { display: none; }

    .damage-panel,
    .ledger-section { padding-top: 76px; padding-bottom: 76px; }
    .panel-heading { display: block; margin-bottom: 46px; }
    .panel-heading h2 { margin-top: 14px; font-size: 43px; }
    .panel-heading > p { margin-top: 24px; font-size: 17px; text-align: left; }
    .damage-grid {
        display: flex;
        gap: 12px;
        margin-right: calc(var(--pad) * -1);
        overflow-x: auto;
        border-bottom: 0;
        padding: 0 var(--pad) 12px 0;
        scroll-padding-right: var(--pad);
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }
    .damage-grid::-webkit-scrollbar { display: none; }
    .damage-card,
    .damage-card:first-child {
        min-height: 258px;
        flex: 0 0 min(82vw, 360px);
        border: 1px solid rgba(255, 255, 255, .24);
        padding: 22px;
        background: rgba(255, 255, 255, .035);
        scroll-snap-align: start;
    }
    .damage-card.damage-card--red { margin: 0; background: var(--red-soft); }
    .damage-card:hover { transform: none; }

    .panel-heading--ledger h2 { font-size: 74px; }
    .ledger-heading-aside { align-items: flex-start; margin-top: 26px; }
    .ledger-heading-aside p { font-size: 17px; text-align: left; }
    .ledger-heading-aside button { min-width: min(270px, 100%); }
    .insights-dialog[open] { place-items: end stretch; padding: 0; }
    .insights-panel { width: 100%; max-height: calc(92dvh - env(safe-area-inset-top)); border: 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); overscroll-behavior: contain; animation-name: mobile-sheet-in; }
    .ledger-insights { border: 0; }
    .ledger-insight-heading { align-items: flex-start; flex-direction: column; padding: 20px 52px 20px 16px; }
    .ledger-insight-heading p { text-align: left; }
    .ledger-stat-grid article { min-height: 126px; padding: 14px; }
    .ledger-stat-grid strong { font-size: 26px; }
    .ledger-analysis-grid > article { padding: 20px 16px; }
    .ledger-analysis-grid header { align-items: flex-start; flex-direction: column; gap: 4px; }
    .month-chart { height: 190px; gap: 6px; }
    .month-column strong { font-size: 7px; }
    .ledger-toolbar { grid-template-columns: 1fr 1fr; }
    .ledger-search { grid-column: 1 / -1; }
    .ledger-toolbar label:nth-child(4) { grid-column: 1 / -1; }
    .ledger-toolbar input,
    .ledger-toolbar select { min-height: 48px; }
    .ledger-result-meta { align-items: flex-start; flex-direction: column; gap: 4px; margin-bottom: 7px; }
    .ledger-row { grid-template-columns: minmax(0, 1fr) auto 92px; gap: 8px; padding: 18px 0; }
    .ledger-row time { grid-column: 1 / -1; }
    .ledger-main strong { font-size: 21px; }
    .ledger-amount { font-size: 23px; }
    .edit-entry,
    .delete-entry { width: 44px; height: 44px; }
    .empty-ledger { min-height: 190px; flex-direction: column; align-items: flex-start; justify-content: center; }
    .empty-ledger p { font-size: 25px; }

    .app-footer { align-items: flex-start; flex-direction: column; padding-bottom: calc(38px + env(safe-area-inset-bottom)); }
    .app-footer a { display: flex; min-height: 44px; align-items: center; }

    .borrow-dialog[open] { place-items: end stretch; }
    .borrow-dialog form {
        width: 100%;
        min-height: 0;
        max-height: calc(92dvh - env(safe-area-inset-top));
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        padding: 25px 20px calc(25px + env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        animation-name: mobile-sheet-in;
    }
    @keyframes mobile-sheet-in { from { transform: translateY(100%); } }
    .borrow-dialog h2 { font-size: 40px; }
    .borrow-dialog header > button,
    .result-card > button:first-child,
    .insights-close,
    .agent-panel > header button { min-width: 44px; min-height: 44px; }
    .borrow-amount { margin-top: 38px; }
    .borrow-amount input { font-size: clamp(62px, 21vw, 84px); }
    .borrow-fields { grid-template-columns: 1fr; }
    .confirm-borrow { min-height: 60px; align-items: flex-start; flex-direction: column; gap: 7px; }

    .result-dialog[open] { place-items: end stretch; padding: 0; }
    .result-card { width: 100%; border-radius: 20px 20px 0 0; padding-bottom: calc(32px + env(safe-area-inset-bottom)); animation-name: mobile-sheet-in; }
    .result-card > p { margin-top: 45px; }
    .result-card > strong { font-size: 21vw; }
    .result-card > button:last-child { min-height: 48px; }

    .agent-dialog[open] { place-items: end stretch; padding: 0; }
    .agent-panel { width: 100%; max-height: calc(92dvh - env(safe-area-inset-top)); border-radius: 20px 20px 0 0; padding: 25px 20px calc(25px + env(safe-area-inset-bottom)); overscroll-behavior: contain; animation-name: mobile-sheet-in; }
    .agent-panel > header h2 { font-size: 42px; }
    .agent-intro { margin: 18px 0 26px; font-size: 15px; }
    .sync-key-heading,
    .sync-key-value,
    .sync-key-connect,
    .sync-key-rotate { padding-right: 14px; padding-left: 14px; }
    .sync-key-value { grid-template-columns: minmax(0, 1fr) auto auto; }
    .sync-key-value code { font-size: 10px; }
    .sync-key-value button { padding: 8px; }
    .sync-key-connect > div { grid-template-columns: 1fr; }
    .sync-key-connect button { min-height: 42px; }
    .sync-key-rotate { align-items: flex-start; flex-direction: column; }
    .agent-step { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; }
    .agent-step code { font-size: 11px; }
    .agent-panel > footer { align-items: flex-start; flex-direction: column; }

    .mobile-tabbar {
        position: fixed;
        right: 10px;
        bottom: calc(8px + env(safe-area-inset-bottom));
        left: 10px;
        z-index: 35;
        display: grid;
        grid-template-columns: 1fr 1fr 1.18fr 1fr 1fr;
        min-height: 68px;
        overflow: visible;
        border: 1px solid rgba(255, 255, 255, .16);
        border-radius: 18px;
        background: rgba(12, 13, 11, .94);
        color: rgba(246, 241, 232, .58);
        box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }
    .mobile-tabbar button {
        position: relative;
        display: flex;
        min-width: 0;
        min-height: 66px;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 4px;
        border: 0;
        background: transparent;
        color: inherit;
    }
    .mobile-tabbar button i { font-family: var(--mono); font-size: 8px; font-style: normal; letter-spacing: .08em; }
    .mobile-tabbar button span { max-width: 100%; overflow: hidden; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-overflow: clip; white-space: nowrap; }
    .mobile-tabbar button.is-active { color: var(--white); }
    .mobile-tabbar button.is-active::after { position: absolute; bottom: 6px; width: 18px; height: 2px; background: var(--red-soft); content: ""; }
    .mobile-tabbar__borrow {
        min-height: 74px !important;
        margin: -7px 2px 2px;
        border: 1px solid rgba(255, 255, 255, .22) !important;
        border-radius: 14px;
        background: var(--red-soft) !important;
        color: var(--ink) !important;
        box-shadow: 0 9px 24px rgba(0, 0, 0, .3);
    }
    .mobile-tabbar__borrow i { font-size: 23px !important; line-height: .7; }

    .toast { right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}

@media (display-mode: standalone) and (max-width: 640px) {
    .site-header { padding-top: calc(8px + env(safe-area-inset-top)); }
    .brand span { display: none; }
}

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