/* The app's screens. */

/* ── Booting (before Blazor starts) and errors ─────────────────────────── */
#app { height: 100%; }
.boot { height: 100%; display: grid; place-items: center; align-content: center; gap: 28px; background: linear-gradient(color-mix(in srgb, var(--section) 60%, var(--bg)), var(--bg) 56%); }
.boot-mark { width: 96px; height: 96px; }
.boot-bar { width: 120px; height: 2px; border-radius: 1px; background: var(--n800); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: var(--blazor-load-percentage, 10%); background: var(--accent); box-shadow: 0 0 8px var(--glow); transition: width .2s; }
#blazor-error-ui {
  display: none; position: fixed; inset-inline: 16px; bottom: 16px; z-index: 100; padding: 12px 16px; border-radius: 10px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); font-size: 14px;
}
#blazor-error-ui .reload { color: var(--accent); margin-inline-start: 8px; }
#blazor-error-ui .ar { display: none; }
:root[lang="ar"] #blazor-error-ui .ar { display: inline; }
:root[lang="ar"] #blazor-error-ui .en { display: none; }

/* The night-sky ground of the welcome, sign-in and splash screens. */
.night { background: linear-gradient(color-mix(in srgb, var(--section) 60%, var(--bg)), var(--bg) 56%); }
.scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.splash { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.splash-mark { width: 96px; height: 96px; margin-bottom: 4px; }

/* ── The shell ───────────────────────────────────────────────────────────── */
.shell { height: 100%; display: flex; flex-direction: column; }
.shell .screen { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.shell .screen > .page { flex: 1; min-height: 0; }
/* A screen's own scrolling area takes the rest of the height. */
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.page-narrow { width: 100%; max-width: 680px; margin-inline: auto; }
.page-wide { width: 100%; max-width: 980px; margin-inline: auto; }

.tabbar {
  position: relative; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--bg);
  padding: 6px 8px calc(8px + var(--safe-bottom));
}
.tabbar::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--divider) 48px, var(--divider) calc(100% - 48px), transparent); }
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; padding: 8px 2px 4px;
  color: var(--n500); text-decoration: none; min-width: 0;
}
.tab.on { color: var(--accent); }
.tab-mark { position: absolute; top: 0; width: 18px; height: 2px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 8px var(--glow); opacity: 0; transition: opacity .2s; }
.tab.on .tab-mark { opacity: 1; }
/* Six tabs share the width: a long label shrinks a little to show in full rather than being cut off. */
.tab-label { font-size: min(11px, 2.65vw); line-height: 1.2; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: clip; }
.tab-dot { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--glow); }

.rail { display: none; }

/* Desktop first: a sidebar from tablet width up (compact icons with labels under them, then the full sidebar from
   1100px); phones get the bottom tab bar. */
@media (min-width: 768px) {
  .shell.with-rail { flex-direction: row; }
  .tabbar { display: none; }
  .shell .screen { min-width: 0; }
  .rail {
    /* As the admin console's sidebar: the surface, a hairline at its edge. */
    display: flex; flex-direction: column; gap: 2px; width: 88px; flex: none; padding: calc(var(--safe-top) + 18px) 8px 18px;
    background: var(--surface); box-shadow: 1px 0 0 var(--n900); overflow-y: auto; z-index: 1;
  }
  .rail-brand { display: flex; align-items: center; justify-content: center; gap: 11px; padding: 0 0 22px; text-decoration: none; color: var(--text); }
  .rail-brand .mark { width: 36px; height: 36px; }
  .rail-name { display: none; font-size: 18px; font-weight: 500; letter-spacing: calc(-.01em * var(--track)); }
  .rail-item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 60px;
    padding: 6px 4px; border-radius: 12px; color: var(--n400); text-decoration: none; font-size: 11.5px; line-height: 1.2; text-align: center;
  }
  .rail-item:hover { background: rgb(var(--glow-rgb) / .06); color: var(--text); }
  .rail-item.on { color: var(--accent); background: var(--a900); font-weight: 500; }
  .rail-item .dot-new { position: absolute; top: 9px; inset-inline-end: 20px; }
  .rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 12px; }
  .header { padding-inline: 28px; }
  .header.back { padding-inline-start: 18px; }
}
@media (min-width: 1100px) {
  .rail { width: 236px; padding: calc(var(--safe-top) + 22px) 14px 18px; }
  .rail-brand { justify-content: flex-start; padding: 0 8px 24px; }
  .rail-name { display: block; }
  .rail-item { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 15px; text-align: start; }
  .rail-item .dot-new { position: static; margin-inline-start: auto; }
  .rail-foot { align-items: stretch; }
}

/* ── Welcome ─────────────────────────────────────────────────────────────── */
.welcome { position: relative; display: flex; flex-direction: column; overflow-x: hidden; }
.welcome .stars {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke='%23F3F5FE' stroke-opacity='.08' stroke-width='.7'%3E%3Cpath d='M20 6 34 20 20 34 6 20Z'/%3E%3Crect x='10' y='10' width='20' height='20'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: linear-gradient(#000, transparent 60%);
}
.welcome-top { position: relative; padding: calc(var(--safe-top) + 10px) 12px 0; }
.hero { position: relative; height: 360px; width: 100%; max-width: 560px; margin: 0 auto; overflow: visible; flex: none; }
.hero .star { position: absolute; border-radius: 50%; background: var(--star); }
.hero .halo { position: absolute; top: 15px; left: calc(50% - 145px); width: 290px; height: 290px; border-radius: 50%; border: 1px solid rgb(var(--glow-rgb) / .12); }
.hero .halo.big { top: -50px; left: calc(50% - 210px); width: 420px; height: 420px; border-color: rgb(var(--glow-rgb) / .07); background: radial-gradient(color-mix(in srgb, var(--a800) 35%, transparent), transparent 55%); }
.hero-moon { position: absolute; top: -7px; inset-inline-end: calc(50% - 180px); width: 76px; height: 76px; }
.hero-card {
  position: absolute; width: 150px; height: 188px; border-radius: 24px; overflow: hidden;
  background: linear-gradient(170deg, color-mix(in srgb, var(--section-glow) 55%, var(--n900)), var(--a900));
}
.hero-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, rgb(var(--glow-rgb) / .22), transparent 70%); }
.hero-card .initial { position: absolute; top: 44px; inset-inline: 0; text-align: center; font-family: "Inter", sans-serif; font-size: 68px; line-height: 1; color: var(--a200); letter-spacing: -2.7px; text-shadow: 0 0 30px var(--glow-70); }
.hero-card.you { top: 44px; left: calc(50% - 143px); transform: rotate(-7deg); box-shadow: 0 0 0 1px var(--a800), 0 24px 48px -16px var(--shadow); }
.hero-card.match { top: 30px; left: calc(50% - 7px); transform: rotate(6deg); box-shadow: 0 0 0 1px var(--a600), 0 24px 48px -16px var(--shadow), 0 0 60px -18px var(--glow-70); }
.hero-tag { position: absolute; left: 12px; bottom: 12px; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--n100); font-size: 11.5px; line-height: 1.3; }
.hero-lock { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--a200); }
.hero-name { position: absolute; inset-inline: 0; bottom: 0; display: flex; flex-direction: column; padding: 26px 12px 11px; background: linear-gradient(transparent, color-mix(in srgb, var(--bg) 80%, transparent)); font-size: 14px; }
.hero-name .t-secondary { font-size: 11.5px; color: var(--n300); }
.hero-mutual {
  position: absolute; top: 216px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 15px; border-radius: 999px; background: var(--bg); border: 1px solid var(--accent); color: var(--a100); font-size: 13px; line-height: 1.2;
  box-shadow: 0 0 30px -4px var(--glow-70);
}
.hero-mutual .ph { color: var(--accent); }
.hero-khala {
  position: absolute; top: 270px; inset-inline: 24px 56px; display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-radius: 4px 18px 18px 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-md);
}
:root[dir="rtl"] .hero-khala { border-radius: 18px 4px 18px 18px; }
.hero-khala .grow { display: flex; flex-direction: column; }
.hero-khala .t-kicker { letter-spacing: calc(.1em * var(--track)); }
.hero-khala-line { font-size: 13.5px; line-height: 1.35; }
.welcome-body { position: relative; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 520px; margin: auto auto 0; padding: 12px 24px calc(26px + var(--safe-bottom)); }
.welcome-title { font-size: 42px; }
:root[lang="ar"] .welcome-title { font-size: 36px; }
.welcome-title .soft { color: var(--a300); }
.lead { font-size: 16px; color: var(--n300); line-height: 1.5; }
.trust { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.trust span { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--n400); }
.trust .ph { color: var(--accent); }
.welcome .btn.xl { margin-top: 8px; height: 54px; }
.welcome-legal { text-align: center; }
.welcome-legal a { color: var(--n500); text-decoration: none; }

/* ── Sign-in, consent, locked ────────────────────────────────────────────── */
.auth { height: 100%; overflow-y: auto; }
.auth-col { width: 100%; max-width: 460px; margin: 0 auto; padding: calc(var(--safe-top) + 8px) 24px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; }
.auth-col.centered { min-height: 100%; justify-content: center; }
.auth-title { font-size: 34px; margin-top: 22px; }
.auth-col .lead { margin-top: 10px; }
.auth-form { margin-top: 28px; display: flex; flex-direction: column; }
.field-label { font-size: 12px; color: color-mix(in srgb, var(--text) 70%, transparent); margin-bottom: 6px; }
.phone-row { display: flex; gap: 8px; }
.phone-row .btn { flex: none; }
.code-wrap { position: relative; }
.code-input { text-align: center; font-family: "Inter", sans-serif; font-size: 28px; letter-spacing: 14px; padding: 12px 48px; font-variant-numeric: tabular-nums; }
.code-paste { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.or .rule { height: 1px; }
.checks { margin-top: 24px; }
.consent-check { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 13px 0; text-align: start; font-size: 15px; line-height: 1.5; }
.consent-check .box { width: 22px; height: 22px; margin-top: 1px; flex: none; border-radius: 6px; border: 1px solid var(--n700); display: grid; place-items: center; color: var(--a100); transition: background .15s, border-color .15s; }
.consent-check .box.on { border-color: var(--accent); background: var(--a800); }
.locked-title { font-size: 25px; margin: 20px 0 10px; }
.btn.muted { --btn-fg: var(--n400); }

/* ── Sheets: titles, search and lists ────────────────────────────────────── */
.sheet-title { font-size: 19px; line-height: 1.25; margin-bottom: 12px; }
.sheet-search { position: relative; margin-bottom: 8px; }
.sheet-search .ph { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); color: var(--n500); }
.sheet-search .input { padding-inline-start: 38px; }
.sheet-list { display: flex; flex-direction: column; max-height: min(60dvh, 520px); overflow-y: auto; margin: 0 -20px; }
.sheet-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 20px; text-align: start; font-size: 15px; }
.sheet-row.on { color: var(--accent); }
@media (hover: hover) { .sheet-row:hover { background: rgb(var(--glow-rgb) / .06); } }
.flag { font-size: 20px; line-height: 1; width: 26px; text-align: center; }

/* Spacing helpers */
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.pad-v { padding: 12px 20px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

/* ── Khala ───────────────────────────────────────────────────────────────── */
.khala-header { gap: 10px; padding-top: calc(var(--safe-top) + 10px); }
.khala-header .orb { width: 36px; height: 36px; }
.progress { height: 2px; margin: 0 16px 6px; border-radius: 1px; background: var(--n900); overflow: hidden; padding: 0; }
.progress span { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--glow); transition: width .5s var(--ease); }
.grow-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
/* The thread is anchored at the bottom: newest last, and loading older ones above never moves what's on screen. */
.thread { display: flex; flex-direction: column-reverse; }
.thread-inner { display: flex; flex-direction: column-reverse; gap: 8px; padding: 14px 16px; width: 100%; max-width: 760px; margin: 0 auto; }
.thread-row { display: flex; flex-direction: column; }
.thread-row > .bubble.mine, .thread-row > .photo-bubble { align-self: flex-end; }
.bubble { overflow-wrap: anywhere; }
.bubble.unsent { text-align: start; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.bubble-foot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--danger); }
.photo-bubble {
  position: relative; margin: 0; width: min(64%, 300px); border-radius: 18px 18px 4px 18px; overflow: hidden;
  background: var(--a900); box-shadow: inset 0 0 0 1px var(--a800); align-self: flex-end;
}
:root[dir="rtl"] .photo-bubble { border-radius: 18px 18px 18px 4px; }
.photo-bubble > img, .photo-bubble > .photo { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; position: relative; }
.photo-bubble figcaption { padding: 10px 14px; font-size: 15px; line-height: 1.45; }
.photo-bubble-overlay { position: absolute; inset: 0; bottom: auto; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 35%, transparent); aspect-ratio: 4 / 5; }
.photo-gone { display: grid; place-items: center; aspect-ratio: 4 / 5; background: var(--surface); color: var(--n500); font-size: 28px; }
.photo.fill { position: absolute; inset: 0; }
.photo-bubble > .photo.fill { position: relative; inset: auto; }
.progress-ring {
  width: 34px; height: 34px; border-radius: 50%;
  background: conic-gradient(var(--text) calc(var(--p, 0) * 1%), color-mix(in srgb, var(--text) 20%, transparent) 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.progress-ring.spin { background: conic-gradient(var(--text) 25%, color-mix(in srgb, var(--text) 20%, transparent) 0); animation: spin .9s linear infinite; }

/* Candidate cards in the thread */
.thread-card { width: min(88%, 420px); margin: 4px 0; border-radius: var(--r-card); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); align-self: flex-start; }
.thread-card-photo { position: relative; display: block; width: 100%; height: 228px; text-align: start; }
.thread-card-name { position: absolute; inset-inline: 0; bottom: 0; z-index: 3; display: flex; flex-direction: column; padding: 48px 14px 12px; background: linear-gradient(transparent, var(--surface)); }
.thread-card-name .name { font-size: 21px; font-weight: 500; line-height: 1.2; letter-spacing: calc(-.01em * var(--track)); }
.thread-card-name .sub { font-size: 13px; color: var(--n300); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-card-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.lock-pill { position: absolute; top: 10px; inset-inline-start: 10px; z-index: 3; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--n200); font-size: 12px; line-height: 1.3; }
.card-actions { display: flex; align-items: center; gap: 8px; }
.card-actions .grow-10 { flex: 10; min-width: 0; }
.card-actions .grow-14 { flex: 14; min-width: 0; }
.state-line { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; line-height: 1.35; }
.state-line .ph { font-size: 16px; }

.premium-lock { padding: 14px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--a800); box-shadow: 0 0 24px rgb(var(--glow-rgb) / .08); }
.mt-12 { margin-top: 12px; }

/* Under the thread: answer chips or suggestions, the attached photo, the composer */
.composer-wrap { width: 100%; max-width: 760px; margin: 0 auto; padding-top: 6px; }
.composer-wrap .chips.hscroll { padding-bottom: 8px; align-items: center; }
.chips-spark { color: var(--accent); }
.attachment { display: flex; align-items: center; gap: 12px; margin: 0 16px 8px; padding: 8px 4px 8px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--divider); }
.attachment img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.khala .composer { padding-bottom: calc(12px + var(--safe-bottom)); }

/* ── Sheets: choices, photos, height ─────────────────────────────────────── */
.choices { border-radius: 16px; overflow: hidden; background: color-mix(in srgb, var(--bg) 50%, transparent); border: 1px solid rgb(var(--glow-rgb) / .06); }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px 10px 16px; text-align: start; transition: background .16s; }
.choice + .choice { border-top: 1px solid rgb(var(--glow-rgb) / .07); }
.choice .grow { display: flex; flex-direction: column; }
.choice-label { font-size: 15.5px; color: var(--n300); }
.choice.on { background: rgb(var(--glow-rgb) / .07); }
.choice.on .choice-label { color: var(--text); font-weight: 500; }
.choice-sub { font-size: 12.5px; color: var(--n500); }
.choice-tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid var(--n700); display: grid; place-items: center; color: transparent; transition: all .16s; }
.choice.on .choice-tick { background: var(--accent); border-color: var(--accent); color: var(--bg); box-shadow: 0 0 10px var(--glow-25); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo-tile, .photo-add { position: relative; aspect-ratio: 4 / 5; border-radius: 14px; overflow: hidden; }
.photo-tile-main { position: absolute; inset: 0; width: 100%; height: 100%; }
.photo-status { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 6px; text-align: center; font-size: 11.5px; line-height: 1.3; color: var(--n200); background: color-mix(in srgb, var(--bg) 55%, transparent); }
.photo-status.bad { color: var(--danger); }
.photo-main { position: absolute; top: 6px; inset-inline-start: 6px; z-index: 4; }
.photo-working { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 60%, transparent); }
.photo-x { position: absolute; top: 0; inset-inline-end: 0; z-index: 6; width: var(--tap); height: var(--tap); display: flex; align-items: flex-start; justify-content: flex-end; padding: 4px; }
.photo-x .ph { width: 26px; height: 26px; border-radius: 50%; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.photo-add { display: grid; place-items: center; background: var(--bg); border: 1px solid var(--divider); color: var(--accent); cursor: pointer; font-size: 22px; }
.photo-add.disabled { color: var(--n700); cursor: default; }
.photo-add .progress-ring { --text: var(--accent); }

.height-list { max-height: 260px; overflow-y: auto; margin: 0 -20px; scroll-behavior: smooth; }
.height-row { display: block; width: 100%; min-height: 44px; font-size: 18px; text-align: center; color: var(--n400); }
.height-row.on { color: var(--text); font-weight: 500; background: rgb(var(--glow-rgb) / .08); }
.sentinel { height: 1px; flex: none; }

/* The local test server says so on sign-in (dev sign-in only). */
.dev-server { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: var(--r-card); background: rgb(var(--glow-rgb) / .08); box-shadow: inset 0 0 0 1px var(--a700); }
.dev-server > .ph { color: var(--accent); margin-top: 2px; }
.dev-server strong { font-size: 14px; font-weight: 500; }
.dev-server p { margin-top: 2px; font-size: 13px; color: var(--n300); line-height: 1.45; }
.dev-badge { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border-radius: 8px; font-size: 11px; line-height: 1.25; text-align: center; color: var(--n300); box-shadow: inset 0 0 0 1px var(--n800); }
.dev-badge .ph { color: var(--accent); }
@media (max-width: 1099px) { .dev-badge > span { display: none; } }
/* A new version is ready: a bar above everything at the bottom, out of the way of the composer. */
.update-bar {
  position: fixed; z-index: 70; inset-inline: 16px; bottom: calc(16px + var(--safe-bottom)); margin-inline: auto; max-width: 460px;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-md); font-size: 14px; animation: pop .18s var(--ease);
}
:root[dir="rtl"] .update-bar { padding: 10px 14px 10px 10px; }
.update-bar > .ph { color: var(--accent); }
@media (max-width: 767px) { .update-bar { bottom: calc(84px + var(--safe-bottom)); } }
