* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Arial, "Microsoft YaHei", sans-serif; color: var(--color-ink); background: #eef1f4; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.stage { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.phone { position: relative; width: 390px; height: min(844px, calc(100vh - 48px)); min-height: 660px; overflow: hidden; background: var(--color-page); box-shadow: 0 24px 70px #34485c2c; }
.app { height: 100%; overflow-y: auto; scrollbar-width: none; }
.app::-webkit-scrollbar { display: none; }
.screen { min-height: 100%; background: var(--color-page); }

.splash-screen { position: relative; min-height: 100%; display: grid; place-items: center; overflow: hidden; background: linear-gradient(#ffffff58, #ffffff58), url("assets/header-texture.png") center/cover; }
.splash-brand { margin-top: -46px; text-align: center; }
.splash-brand img { width: 138px; height: 138px; border-radius: 34px; object-fit: contain; filter: drop-shadow(0 14px 28px #ef4f5220); }
.splash-brand h1 { margin: 18px 0 0; font-size: 29px; }
.splash-loading { position: absolute; left: 20px; right: 20px; bottom: 42px; text-align: center; }
.splash-loading strong { display: block; margin-bottom: 13px; color: var(--color-primary); font-size: 17px; }
.loading-track { height: 10px; overflow: hidden; border-radius: 8px; background: #dfe3e2; }
.loading-track span { display: block; width: 52%; height: 100%; border-radius: inherit; background: var(--color-primary); animation: load-progress 1.3s ease-out forwards; }
@keyframes load-progress { from { width: 10%; } to { width: 100%; } }

.home-screen { padding-bottom: 78px; }
.home-hero { position: relative; height: 120px; display: flex; justify-content: center; padding: 39px 20px 0; color: #fff; background: linear-gradient(#f4505338, #f4505338), url("assets/header-texture.png") center/cover; }
.home-hero h1 { margin: 0; font-size: 28px; text-shadow: 0 1px 4px #9d2f3333; }
.home-content { position: relative; margin-top: -28px; padding: 0 11px 30px; border-radius: var(--radius-page) var(--radius-page) 0 0; background: var(--color-page); }
.loan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.loan-card { position: relative; min-height: 184px; padding: 14px; border: 0; border-radius: 26px; background: var(--color-surface); text-align: left; box-shadow: var(--shadow-soft); }
.loan-card img { display: block; width: 72px; height: 72px; object-fit: contain; }
.loan-card strong, .loan-card small { display: block; }
.loan-card strong { margin-top: 7px; font-size: 17px; }
.loan-card small { margin-top: 5px; padding-right: 4px; color: var(--color-muted); font-size: 11px; line-height: 1.25; }
.loan-card .circle-arrow { top: 14px; }
.loan-card:disabled, .nav-btn:disabled { cursor: default; }
.home-content .recent-section { padding: 0 10px; }
.bottom-nav { position: absolute; z-index: 30; left: 0; right: 0; bottom: 0; height: 68px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 5px 5px max(5px, env(safe-area-inset-bottom)); border-top: 1px solid #ececec; background: #fff; }
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: #666; font-size: 13px; }
.nav-btn img { width: 30px; height: 30px; object-fit: contain; }
.nav-btn.active { color: var(--color-primary); font-weight: 700; }

.page-hero {
  position: relative;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10px;
  color: #fff;
  background: linear-gradient(#f4505352, #f4505352), url("assets/header-texture.png") center/cover;
}
.page-hero h1 { margin: 0; max-width: 245px; font-size: 26px; color: #fff; text-align: center; text-shadow: 0 1px 4px #9d2f3333; }
.header-mark { position: absolute; right: 18px; top: 48px; width: 38px; height: 38px; border-radius: 50%; background: #fff; padding: 3px; object-fit: contain; }
.back { position: absolute; left: 18px; top: 48px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #fff; color: var(--color-primary); font-size: 26px; line-height: 1; }

.page-body { position: relative; margin-top: -2px; padding: 20px var(--page-gutter) 28px; border-radius: var(--radius-page) var(--radius-page) 0 0; background: var(--color-page); }
.calculator-intro { margin: 0 1px 16px; color: var(--color-muted); font-size: 14px; line-height: 1.45; }
.loan-form { padding-bottom: 12px; }
.field-title { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin: 7px 1px 8px; font-size: 18px; font-weight: 700; }
.currency-pill { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 11px; border-radius: 22px; background: var(--color-surface); color: var(--color-ink); font-size: 16px; font-weight: 400; }
.currency-pill::after { content: "\2304"; color: #aaa; font-size: 18px; line-height: 1; }
.flag-gbp {
  display: inline-block;
  width: 26px;
  height: 18px;
  overflow: hidden;
  border: 1px solid #0002;
  border-radius: 3px;
  background: linear-gradient(33deg, transparent 43%, #fff 43% 48%, #cf2436 48% 52%, #fff 52% 57%, transparent 57%), linear-gradient(-33deg, transparent 43%, #fff 43% 48%, #cf2436 48% 52%, #fff 52% 57%, transparent 57%), linear-gradient(90deg, transparent 38%, #fff 38% 45%, #cf2436 45% 55%, #fff 55% 62%, transparent 62%), linear-gradient(transparent 34%, #fff 34% 42%, #cf2436 42% 58%, #fff 58% 66%, transparent 66%), #21468b;
}
.native-input { position: relative; height: var(--control-height); display: flex; align-items: center; margin-bottom: 17px; overflow: hidden; border: 0; border-radius: var(--radius-control); background: var(--color-surface); }
.native-input:focus-within { box-shadow: 0 0 0 2px #f4505322; }
.native-input input { width: 100%; height: 100%; padding: 0 50px 0 18px; border: 0; outline: 0; background: transparent; color: var(--color-ink); font-size: 17px; }
.native-input input::placeholder { color: var(--color-muted); }
.native-input > span { position: absolute; right: 22px; color: var(--color-muted); font-size: 18px; }
.select-input select { width: 100%; height: 100%; padding: 0 18px; border: 0; outline: 0; background: transparent; color: var(--color-ink); font-size: 17px; }
.date-input input { padding-right: 18px; }
.term-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.down-payment-row { display: grid; grid-template-columns: 1.45fr 1fr; gap: 14px; }
.mortgage-costs-title { margin: 26px 1px 9px; }
.mortgage-costs-title h2 { margin: 0; font-size: 18px; }
.mortgage-costs-title small { display: block; margin-top: 4px; color: var(--color-muted); font-size: 12px; }
.term-unit { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px; }
.term-unit label { position: relative; display: grid; place-items: center; border-radius: 18px; color: var(--color-muted); font-size: 14px; font-weight: 700; cursor: pointer; }
.term-unit input { position: absolute; opacity: 0; pointer-events: none; }
.term-unit label:has(input:checked) { background: #f8e5e5; color: var(--color-primary); }
.error { min-height: 24px; padding: 2px 5px; color: var(--color-error); font-size: 13px; }

.form-actions { position: sticky; z-index: 10; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 6px -1px 0; padding: 16px 0 max(10px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--color-page) 18%); }
.primary, .secondary { min-width: 0; height: var(--button-height); border: 0; border-radius: var(--radius-button); color: #fff; font-size: 17px; font-weight: 700; box-shadow: var(--shadow-action); }
.primary { background: var(--color-primary); }
.primary:active { background: var(--color-primary-pressed); }
.secondary { background: var(--color-secondary); }

.recent-section { margin-top: var(--section-gap); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 11px 12px; }
.section-title h2 { margin: 0; color: var(--color-muted); font-size: 18px; font-weight: 500; }
.section-title span { color: var(--color-muted); font-size: 12px; }
.history-list { display: grid; gap: 12px; }
.history-card { position: relative; width: 100%; padding: 12px; border: 0; border-radius: var(--radius-card); background: var(--color-surface); text-align: left; box-shadow: var(--shadow-soft); }
.history-title { display: flex; align-items: center; gap: 10px; }
.history-title img { width: 42px; height: 42px; object-fit: contain; }
.history-title strong, .history-title small { display: block; }
.history-title strong { font-size: 17px; }
.history-title small { margin-top: 3px; color: var(--color-muted); font-size: 13px; }
.circle-arrow { position: absolute; right: 13px; top: 14px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #f5f6f7; color: #aaa; font-size: 21px; }
.history-stats { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 8px; margin-top: 14px; }
.history-stats small, .history-stats b { display: block; }
.history-stats small { color: var(--color-muted); font-size: 12px; }
.history-stats b { margin-top: 4px; font-size: 14px; white-space: nowrap; }
.empty-history { display: flex; align-items: center; gap: 10px; min-height: 74px; padding: 12px 14px; border-radius: var(--radius-card); background: var(--color-surface); }
.empty-history img { width: 42px; height: 42px; object-fit: contain; opacity: .65; }
.empty-history strong, .empty-history small { display: block; }
.empty-history small { margin-top: 3px; color: var(--color-muted); font-size: 12px; }

.result-content { padding-top: 18px; }
.result-content h2 { margin: 16px 0 12px; font-size: 18px; }
.result-card { padding: 14px 22px; border-radius: var(--radius-control); background: var(--color-surface); }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; font-size: 16px; }
.result-row span { color: var(--color-primary); }
.result-row b { white-space: nowrap; }
.result-row.total { margin: -2px 0 4px; border-bottom: 1px solid #eceff1; font-size: 18px; }
.result-row.total b { color: var(--color-primary); font-size: 20px; }
.disclaimer { margin: 18px 4px 0; color: var(--color-muted); font-size: 11px; line-height: 1.5; text-align: center; }
.result-actions { display: grid; gap: 14px; margin-top: 24px; }
.result-actions .primary, .result-actions .secondary { width: 100%; }
.tools-body { padding: 20px var(--page-gutter) 92px; background: var(--color-page); }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tool-card { position: relative; min-height: 178px; padding: 14px; border: 0; border-radius: var(--radius-card); background: var(--color-surface); text-align: left; box-shadow: var(--shadow-soft); }
.tool-card img { width: 64px; height: 64px; object-fit: contain; }
.tool-card strong, .tool-card small { display: block; }
.tool-card strong { margin-top: 10px; font-size: 16px; }
.tool-card small { min-height: 34px; margin-top: 5px; color: var(--color-muted); font-size: 12px; line-height: 1.35; }
.tool-detail { min-height: calc(100% - 128px); padding: 28px var(--page-gutter); background: var(--color-page); }
.convert-button { width: 100%; height: 48px; margin: 0 0 22px; border: 0; border-radius: var(--radius-control); background: var(--color-primary); color: #fff; font-size: 16px; font-weight: 700; }
.clock-list { display: grid; gap: 12px; }
.clock-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 20px; border-radius: var(--radius-control); background: var(--color-surface); }
.clock-row span { color: var(--color-muted); }
.clock-row b { font-size: 22px; }

.native-ad { position: relative; min-height: 154px; display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: 1fr 38px; gap: 8px 12px; margin: 18px 0 10px; padding: 12px; overflow: hidden; border: 1px solid #e5e7e9; border-radius: 8px; background: #fff; box-shadow: 0 5px 18px #29384612; }
.native-ad-media { grid-row: 1 / 3; position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 6px; background: #e9f2ee; color: #28705b; }
.native-ad-media span { position: relative; z-index: 2; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: #fff; font-size: 25px; font-weight: 700; box-shadow: 0 6px 14px #1d58472b; }
.native-ad-media i, .native-ad-media b, .interstitial-media i, .interstitial-media b { position: absolute; display: block; border-radius: 50%; background: #8fc8b6; }
.native-ad-media i { width: 76px; height: 76px; right: -22px; bottom: -20px; }
.native-ad-media b { width: 42px; height: 42px; left: -12px; top: -10px; background: #f2c76f; }
.native-ad-copy { min-width: 0; align-self: center; padding-right: 18px; }
.native-ad-copy strong, .native-ad-copy small { display: block; }
.native-ad-copy strong { margin-top: 6px; overflow-wrap: anywhere; font-size: 15px; line-height: 1.2; }
.native-ad-copy small { margin-top: 5px; color: #687177; font-size: 11px; line-height: 1.3; }
.ad-label { display: inline-grid; place-items: center; min-width: 22px; height: 16px; padding: 0 4px; border: 1px solid #9aa1a5; border-radius: 3px; color: #6c7478; font-size: 9px; font-weight: 700; line-height: 1; }
.ad-dismiss { position: absolute; z-index: 2; top: 5px; right: 6px; width: 25px; height: 25px; padding: 0; border: 0; background: transparent; color: #72797d; font-size: 22px; line-height: 1; }
.ad-cta { align-self: end; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 5px; background: #28705b; color: #fff; font-size: 12px; font-weight: 700; }

.ad-overlay { position: absolute; z-index: 100; inset: 0; }
.ad-loading-overlay { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 62px; background: #fff; color: #41474b; }
.ad-loading-overlay > strong { font-size: 18px; font-weight: 500; }
.ad-loading-visual { position: relative; width: 148px; height: 148px; display: grid; place-items: center; overflow: hidden; border-radius: 18px; background: #e9f2ee; }
.ad-loading-visual span { position: relative; z-index: 2; display: grid; place-items: center; width: 70px; height: 70px; border: 2px solid #fff; border-radius: 50%; background: #28705b; color: #fff; font-size: 20px; font-weight: 700; }
.ad-loading-visual i, .ad-loading-visual b { position: absolute; border-radius: 50%; }
.ad-loading-visual i { width: 96px; height: 96px; right: -24px; bottom: -24px; background: #8fc8b6; }
.ad-loading-visual b { width: 58px; height: 58px; left: -14px; top: -12px; background: #f2c76f; }
.interstitial-overlay { display: grid; place-items: center; padding: 18px; background: #0009; }
.interstitial-ad { width: 100%; max-width: 340px; overflow: hidden; border-radius: 8px; background: #fff; box-shadow: 0 20px 60px #0005; }
.interstitial-top { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 7px 8px 7px 12px; }
.interstitial-top button { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: #596166; font-size: 27px; line-height: 1; }
.interstitial-media { position: relative; height: 248px; display: grid; place-items: center; overflow: hidden; background: #e9f2ee; }
.interstitial-media span { position: relative; z-index: 2; width: 104px; height: 104px; display: grid; place-items: center; border-radius: 50%; background: #28705b; color: #fff; font-size: 52px; font-weight: 700; box-shadow: 0 14px 30px #1d584735; }
.interstitial-media i { width: 188px; height: 188px; right: -40px; bottom: -62px; }
.interstitial-media b { width: 120px; height: 120px; left: -24px; top: -30px; background: #f2c76f; }
.interstitial-copy { padding: 20px; text-align: center; }
.interstitial-copy h2 { margin: 0; font-size: 21px; }
.interstitial-copy p { margin: 9px 0 18px; color: #687177; font-size: 13px; line-height: 1.45; }
.interstitial-copy .ad-cta { width: 100%; height: 44px; font-size: 14px; }
.settings-screen { padding-bottom: 78px; }
.settings-list { display: grid; gap: 25px; padding: 59px 17px; }
.setting { position: relative; min-height: 74px; display: flex; align-items: center; gap: 18px; padding: 7px 56px 7px 20px; border: 0; border-radius: 23px; background: var(--color-surface); text-align: left; }
.setting-icon { width: 46px; height: 46px; object-fit: contain; }
.setting strong { font-size: 18px; }
.setting .circle-arrow { top: 22px; }
.settings-notice { position: absolute; z-index: 30; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 40px); transform: translateX(-50%); padding: 11px 16px; border-radius: 8px; background: #303030; color: #fff; font-size: 13px; line-height: 1.35; text-align: center; box-shadow: 0 6px 18px #0003; }

@media (max-width: 500px) {
  body { background: var(--color-page); }
  .stage { display: block; padding: 0; }
  .phone { width: 100%; height: 100dvh; min-height: 620px; box-shadow: none; }
}

@media (max-width: 360px) {
  .page-body { padding-left: 15px; padding-right: 15px; }
  .term-row { gap: 10px; }
  .history-stats b, .result-row { font-size: 14px; }
  .native-ad { grid-template-columns: 92px minmax(0, 1fr); gap: 8px 10px; padding: 10px; }
}
