:root { --ink:#16202A; --ink-2:#223140; --paper:#F3F5F7; --panel:#fff; --line:#D9DFE5; --muted:#56626E; --red:#C8353B; --blue:#2457D6; --ok:#1E7A4C; --tab-h: 64px; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font: 16px/1.5 "Avenir Next", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.screen { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.5rem; margin: 8px 0 14px; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.stripe { height: 6px; background: repeating-linear-gradient(135deg, var(--red) 0 10px, #fff 10px 20px, var(--blue) 20px 30px); }
.btn { min-height: 48px; padding: 0 18px; border: 2px solid var(--ink); background: #fff; font-weight: 700; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; }
input, select, textarea { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid #A9B4BF; border-radius: 4px; background: #fff; }
textarea { min-height: 96px; }
input[type="checkbox"] { width: 24px; min-height: 24px; height: 24px; flex: none; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > span { font-weight: 700; font-size: .92rem; }
.check { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: .85rem; }
.card-box { background: var(--panel); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.tile { background: var(--panel); border: 1px solid var(--line); padding: 10px; text-align: center; }
.tile b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid img, .preview img { width: 100%; height: auto; display: block; border: 1px solid var(--line); }
.err { color: #9B2428; font-weight: 700; min-height: 1.4em; }
.ok-note { color: var(--ok); font-weight: 700; }
.tabbar { position: fixed; inset: auto 0 0 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--ink); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #B9C6D2; text-decoration: none; font-size: .78rem; position: relative; }
.tabbar a[aria-current="page"] { color: #fff; font-weight: 700; box-shadow: inset 0 3px 0 var(--red); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dot { position: absolute; top: 8px; inset-inline-end: 28%; background: var(--red); color: #fff; border-radius: 10px; font-size: .7rem; min-width: 18px; text-align: center; padding: 0 4px; font-weight: 700; }
.list a.item, .list button.item { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 52px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); margin-bottom: -1px; color: inherit; text-decoration: none; text-align: start; cursor: pointer; }
.pill { display: inline-block; border-radius: 10px; padding: 0 9px; font-size: .78rem; font-weight: 700; background: #E4EAF0; }
.pill.on { background: #DDF1E6; color: var(--ok); } .pill.off { background: #F8DEDF; color: #9B2428; }
.chat { display: flex; flex-direction: column; min-height: 60vh; background: var(--panel); border: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; }
.bubble { max-width: 90%; padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.bubble p { margin: 0; }
.bubble.user { align-self: flex-end; background: var(--ink); color: #fff; }
.bubble.assistant { align-self: flex-start; background: #EDF1F4; }
.bubble.error { align-self: center; background: #F8DEDF; color: #9B2428; }
.chat-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input { min-height: 48px; resize: none; }
.toasts { position: fixed; inset: 12px 12px auto 12px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 6px; }
.toast.error { background: var(--red); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px; margin-inline-end: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.dialog { border: 0; padding: 0; width: min(420px, 94vw); border-radius: 10px; }
.dialog::backdrop { background: rgba(10,18,26,.55); }
.dialog h2 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 16px 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }

/* ---- in-app help (colourful guide and tips) ---- */
.help-guide { margin: 14px 0 4px; }
.help-head { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.help-title { margin: 0; font-size: 1.15rem; }
.help-sub { margin: 2px 0 10px; color: var(--muted); font-size: .9rem; }
.help-hide, .help-show { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.help-show { width: 100%; padding: 10px 14px; text-align: left; color: var(--blue); }
.help-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.help-step { border-radius: 14px; padding: 12px; color: #fff; position: relative; }
.help-step h3 { margin: 8px 0 4px; font-size: .98rem; line-height: 1.2; }
.help-step p { margin: 0; font-size: .82rem; line-height: 1.35; opacity: .95; }
.help-badge { display: flex; align-items: center; justify-content: space-between; }
.help-icon { font-size: 1.6rem; line-height: 1; }
.help-num { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.c-blue { background: linear-gradient(135deg, #2457D6, #4C84F0); }
.c-purple { background: linear-gradient(135deg, #6B3FD0, #9A6BEF); }
.c-green { background: linear-gradient(135deg, #1E7A4C, #34B073); }
.c-orange { background: linear-gradient(135deg, #D9701C, #F2A03D); }
.help-tips, .help-box { margin-top: 10px; border-radius: 12px; padding: 12px 14px; background: #FFF6D6; border: 1px solid #F0D98A; color: #4A3B00; font-size: .88rem; }
.help-tips ul, .help-box ul { margin: 6px 0 0; padding-left: 18px; }
.help-tips li, .help-box li { margin: 3px 0; }
.help-box { margin: 0 0 14px; color: #fff; border: 0; }
.help-box.c-purple { background: linear-gradient(135deg, #6B3FD0, #9A6BEF); }
.help-box.c-green { background: linear-gradient(135deg, #1E7A4C, #34B073); }
@media (max-width: 380px) { .help-steps { grid-template-columns: 1fr; } }

/* ---- v3: Inter font, app-like top bar and tab bar, photo picker ---- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/app/fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/app/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root { --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif; --grad: linear-gradient(135deg, #2457D6, #6B3FD0); }
body { font-family: var(--font); font-feature-settings: "cv11", "ss01"; letter-spacing: -0.006em; background: #EEF1F6; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-weight: 750; letter-spacing: -0.01em; }
.btn { border-radius: 12px; border-width: 1.5px; font-weight: 650; letter-spacing: -0.005em; }
.btn.primary { background: var(--grad); border-color: transparent; box-shadow: 0 6px 16px rgba(60, 70, 200, .28); }
.btn.danger { border-radius: 10px; }
input, select, textarea { border-radius: 12px; border-color: #C3CCD6; }
.card-box, .tile { border-radius: 14px; box-shadow: 0 1px 2px rgba(22, 32, 42, .05); }
.field > span, .field-label { font-weight: 650; }

.appbar { position: sticky; top: 0; z-index: 9; display: flex; align-items: center; justify-content: space-between; height: 56px;
  padding: env(safe-area-inset-top) max(16px, calc((100% - 560px) / 2 + 16px)) 0; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); box-sizing: content-box; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #E9EEFB; color: var(--blue); display: grid; place-items: center; font-weight: 800; text-decoration: none; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }

.tabbar { background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(22, 32, 42, .07); }
.tabbar a { color: #6B7785; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--blue); box-shadow: none; }
.tabbar a[data-tab="new"] svg { width: 52px; height: 52px; padding: 14px; margin-top: -26px; border-radius: 50%; background: var(--grad); color: #fff; border: 4px solid #fff; box-shadow: 0 8px 18px rgba(60, 70, 200, .38); }
.tabbar a[data-tab="new"] { color: #3B4B5C; }
.tabbar a[data-tab="new"][aria-current="page"] { color: var(--blue); }

.pick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 76px; padding: 10px 6px; border-radius: 14px; border: 1.5px solid transparent;
  font-weight: 650; font-size: .85rem; cursor: pointer; line-height: 1.2; text-align: center; }
.pick-i { font-size: 1.6rem; line-height: 1; }
.pick.t-blue { background: #E9F0FF; color: #1B45B0; border-color: #C5D6FA; }
.pick.t-purple { background: #F1EAFE; color: #5428B8; border-color: #D9C9F8; }
.pick.t-green { background: #E3F6EC; color: #176A41; border-color: #BFE6CF; }
.pick:active { transform: scale(.97); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: #dde3ea; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; }
.thumb-x { position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(22, 32, 42, .75); color: #fff; font-size: .8rem; cursor: pointer; }

/* ---- v4: home quick actions, checklist, live camera ---- */
.home-extras { margin-top: 6px; }
.qa-title { margin: 18px 0 8px; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 14px; border-radius: 14px; border: 0; color: #fff; font-weight: 700; font-size: .95rem;
  text-decoration: none; cursor: pointer; text-align: start; box-shadow: 0 4px 12px rgba(22, 32, 42, .12); }
.qa:active { transform: scale(.98); }
.qa-i { font-size: 1.6rem; line-height: 1; }
.checklist { margin-top: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.cl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cl-count { color: var(--muted); font-size: .82rem; font-weight: 600; }
.cl-bar { height: 8px; background: #E6EBF1; border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.cl-bar span { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .3s; }
.cl-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0; border: 0; border-top: 1px solid #EEF1F5; background: none; color: var(--ink); font-weight: 600; text-decoration: none; text-align: start; cursor: pointer; }
.cl-item:first-of-type { border-top: 0; }
.cl-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #B8C3CF; display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: #fff; flex: none; }
.cl-mark.on { background: #1E7A4C; border-color: #1E7A4C; }
.cam-overlay { position: fixed; inset: 0; z-index: 100; background: #0B1118; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.cam-video { max-width: min(100%, 720px); max-height: calc(100vh - 140px); border-radius: 16px; background: #000; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-bar { display: flex; gap: 12px; width: min(100%, 720px); }
.cam-bar .btn { flex: 1; }

/* ---- v5: validation + toasts + phone field ---- */
.field.invalid input, .field.invalid select, .field.invalid .pick { border-color: #C8353B; background: #FFF6F6; }
.field.invalid .picker { outline: 2px solid #F3B9BB; outline-offset: 4px; border-radius: 12px; }
.field-error { color: #B3262C; font-size: .85rem; font-weight: 650; display: block; }
.field-error:empty { display: none; }
.field-error::before { content: "\26A0\FE0F "; }
.phone-row { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 8px; }
.phone-row select { padding-inline: 8px; text-overflow: ellipsis; }
.toast { display: flex; align-items: center; gap: 10px; border-radius: 12px; box-shadow: 0 8px 22px rgba(22, 32, 42, .25); font-weight: 600; }
.toast::before { content: "\2139\FE0F"; font-size: 1.1rem; }
.toast.ok { background: #1E7A4C; } .toast.ok::before { content: "\2705"; }
.toast.warn { background: #B26A00; } .toast.warn::before { content: "\26A0\FE0F"; }
.toast.error { background: #C8353B; } .toast.error::before { content: "\274C"; }

.thumb-kind { position: absolute; bottom: 6px; inset-inline-start: 6px; background: rgba(22, 32, 42, .8); color: #fff; border-radius: 8px; font-size: .72rem; font-weight: 700; padding: 2px 8px; }

/* ---- v6: mobile-app welcome slider and sign-up / log-in ---- */
.welcome { --tone-a: #2457D6; --tone-b: #4C84F0; max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; color: #fff;
  background: linear-gradient(165deg, var(--tone-a), var(--tone-b)); transition: background-color .4s; padding-bottom: env(safe-area-inset-bottom); overflow: hidden; }
.welcome[data-tone="t-purple"] { --tone-a: #6B3FD0; --tone-b: #9A6BEF; }
.welcome[data-tone="t-green"] { --tone-a: #1E7A4C; --tone-b: #34B073; }
.welcome[data-tone="t-orange"] { --tone-a: #D9701C; --tone-b: #F2A03D; }
.w-top { display: flex; justify-content: space-between; align-items: center; padding: max(14px, env(safe-area-inset-top)) 18px 6px; }
.welcome .brand, .auth .brand { color: #fff; }
.welcome .brand-mark, .auth .brand-mark { background: rgba(255, 255, 255, .22); }
.welcome select, .auth-lang select { width: auto; min-height: 36px; padding: 4px 10px; border-radius: 99px; font-weight: 600; font-size: .85rem; }
.welcome select { background: rgba(255, 255, 255, .2); color: #fff; border: 1px solid rgba(255, 255, 255, .4); }
.welcome select option, .auth-lang select option { color: #16202A; }
.w-viewport { flex: 1; overflow: hidden; touch-action: pan-y; outline-offset: -3px; min-height: 340px; }
.w-track { display: flex; height: 100%; transition: transform .45s cubic-bezier(.4, 0, .2, 1); }
.w-slide { flex: 0 0 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 28px 0; text-align: center; }
.w-art svg { width: min(78vw, 320px); height: auto; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .25)); animation: w-float 5s ease-in-out infinite; }
.w-slide h2 { color: #fff; font-size: 1.75rem; font-weight: 800; margin: 14px 0 6px; letter-spacing: -0.02em; line-height: 1.15; }
.w-slide p { margin: 0; opacity: .94; max-width: 30ch; }
@keyframes w-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.w-dots { display: flex; justify-content: center; gap: 8px; padding: 12px 0 6px; }
.w-dot { width: 9px; height: 9px; min-height: 0; padding: 0; border: 0; border-radius: 99px; background: rgba(255, 255, 255, .5); cursor: pointer; transition: width .3s, background .3s; }
.w-dot[aria-current] { width: 28px; background: #fff; }
.w-actions { display: grid; gap: 10px; padding: 10px 20px 4px; }
.welcome .btn.primary { background: #fff; color: #16202A; border-color: #fff; box-shadow: 0 8px 20px rgba(0, 0, 0, .22); }
.welcome .btn.w-login { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .6); }
.w-foot { text-align: center; font-size: .8rem; opacity: .88; margin: 8px 16px 16px; }

.auth { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: linear-gradient(160deg, #2457D6, #6B3FD0); }
.auth.signup { background: linear-gradient(160deg, #1E7A4C, #2457D6); }
.auth-hero { color: #fff; padding: max(16px, env(safe-area-inset-top)) 22px 34px; }
.auth-top { display: flex; align-items: center; gap: 12px; }
.auth-back { width: 40px; height: 40px; min-height: 0; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .2); color: #fff; font-size: 1.2rem; cursor: pointer; padding: 0; }
.auth-hero h1 { color: #fff; font-size: 1.85rem; margin: 22px 0 6px; }
.auth-hero p { margin: 0; opacity: .94; }
.auth-sheet { flex: 1; background: var(--paper); border-radius: 28px 28px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); margin-top: -14px; }
.auth-switch { display: block; width: 100%; margin-top: 12px; background: none; border: 0; color: var(--blue); font-weight: 700; padding: 10px; cursor: pointer; font-size: .95rem; }
.auth-lang { margin-top: 14px; display: flex; justify-content: center; }
.auth-lang select { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.otp { text-align: center; font-size: 1.6rem; letter-spacing: .35em; font-weight: 700; }
.auth-notice { background: #FFF6D6; border: 1px solid #F0D98A; color: #4A3B00; border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin: 0 0 14px; }
.auth-notice[hidden], .field[hidden] { display: none; }
@media (min-width: 600px) {
  .welcome, .auth { margin: 24px auto; min-height: min(800px, calc(100vh - 48px)); border-radius: 30px; box-shadow: 0 24px 60px rgba(22, 32, 42, .28); }
  .auth { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .w-art svg { animation: none; } .w-track { transition: none; } }

/* ---- v6.1: centre slide content, stack the country picker above the number ---- */
.w-viewport { display: flex; }
.w-track { flex: 1; height: auto; }
.phone-row { grid-template-columns: 1fr; }
.w-track { min-width: 0; }
