:root {
  --bg: #f4efe8;
  --card: #ffffff;
  --navy: #1b2a3a;
  --ink: #22303d;
  --muted: #5f6b76;
  --line: #e3ddd4;
  --green: #2f7d5b;
  --green-soft: #e7f0eb;
  --sand: #efe8dd;
  --danger: #b4403a;
  --radius: 20px;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }

.app { max-width: 430px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

/* On a laptop the app sits as a phone-sized card on a calm backdrop. */
@media (min-width: 600px) {
  body { background: #e6e0d6; padding: 32px 0; }
  .app { min-height: calc(100dvh - 64px); border-radius: 36px; box-shadow: 0 24px 60px rgba(27, 42, 58, 0.18); overflow: hidden; }
}

.screen { padding: 16px 20px 32px; display: flex; flex-direction: column; flex: 1; }
.screen[hidden] { display: none; }

h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 8px 0 10px; color: var(--navy); letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 700; margin: 18px 0 4px; color: var(--navy); }
p { margin: 0 0 12px; line-height: 1.5; }
.lead { color: var(--muted); font-size: 16px; margin-bottom: 20px; }
.muted { color: var(--muted); font-size: 15px; }
.error { color: var(--danger); font-size: 14px; }

/* Top bars */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 14px; }
.logo { font-family: var(--serif); font-size: 34px; font-weight: 500; color: var(--navy); letter-spacing: -0.02em; }
.topbar__right { display: flex; align-items: center; gap: 14px; font-size: 16px; color: var(--navy); }
.bell { width: 16px; height: 16px; border: 2px solid var(--navy); border-radius: 8px 8px 3px 3px; border-bottom-width: 3px; display: inline-block; }

.pagebar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin-bottom: 10px; }
.pagebar span { grid-column: 2; text-align: center; font-weight: 600; font-size: 15px; color: var(--navy); }
.back { grid-column: 1; width: 36px; height: 36px; border: 0; background: transparent; position: relative; cursor: pointer; }
.back::before { content: ""; position: absolute; left: 12px; top: 11px; width: 10px; height: 10px; border-left: 2px solid var(--navy); border-bottom: 2px solid var(--navy); transform: rotate(45deg); }

/* Home */
.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px; margin-bottom: 16px; }
.tabs__item { flex: 1; text-align: center; padding: 10px 0 8px; font-size: 15px; color: var(--muted); position: relative; }
.tabs__item--active { color: var(--navy); font-weight: 700; }
.tabs__item--active::after { content: ""; position: absolute; left: 35%; right: 35%; bottom: 0; height: 3px; background: var(--green); border-radius: 3px; }

.hero { background: var(--sand); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.hero__image { height: 210px; position: relative; background: #d9c9b2 url("/img/home.jpg") center / cover no-repeat; }
.hero__badge { position: absolute; right: 14px; top: 14px; width: 54px; height: 54px; background: #fff; border-radius: 14px; }
.hero__badge::before, .hero__badge::after { content: ""; position: absolute; left: 20px; width: 14px; height: 14px; background: var(--navy); }
.hero__badge::before { top: 9px; border-radius: 4px; }
.hero__badge::after { top: 29px; background: var(--green); transform: rotate(45deg); border-radius: 3px; }
.hero__body { padding: 22px 22px 24px; }
.hero__body p { color: var(--muted); font-size: 17px; }

.learn { display: flex; align-items: center; gap: 16px; padding: 12px 4px 20px; border-bottom: 1px solid var(--line); }
.learn__icon { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.learn__icon span { width: 44px; height: 38px; background: linear-gradient(180deg, var(--navy) 48%, transparent 48%, transparent 52%, var(--navy) 52%); border-radius: 8px; }
.learn__text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.learn__text b { font-size: 17px; color: var(--navy); }
.learn__text span { color: var(--muted); font-size: 15px; }
.chev { width: 10px; height: 10px; border-right: 2px solid var(--navy); border-top: 2px solid var(--navy); transform: rotate(45deg); flex: none; margin-right: 6px; }

.bottomnav { margin-top: auto; display: flex; justify-content: space-around; padding-top: 18px; border-top: 1px solid var(--line); }
.bottomnav__item { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 10px 22px; border-radius: 16px; }
.bottomnav__item--active { background: var(--green-soft); color: var(--navy); font-weight: 700; position: relative; }
.bottomnav__item--active::after { content: ""; width: 18px; height: 3px; background: var(--green); border-radius: 3px; }
.ic { width: 20px; height: 20px; display: block; background: var(--navy); border-radius: 50%; }
.ic--home { border-radius: 10px 10px 2px 2px; height: 16px; }
.ic--paths { background: radial-gradient(circle, var(--navy) 35%, transparent 36%); }
.ic--profile { border-radius: 50% 50% 8px 8px; }

/* Buttons */
.btn { width: 100%; border: 0; border-radius: 999px; padding: 17px 20px; font-family: var(--sans); font-size: 17px; font-weight: 700; cursor: pointer; transition: opacity 0.15s; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:disabled { background: #e2e5e7; color: #8a949c; cursor: default; }
.btn[hidden] { display: none; }
.btn--text { background: transparent; color: var(--navy); padding: 12px; }
.btn:active:not(:disabled) { opacity: 0.8; }
.actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 24px; }

.option { width: 100%; display: flex; align-items: center; justify-content: space-between; text-align: left; background: var(--card); border: 0; border-radius: 16px; padding: 20px 18px; margin-bottom: 12px; font-family: var(--sans); cursor: pointer; }
.option span:first-child { display: flex; flex-direction: column; gap: 4px; }
.option b { font-size: 17px; color: var(--navy); }
.option small { color: var(--muted); font-size: 14px; }
.option--disabled { opacity: 0.55; cursor: default; }

/* Recorder */
.recorder { background: var(--card); border: 1.5px solid var(--line); border-radius: 22px; padding: 18px; margin-bottom: 18px; transition: background 0.3s, color 0.3s; }
.recorder[data-state="recording"], .recorder[data-state="paused"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.recorder__status { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.recorder__time { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.recorder[data-state="recording"] .dot { background: #f3b7b0; animation: blink 1.2s infinite; }
.recorder[data-state="paused"] .dot { background: #f1d27a; }
@keyframes blink { 50% { opacity: 0.25; } }
.recorder__wave { width: 100%; height: 100px; display: block; margin: 14px 0; }
.recorder__hint { font-size: 13px; color: var(--muted); margin: 0; }
.recorder[data-state="recording"] .recorder__hint, .recorder[data-state="paused"] .recorder__hint { color: rgba(255,255,255,0.7); }

.kv { margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: 14px; padding-top: 14px; }
.kv dd { margin: 4px 0 14px; font-weight: 700; font-size: 16px; color: var(--navy); border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.kv dd:last-child { border-bottom: 0; }

/* Words */
.words { display: block; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 16px; }
.words--editing { border-color: var(--green); }
.words__head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--navy); }
.words__count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 13px; }
.words__text { margin: 14px 0; font-size: 16px; line-height: 1.5; white-space: pre-wrap; }
.words__note { display: block; border-left: 2px solid var(--green); padding-left: 10px; color: var(--muted); font-size: 14px; }
.words textarea { width: 100%; border: 0; outline: 0; resize: none; font-family: var(--sans); font-size: 16px; line-height: 1.5; margin: 14px 0; background: transparent; color: var(--ink); }

/* Building */
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 10px 0 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.5s linear; }

/* Portfolio */
.total { display: flex; justify-content: space-between; align-items: baseline; background: var(--card); border-radius: 16px; padding: 16px 18px; margin-bottom: 14px; }
.total span { color: var(--muted); }
.total b { font-family: var(--serif); font-size: 24px; color: var(--navy); }
.holdings { display: flex; flex-direction: column; gap: 10px; }
.holding { background: var(--card); border-radius: 16px; padding: 14px 16px; }
.holding__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.holding__name { font-weight: 700; color: var(--navy); }
/* The ticker is pinned to the top-left corner whatever the language of the name. */
.holding__symbol { direction: ltr; text-align: left; color: var(--muted); font-size: 12px; letter-spacing: 0.02em; margin-bottom: 4px; }
.holding__amount { font-weight: 700; color: var(--navy); white-space: nowrap; }
.holding__bar { height: 5px; background: var(--line); border-radius: 5px; margin: 10px 0 8px; overflow: hidden; }
.holding__bar span { display: block; height: 100%; background: var(--green); }
.holding__why { color: var(--muted); font-size: 14px; margin: 0; }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* Portfolio check */
.check { margin-top: 18px; background: var(--card); border-radius: 16px; padding: 16px 18px; }
.check h3 { margin-top: 0; }
.check__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 14px; }
.stat { background: var(--sand); border-radius: 12px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 22px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }
.sectors { display: flex; flex-direction: column; gap: 8px; }
.sector { display: grid; grid-template-columns: 1fr 90px 40px; align-items: center; gap: 10px; font-size: 13px; }
.sector__name { color: var(--ink); }
.sector__bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.sector__bar span { display: block; height: 100%; background: var(--green); }
.sector__pct { text-align: end; color: var(--muted); font-variant-numeric: tabular-nums; }
[dir="rtl"] .sector__bar span { margin-inline-start: auto; }
[dir="rtl"] .holding__bar span { margin-inline-start: auto; }
[dir="rtl"] .back { transform: scaleX(-1); }
[dir="rtl"] .holding__amount { direction: ltr; }

/* Registration */
.screen--welcome { padding-top: 24px; }
.logo--welcome { display: block; font-size: 40px; margin-bottom: 14px; }
.welcome__image { height: 300px; border-radius: 6px; margin-bottom: 26px; background: #d8d0c4 url("/img/welcome.jpg") center / cover no-repeat; }
.welcome__tags { font-weight: 700; color: var(--navy); font-size: 15px; }

.field { display: block; margin: 8px 0 6px; }
.field__label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.field__input { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1.5px solid #c9ccd0; border-radius: 14px; padding: 18px 16px; font-size: 18px; color: var(--navy); min-height: 60px; }
.field__input--error { border-color: var(--danger); }
.field__prefix { color: var(--muted); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; margin: 18px 0 10px; }
.keypad button { background: transparent; border: 0; font-family: var(--sans); font-size: 30px; font-weight: 500; color: var(--navy); padding: 14px 0; border-radius: 14px; cursor: pointer; }
.keypad button:active { background: var(--sand); }
.keypad [data-key="back"] { font-size: 26px; }

.code { display: flex; justify-content: center; gap: 10px; margin: 10px 0 8px; }
.code span { flex: 1; aspect-ratio: 1 / 1.1; max-width: 60px; border: 1.5px solid #9aa0a6; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--navy); background: var(--card); }
.code--pin span { max-width: 70px; }
.code--error span { border-color: var(--danger); }
.error--code { font-size: 13px; margin-top: 0; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 12px 0; }
.steps li { counter-increment: step; display: flex; gap: 22px; padding: 14px 0; font-size: 17px; color: var(--ink); }
.steps li::before { content: counter(step); font-weight: 700; font-size: 13px; color: var(--navy); width: 12px; padding-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; margin-top: 12px; }
.card--center { text-align: center; }
.card h1 { margin: 16px 0 10px; }
.check-mark { display: inline-block; width: 88px; height: 88px; border-radius: 50%; background: var(--green-soft); position: relative; }
.check-mark::after { content: ""; position: absolute; left: 32px; top: 24px; width: 18px; height: 32px; border-right: 3px solid var(--navy); border-bottom: 3px solid var(--navy); transform: rotate(45deg); }

/* Face ID */
@keyframes faceid-scan { from { transform: scale(1); opacity: 1; } to { transform: scale(0.92); opacity: 0.6; } }

/* Face ID screen sits on the ripple photo; the card stays readable on top. */
#faceid { background: #ece6dc url("/img/faceid.jpg") center / cover no-repeat; }

/* Screen 17: Face ID */
.screen--faceid { padding-bottom: 0; }
.faceid-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 260px; }
.faceid-tile { display: inline-flex; align-items: center; justify-content: center; width: 168px; height: 168px; border-radius: 22px; background: rgba(226, 238, 233, 0.92); color: var(--navy); transition: background 0.3s, color 0.3s; }
.faceid-icon--scanning { animation: faceid-scan 0.6s ease-in-out infinite alternate; }
.faceid-icon--done { color: var(--green); }
.sheet { background: var(--card); border-radius: 28px 28px 0 0; margin: 0 -20px; padding: 28px 24px 24px; display: flex; flex-direction: column; gap: 8px; }
.sheet h1 { margin-top: 0; }

/* Screen 18: loader stages */
.stages { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 18px; }
.stages li { position: relative; padding-left: 34px; color: #a4abb2; font-size: 15px; }
.stages li::before { content: ""; position: absolute; left: 0; top: -1px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c3c8cd; box-sizing: border-box; }
.stages li.stage--current { color: var(--ink); }
.stages li.stage--current::before { border-color: var(--navy); }
.stages li.stage--done { color: var(--ink); }
.stages li.stage--done::before { border-color: var(--navy); background: var(--navy); }
.stages li.stage--done::after { content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); }

/* Screen 19: details with a Change action */
.details { display: flex; flex-direction: column; }
.detail { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); }
.detail__label { color: var(--muted); font-size: 14px; }
.detail__value { color: var(--navy); font-size: 16px; }
.detail__input { font-family: var(--sans); font-size: 16px; padding: 12px 14px; border: 1.5px solid var(--green); border-radius: 12px; background: var(--card); color: var(--ink); }
.detail__change { padding: 10px 0 0; }

/* Screen 21: broker choice */
.pagebar .close { grid-column: 3; justify-self: end; width: 36px; height: 36px; border: 0; background: transparent; position: relative; cursor: pointer; }
.pagebar .close::before, .pagebar .close::after { content: ""; position: absolute; left: 9px; top: 17px; width: 18px; height: 2px; background: var(--navy); }
.pagebar .close::before { transform: rotate(45deg); }
.pagebar .close::after { transform: rotate(-45deg); }
.choices { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.choice { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px; border: 1.5px solid #c9ccd0; border-radius: 14px; background: var(--card); font-family: var(--sans); font-size: 18px; color: var(--navy); cursor: pointer; text-align: left; }
.choice .radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #8e959c; box-sizing: border-box; }
.choice--selected { border-color: var(--navy); }
.choice--selected .radio { border: 7px solid var(--navy); }
