/* ==========================================================================
   Klingfirm app shell. Loaded last on base.html pages.
   - A fixed bottom tab bar on phones (every public screen).
   - body.kx-app screens: a fixed top bar, a fixed tab bar, and one screen in
     between that fits the viewport. Only the middle scrolls, and only when
     the content is taller than the screen.
   ========================================================================== */

/* ---------- bottom tab bar ---------- */
.kx-tabbar {
  position: fixed; z-index: 90; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(11, 13, 10, .92); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
}
.kx-tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; border-radius: 16px; color: #8d9386; text-decoration: none;
  font: 600 .7rem/1.1 var(--font); letter-spacing: .01em; text-align: center;
}
.kx-tabbar a .ico { transition: transform .15s ease; }
.kx-tabbar a.on { color: var(--lime); }
.kx-tabbar a.on .ico { transform: translateY(-1px); }
.kx-tabbar a:active { background: var(--night-2); }
body.kx-has-tabbar { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
@media (max-width: 1023px) {
  body.kx-has-tabbar .nsc { bottom: calc(84px + env(safe-area-inset-bottom)); right: 14px; }
}
/* The front door stays clean: help is one tap away on every other screen. */
body.kx-home .nsc, body.kx-sheet-open .nsc { display: none; }
@media (min-width: 1024px) {
  .kx-tabbar { display: none; }
  body.kx-has-tabbar { padding-bottom: 0; }
}

/* Phones: the header is a slim fixed bar, not a floating capsule; the
   menu button goes, because the tab bar does its job. */
@media (max-width: 1023px) {
  .site-header, html[data-theme] .site-header { position: sticky; top: 0; padding: 0; }
  .site-header .nav {
    margin: 0; min-height: 60px; padding: 8px 12px 8px 14px; border-radius: 0;
    border-width: 0 0 1px; background: rgba(11, 13, 10, .9);
  }
  .site-header .brand-mark { width: 36px; height: 36px; }
  .site-header .nav-actions .btn-primary { display: none; }
  .site-header .nav-actions .btn { min-height: 42px; padding: 0 1rem; }
}

/* ---------- app screens (body.kx-app) ---------- */
body.kx-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.kx-app > main { flex: 1 0 auto; display: flex; }
body.kx-app .flashes { position: fixed; z-index: 95; left: 12px; right: 12px; top: 68px; margin: 0; }

.kx-bar {
  position: sticky; top: 0; z-index: 85; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; height: 60px; padding: 0 14px; padding-top: env(safe-area-inset-top);
  background: rgba(11, 13, 10, .9); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.kx-bar-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font: 700 1.15rem var(--font-head); letter-spacing: -.02em; }
.kx-bar-brand .brand-mark { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--lime); color: var(--lime-ink); }
.kx-bar-brand .brand-mark svg { width: 20px; height: 20px; }
.kx-bar-brand small { display: none; }
.kx-bar-actions { display: flex; align-items: center; gap: 8px; }

.kx-screen {
  width: 100%; max-width: 560px; margin: 0 auto; padding: 18px 16px 14px;
  display: flex; flex-direction: column; gap: 14px; justify-content: space-between;
  min-height: calc(100dvh - 60px - 72px - env(safe-area-inset-bottom));
}
.kx-screen-narrow { justify-content: flex-start; gap: 16px; max-width: 480px; }
.kx-head .kx-tag { height: 32px; font-size: .8rem; padding: 0 .85rem 0 .45rem; }
.kx-head .kx-tag i { width: 20px; height: 20px; box-shadow: 0 0 0 4px rgba(198, 243, 107, .12); }
.kx-head h1 {
  margin: .7rem 0 .4rem; font-size: clamp(2.5rem, 12vw, 4.2rem); line-height: .95; letter-spacing: -.05em; font-weight: 800;
}
.kx-head h1 .line2 { display: block; }
.kx-head h1 mark { background: none; color: var(--lime); padding: 0; }
.kx-head .kx-h1-sm { font-size: clamp(2rem, 9vw, 2.8rem); }
.kx-sub { margin: 0; color: #a9afa2; font-size: 1rem; line-height: 1.4; }

.kx-start {
  padding: 16px; border-radius: 24px; background: var(--night-1); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.kx-start-label { margin: 0; font-weight: 700; font-size: .95rem; color: var(--ink); }
.kx-phone-row { display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
.kx-dial, .kx-num, .kx-code {
  height: 54px; border-radius: 16px; border: 1px solid var(--border); background: var(--night-2);
  color: var(--ink); font: 600 1.05rem var(--font); padding: 0 12px; width: 100%; min-width: 0;
}
.kx-num { letter-spacing: .02em; }
.kx-dial:focus, .kx-num:focus, .kx-code:focus { outline: 2px solid var(--lime); outline-offset: 1px; border-color: transparent; }
.kx-code { height: 64px; text-align: center; font: 700 1.8rem var(--mono, monospace); letter-spacing: .5em; padding-left: .5em; }
.kx-go { min-height: 54px; font-size: 1.02rem; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.kx-hint { margin: 0; font-size: .82rem; color: #8d9386; line-height: 1.45; }
.kx-hint a, .kx-fine a, .kx-link { color: var(--lime); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; font-size: inherit; cursor: pointer; }
.kx-remember { font-size: .88rem; margin: 0; }
.kx-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kx-finish .field { margin: 0; }
.kx-finish .check { font-size: .86rem; margin: 0; }
.kx-back { display: inline-flex; align-items: center; gap: 6px; color: #a9afa2; text-decoration: none; font-weight: 600; font-size: .9rem; }
.kx-resend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; font-size: .88rem; color: #8d9386; }
.kx-demo-code {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: rgba(198, 243, 107, .08); border: 1px dashed rgba(198, 243, 107, .45); font-size: .85rem; color: #c3c8bb;
}
.kx-demo-code b { font: 700 1.3rem var(--mono, monospace); letter-spacing: .2em; color: var(--lime); }

/* packages: one line each, sideways when there are many */
.kx-packs-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 700; font-size: .95rem; }
.kx-packs-head a { color: var(--lime); font-size: .85rem; text-decoration: none; }
.kx-packs-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(132px, 1fr); gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 2px;
}
.kx-packs-row::-webkit-scrollbar { display: none; }
.kx-pack {
  scroll-snap-align: start; display: flex; flex-direction: column; gap: 1px; padding: 10px 12px 9px;
  border-radius: 18px; background: var(--night-1); border: 1px solid var(--border); color: var(--ink); text-decoration: none;
}
.kx-pack b { font: 700 1rem var(--font-head); }
.kx-pack span { font-size: .85rem; color: #c3c8bb; }
.kx-pack em { font-style: normal; font-size: .74rem; color: var(--lime); font-weight: 600; }
.kx-pack:active { transform: scale(.98); }
.kx-pack-free { background: rgba(198, 243, 107, .08); border-color: rgba(198, 243, 107, .35); }

.kx-how-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 14px 0 7px;
  border-radius: 999px; border: 1px solid rgba(198, 243, 107, .4); background: transparent; color: var(--ink);
  font: 700 .9rem/1.2 var(--font); cursor: pointer; text-align: left;
}
.kx-how-btn > span:nth-child(2) { flex: 1; }
.kx-how-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: var(--lime-ink); flex: none; }
.kx-fine { margin: 0; font-size: .74rem; color: #6f7569; line-height: 1.45; text-align: center; }

/* how-it-works sheet */
.kx-how { position: fixed; inset: 0; z-index: 120; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.kx-how[hidden] { display: none; }
.kx-how-card {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  border-radius: 28px 28px 0 0; background: #11140f; border: 1px solid var(--border); border-bottom: 0;
  padding: 14px 0 calc(16px + env(safe-area-inset-bottom)); animation: kxUp .22s ease-out;
}
@keyframes kxUp { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.kx-how-top { display: flex; justify-content: space-between; align-items: center; padding: 0 16px 8px; }
.kx-dots { display: flex; gap: 6px; }
.kx-dots i { width: 22px; height: 5px; border-radius: 9px; background: var(--night-3); transition: background .2s, width .2s; }
.kx-dots i.on { width: 34px; background: var(--lime); }
.kx-x { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--night-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.kx-slides { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.kx-slides::-webkit-scrollbar { display: none; }
.kx-slide { scroll-snap-align: start; padding: 10px 22px 18px; }
.kx-step { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--lime); color: var(--lime-ink); font: 800 1.6rem var(--font-head); margin-bottom: 14px; }
.kx-slide h2 { font-size: 1.7rem; margin: 0 0 8px; letter-spacing: -.03em; line-height: 1.1; }
.kx-slide p { margin: 0 0 14px; color: #a9afa2; font-size: 1.02rem; line-height: 1.5; }
.kx-xp { list-style: none; margin: 0; padding: 0; }
.kx-xp li { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: rgba(198, 243, 107, .1); color: var(--lime); font-weight: 600; font-size: .85rem; }
.kx-how-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 22px 0; }
.kx-next { min-width: 140px; min-height: 50px; }
body.kx-sheet-open { overflow: hidden; }

/* desktop: the same screen, given room */
@media (min-width: 1024px) {
  .kx-bar { height: 72px; padding: 0 32px; }
  body.kx-app .flashes { top: 80px; max-width: 560px; left: 50%; transform: translateX(-50%); }
  .kx-home .kx-screen {
    max-width: 1100px; min-height: calc(100dvh - 72px); display: grid; align-content: center;
    grid-template-columns: 1.1fr .9fr; column-gap: 64px; row-gap: 16px; padding: 32px;
  }
  .kx-home .kx-head { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .kx-home .kx-head h1 { font-size: clamp(4rem, 7vw, 6.4rem); }
  .kx-home .kx-sub { font-size: 1.2rem; max-width: 30em; }
  .kx-home .kx-start, .kx-home .kx-packs, .kx-home .kx-how-btn, .kx-home .kx-fine { grid-column: 2; }
  .kx-home .kx-fine { text-align: left; }
  .kx-how { align-items: center; }
  .kx-how-card { border-radius: 28px; border-bottom: 1px solid var(--border); }
  .kx-screen-narrow { min-height: calc(100dvh - 72px); justify-content: center; }
}

/* short phones: tighten so the home screen still fits */
@media (max-height: 760px) and (max-width: 1023px) {
  .kx-sub { font-size: .92rem; }
  .kx-packs-head { margin-bottom: 6px; }
  .kx-how-btn { min-height: 46px; }
  .kx-how-ico { width: 34px; height: 34px; }
  .kx-head h1 { font-size: 2.3rem; margin: .5rem 0 .3rem; }
  .kx-head .kx-tag { display: none; }
  .kx-screen { gap: 10px; padding-top: 12px; }
  .kx-start { padding: 12px; gap: 8px; }
  .kx-dial, .kx-num, .kx-go { height: 48px; min-height: 48px; }
}

/* package cards: three tight lines */
.kx-pack { min-height: 0; justify-content: flex-start; }
.kx-pack > * { line-height: 1.25; margin: 0; }
.kx-home .kx-fine { font-size: .7rem; }
@media (max-height: 760px) and (max-width: 1023px) {
  .kx-head h1 { font-size: clamp(1.9rem, 8.6vw, 2.4rem); white-space: nowrap; }
  .kx-head h1 .line2 { display: inline; margin-left: .22em; }
  .kx-screen { gap: 12px; padding-bottom: 10px; }
}
@media (max-height: 760px) and (max-width: 1023px) {
  .kx-screen { padding-top: 8px; gap: 10px; }
  .kx-start { gap: 7px; }
}

/* Public pages on phones: app-sized type and spacing, less scrolling. */
@media (max-width: 1023px) {
  body.kx-has-tabbar main > .section, body.kx-has-tabbar .section { padding: 1.6rem 0; }
  body.kx-has-tabbar .section h1, body.kx-has-tabbar .page-hero h1 { font-size: clamp(1.9rem, 8vw, 2.6rem); line-height: 1.05; }
  body.kx-has-tabbar .section-head h2, body.kx-has-tabbar h2 { font-size: clamp(1.5rem, 6.4vw, 2rem); }
  body.kx-has-tabbar .lede { font-size: 1rem; }
}

.kx-bar-links { display: none; }
.kx-phone-form { display: flex; flex-direction: column; gap: inherit; margin: 0; }
@media (min-width: 1024px) {
  .kx-bar-links { display: flex; gap: 4px; margin-left: auto; }
  .kx-bar-links a { padding: .55rem .95rem; border-radius: 999px; color: #c3c8bb; font-weight: 600; text-decoration: none; }
  .kx-bar-links a:hover { background: var(--night-2); color: var(--ink); }
  .kx-home .kx-head h1 mark { white-space: nowrap; }
}

/* ---------- one-line footer (the link footer lives on /directory) ---------- */
.site-footer.kx-foot, html[data-theme] .site-footer.kx-foot { padding: 14px 0 16px; margin: 0; border-top: 1px solid var(--border); background: transparent; }
.kx-foot-line { margin: 0; font-size: .74rem; line-height: 1.5; color: #6f7569; text-align: center; }
.kx-foot-line a { color: #a9afa2; font-weight: 600; text-decoration: none; }

/* ---------- home: "Already have an account? Sign in" ---------- */
.kx-have { text-align: center; font-size: .86rem; }
@media (max-height: 760px) and (max-width: 1023px) {
  .kx-phone-form .kx-hint:not(.kx-have) { display: none; }
}

/* ---------- directory: tiles ---------- */
.kx-screen-wide { max-width: 980px; justify-content: flex-start; gap: 18px; }
.kx-group h2 { font-size: .78rem !important; letter-spacing: .12em; text-transform: uppercase; color: #8d9386; margin: 0 0 8px; font-weight: 700; }
.kx-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kx-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 76px; padding: 12px;
  border-radius: 18px; background: var(--night-1); border: 1px solid var(--border); color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: .84rem; line-height: 1.2; overflow-wrap: anywhere;
}
.kx-tile .ico { color: var(--lime); }
.kx-tile:active { transform: scale(.98); }
.kx-tiles-small .kx-tile { min-height: 64px; }
.kx-news { margin: 0; border-radius: 20px; }
.kx-disclose summary { cursor: pointer; font-weight: 700; font-size: .85rem; color: #c3c8bb; }
.kx-disclose .risk-disclosure { margin-top: 8px; font-size: .78rem; }
@media (min-width: 720px) { .kx-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ---------- directory: one row per group, tap to open ---------- */
details.kx-group { border-radius: 18px; background: var(--night-1); border: 1px solid var(--border); }
details.kx-group > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 56px;
  padding: 0 16px; cursor: pointer; font: 700 1rem var(--font);
}
details.kx-group > summary::-webkit-details-marker { display: none; }
details.kx-group > summary .ico { color: var(--lime); transform: rotate(-90deg); transition: transform .15s; }
details.kx-group[open] > summary .ico { transform: rotate(90deg); }
details.kx-group > .kx-news { margin: 0 10px 10px; }
details.kx-group .kx-tiles { padding: 0 10px 10px; }
details.kx-group .kx-tile { background: var(--night-2); min-height: 0; flex-direction: row; align-items: center; padding: 11px 12px; }
.kx-screen-wide { gap: 10px; }
.kx-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .kx-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
body.kx-dir .nsc { display: none; }

/* ---------- packages: swipe one card at a time on phones ---------- */
@media (max-width: 1023px) {
  .kx-packs-page .section { padding: 12px 0 8px; }
  .kx-packs-page .section-head { margin-bottom: 10px; }
  .kx-packs-page .section-head .eyebrow, .kx-packs-page .section-head .lede { display: none; }
  .kx-packs-page .section-head h1 { font-size: 1.3rem !important; margin: 0; }
  .kx-swipe {
    display: grid !important; grid-auto-flow: column; grid-template-columns: none !important; grid-auto-columns: 88%;
    gap: 10px !important; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 4px;
  }
  .kx-swipe::-webkit-scrollbar { display: none; }
  .kx-swipe > .card { scroll-snap-align: start; padding: 16px !important; margin: 0; }
  .kx-swipe .spec-list li { padding: .3rem 0 !important; font-size: .88rem; }
  .kx-swipe > .card > * { margin-top: 0 !important; }
  .kx-swipe .spec-list { margin: .3rem 0 .5rem !important; }
  .kx-swipe h3 { font-size: 1.25rem; margin: .3rem 0 .2rem !important; }
  .kx-swipe > .card > div:first-child > .small.muted { display: none; }
  .kx-swipe .price { font-size: 1.7rem; }
  .kx-swipe .price-row, .kx-swipe .split-pay { margin: 0 0 .6rem !important; }
  .kx-packs-page .nsc { display: none; }
  .kx-packs-page main > .section { min-width: 0; max-width: 100%; }
}
