/* ==========================================================================
   Lumio UI kit for Telegram mini-apps. Mobile first; pages only arrange these.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100vh);
  font: 500 15px/1.45 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--lichen); color: var(--on-accent); }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 16px; height: 16px; }

/* ---------- Backdrop: slag, ice and lichen blurred behind glass ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); pointer-events: none; }
.backdrop i { position: absolute; border-radius: 50%; filter: blur(70px); animation: drift 24s var(--ease) infinite alternate; }
.backdrop i:nth-child(1) { width: 85vw; height: 85vw; left: -30vw; top: -20vw; background: var(--blob-1); }
.backdrop i:nth-child(2) { width: 70vw; height: 90vw; right: -35vw; top: 30vh; background: var(--blob-2); animation-delay: -8s; }
.backdrop i:nth-child(3) { width: 80vw; height: 60vw; left: -10vw; bottom: -30vw; background: var(--blob-3); animation-delay: -15s; }
.backdrop::after {
  /* porous "volcanic" grain */
  content: ""; position: absolute; inset: 0; opacity: var(--grain-op);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift { to { transform: translate3d(8vw, 5vh, 0) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .backdrop i { animation: none; } }

/* ---------- Shell ---------- */
.shell { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(110px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 19px/1 var(--font); letter-spacing: .16em; text-transform: uppercase; }
.brand__mark { width: 30px; height: 30px; border-radius: 9px; background: var(--slag); display: grid; place-items: center; box-shadow: inset 0 1px 0 #ffffff26; }
.brand__mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--lichen); box-shadow: 0 0 14px var(--lichen); }
.brand small { font: 600 10.5px/1 var(--font); letter-spacing: .14em; color: var(--muted); margin-left: 2px; }
.top__end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--rim); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font: 800 16px/1 var(--font); text-transform: uppercase;
}

.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); animation: page-in .45s var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }
.eyebrow { font: 700 11px/1.2 var(--font); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.title { font: 800 28px/1.08 var(--font); letter-spacing: -.01em; text-transform: uppercase; }
.title--sm { font-size: 20px; }
.lead { color: var(--muted); font-size: 14.5px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 10px 2px 0; }

/* ---------- Glass ---------- */
.card {
  position: relative; padding: 18px; border-radius: var(--r-card);
  background: var(--glass); border: 1px solid var(--rim); box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.card--flush { padding: 6px; }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card__title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.card__sub { font-size: 13px; color: var(--muted); }
.card__tools { margin-left: auto; }

/* ---------- Swatch: the palette card from the concept ---------- */
.swatch {
  --bgc: var(--sw-slag-bg); --fgc: var(--sw-slag-fg);
  position: relative; display: flex; flex-direction: column; min-height: 168px; padding: 16px;
  border-radius: var(--r-swatch); background: var(--bgc); color: var(--fgc); text-align: left;
  box-shadow: 0 18px 36px -22px #000a; overflow: hidden;
  transition: transform .35s var(--spring), box-shadow .3s, outline-color .2s;
  outline: 2px solid transparent; outline-offset: 3px;
}
.swatch--ice { --bgc: var(--sw-ice-bg); --fgc: var(--sw-ice-fg); }
.swatch--lichen { --bgc: var(--sw-lichen-bg); --fgc: var(--sw-lichen-fg); }
.swatch--stone { --bgc: var(--sw-stone-bg); --fgc: var(--sw-stone-fg); }
.swatch__name { font: 800 20px/1.1 var(--font); letter-spacing: .01em; text-transform: uppercase; }
.swatch__big { font: 800 52px/1 var(--font); letter-spacing: -.04em; margin-top: auto; }
.swatch__meta { margin-top: auto; padding-top: 14px; display: grid; gap: 2px; font-size: 12px; line-height: 1.35; }
.swatch__meta b { font-weight: 800; letter-spacing: .04em; margin-right: 6px; }
.swatch__meta span { opacity: .82; }
button.swatch:active { transform: scale(.97); }
.swatch[aria-pressed="true"] { outline-color: var(--text); transform: translateY(-3px); }
.swatch[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--fgc);
}
.swatch[aria-pressed="true"]::before {
  content: ""; position: absolute; z-index: 1; top: 17px; right: 20px; width: 6px; height: 10px;
  border: solid var(--bgc); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.swatches--cat .swatch { min-height: 82px; }
.swatches--cat .swatch__name { font-size: 17px; }
.swatch[aria-pressed="true"] .swatch__name { padding-right: 28px; }
.swatches--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.swatches--4 .swatch { min-height: 96px; padding: 10px; }
.swatches--4 .swatch__name { font-size: 13px; }
.swatches--4 .swatch__big { font-size: 30px; }

/* Hero status card */
.hero { min-height: 230px; padding: 20px; }
.hero .swatch__name { font-size: 26px; max-width: 80%; }
.hero__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; }
.hero__unit { font-size: 13px; font-weight: 600; opacity: .8; margin-top: 4px; }
.meter { height: 6px; border-radius: 99px; background: color-mix(in oklab, var(--fgc) 18%, transparent); overflow: hidden; margin-top: 16px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--fgc); transform-origin: left; animation: grow 1s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: currentColor; position: absolute; top: 22px; right: 22px; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: inherit; animation: ping 2s ease-out infinite; }
@keyframes ping { to { transform: scale(3); opacity: 0; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 999px; white-space: nowrap;
  font-size: 15px; font-weight: 700; border: 1px solid transparent;
  transition: transform .2s var(--spring), background .2s, filter .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn--accent { background: var(--lichen); color: var(--on-accent); box-shadow: inset 0 1px 0 #ffffff80, 0 12px 26px -14px #9fbb10; }
.btn--ink { background: var(--text); color: var(--bg); }
.btn--on { background: var(--fgc, var(--text)); color: var(--bgc, var(--bg)); }
.btn--glass { background: var(--glass); border-color: var(--rim); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.btn--ghost { border-color: var(--line-2); }
.btn--danger { color: var(--bad); border-color: color-mix(in oklab, var(--bad) 40%, transparent); }
.btn--sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn--block { width: 100%; }
.btn .spin { width: 18px; height: 18px; }
.ibtn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--line-2); transition: background .2s, transform .2s var(--spring);
}
.ibtn:active { transform: scale(.9); }
.ibtn--glass { background: var(--glass); border-color: var(--rim); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }

/* ---------- Rows & lists ---------- */
.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px;
  border-radius: 16px; text-align: left; width: 100%; transition: background .2s;
}
button.row:active, a.row:active { background: var(--well); }
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row__ic {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--well); font-size: 20px;
}
.row__ic--accent { background: var(--lichen); color: var(--on-accent); }
.row__body { min-width: 0; flex: 1; display: grid; gap: 1px; }
.row__title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__end { flex: none; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  background: var(--well); color: var(--muted);
}
.tag--lichen { background: var(--lichen); color: var(--on-accent); }
.tag--ice { background: var(--sw-ice-bg); color: var(--sw-ice-fg); box-shadow: inset 0 0 0 1px var(--line); }
.tag--slag { background: var(--slag); color: var(--ice); }
.tag--stone { background: var(--stone); color: #161617; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lichen); box-shadow: 0 0 0 3px color-mix(in oklab, var(--lichen) 30%, transparent); flex: none; }

.bar { height: 5px; border-radius: 99px; background: var(--well); overflow: hidden; width: 54px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--lichen)); }

/* ---------- Segmented & chips ---------- */
.seg { display: flex; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--rim); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; height: 36px; padding: 0 10px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--muted); white-space: nowrap; transition: background .25s, color .25s; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.card .seg { background: var(--well); border-color: transparent; }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 6px; }
.field__label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.input, .textarea {
  width: 100%; padding: 13px 16px; border-radius: 16px; border: 1px solid var(--line-2);
  background: var(--glass-2); outline: none; transition: border-color .2s, box-shadow .2s; font-size: 15px;
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus { border-color: var(--lichen); box-shadow: 0 0 0 4px color-mix(in oklab, var(--lichen) 25%, transparent); }
.copy {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 16px;
  background: var(--well); font: 600 13px/1.3 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted);
}
.copy span { flex: 1; width: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; gap: 4px; padding: 6px; border-radius: 999px; width: min(calc(100% - 32px), 420px);
  background: var(--glass-3); border: 1px solid var(--rim); box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
:root[data-theme="dark"] .tabbar { background: #2a2a2be6; }
.tabbar a {
  flex: 1; display: grid; justify-items: center; gap: 3px; padding: 8px 4px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  transition: background .25s, color .25s;
}
.tabbar a[aria-current="page"] { background: var(--slag); color: var(--ice); }
.tabbar a[aria-current="page"] .ico { color: var(--lichen); }
:root[data-theme="dark"] .tabbar a[aria-current="page"] { background: var(--ice); color: var(--slag); }
:root[data-theme="dark"] .tabbar a[aria-current="page"] .ico { color: var(--slag); }
.tabbar .ico { width: 21px; height: 21px; }
.tabbar .has-badge { position: relative; }
.tabbar .has-badge::after { content: ""; position: absolute; top: 6px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--lichen); box-shadow: 0 0 0 2px var(--glass-3); }

/* ---------- Sticky action bar (above tabbar or alone) ---------- */
.actionbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 29; width: min(calc(100% - 32px), 528px);
  bottom: calc(14px + env(safe-area-inset-bottom));
}
.has-tabbar .actionbar { bottom: calc(88px + env(safe-area-inset-bottom)); }

/* ---------- Chat ---------- */
.chat { display: grid; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 84%; padding: 10px 14px 8px; border-radius: 20px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.4; animation: page-in .3s var(--ease) both; }
.msg time { display: block; margin-top: 3px; font-size: 11px; opacity: .65; text-align: right; }
.msg__who { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .7; margin-bottom: 2px; }
.msg--me { justify-self: end; background: var(--lichen); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg--them { justify-self: start; background: var(--glass-3); border: 1px solid var(--rim); border-bottom-left-radius: 6px; }
.msg--sys { justify-self: center; max-width: none; padding: 4px 12px; background: var(--well); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; }
.composer {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  width: min(calc(100% - 24px), 536px); display: flex; align-items: flex-end; gap: 8px; padding: 6px;
  border-radius: 26px; background: var(--glass-3); border: 1px solid var(--rim); box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.composer textarea { flex: 1; min-height: 40px; max-height: 140px; padding: 9px 12px; border: 0; background: none; outline: none; resize: none; font-size: 15px; line-height: 1.4; }
.composer .ibtn { background: var(--lichen); color: var(--on-accent); border: 0; }

/* ---------- Sheet (bottom modal) ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: #0007; animation: fade .25s both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 560px; margin: 0 auto;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0;
  background: var(--glass-3); box-shadow: var(--shadow-pop); animation: sheet-in .4s var(--ease) both;
  display: grid; gap: 14px; max-height: 88vh; overflow: auto;
}
.sheet::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 9px; background: var(--line-2); margin: -8px 0 4px; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 11px 16px; border-radius: 999px; background: var(--slag); color: var(--ice); font-weight: 700; font-size: 14px; box-shadow: var(--shadow-pop); animation: page-in .3s var(--ease) both; }
.toast--good::before { content: "●"; color: var(--lichen); margin-right: 8px; }
.toast--bad::before { content: "●"; color: #ff8f78; margin-right: 8px; }

/* ---------- States ---------- */
.empty { display: grid; justify-items: center; gap: 10px; padding: 34px 20px; text-align: center; color: var(--muted); }
.empty__art { width: 70px; height: 70px; border-radius: 22px; display: grid; place-items: center; background: var(--well); color: var(--text); }
.skel { border-radius: var(--r-card); background: linear-gradient(90deg, var(--well) 25%, var(--glass-2) 50%, var(--well) 75%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- FAQ ---------- */
.faq details { border-radius: 16px; transition: background .2s; }
.faq details + details { box-shadow: 0 -1px 0 var(--line); }
.faq summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 15px 12px; font-weight: 700; cursor: pointer; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; font: 500 22px/1 var(--font); color: var(--muted); transition: transform .3s var(--spring); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 12px 15px; color: var(--muted); font-size: 14px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: grid; gap: 4px; padding: 14px; border-radius: var(--r-tile); background: var(--glass); border: 1px solid var(--rim); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); text-align: left; }
.tile:active { transform: scale(.98); }
.tile__value { font: 800 26px/1.1 var(--font); }
.tile__label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.note { font-size: 12.5px; color: var(--faint); text-align: center; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; background: color-mix(in oklab, var(--lichen) 20%, transparent); font-size: 13px; font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
