/* ==========================================================================
   Alerto Mobile — design system
   Dark, clean, telegram-like. Shared by app.html (live) and index.html (frames)
   ========================================================================== */

:root {
  --bg-primary: #0F1117;
  --bg-secondary: #151924;
  --bg-card: #1B2030;
  --bg-elevated: #1F2536;
  --border: #2A3142;
  --border-soft: #232a3a;
  --text-primary: #F4F7FB;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --primary: #4F8CFF;
  --primary-hover: #3B7AEF;
  --primary-soft: rgba(79, 140, 255, 0.14);
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #38BDF8;
  --purple: #A855F7;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-sheet: 0 -12px 40px rgba(0, 0, 0, 0.5);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --tabbar-h: 64px;
  --appbar-h: 56px;
  --statusbar-h: 28px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
input, textarea, select { font-family: inherit; }

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.12em 0.4em;
  border-radius: 5px;
}

::-webkit-scrollbar { width: 0; height: 0; }

/* ==========================================================================
   App shell — phone-sized fluid container
   ========================================================================== */
.app {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
  isolation: isolate;
}

/* Full-width on real phones; centered phone frame on wider viewports */
@media (min-width: 480px) {
  body.app-standalone {
    display: grid;
    place-items: center;
    background:
      radial-gradient(ellipse at 50% 0%, rgba(79, 140, 255, 0.10), transparent 55%),
      var(--bg-secondary);
  }
  body.app-standalone .app {
    width: min(100%, 440px);
    height: min(92vh, 920px);
    border: 1px solid var(--border);
    border-radius: 36px;
    box-shadow: var(--shadow);
  }
}

/* Inside showcase device iframes — fill the frame, no outer chrome */
body.app-embedded {
  background: var(--bg-primary);
}
body.app-embedded .app {
  max-width: none;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
body.app-embedded .statusbar {
  display: none;
}

/* ===== Fake status bar ===== */
.statusbar {
  flex: 0 0 auto;
  min-height: var(--statusbar-h);
  height: calc(var(--statusbar-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 20px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  z-index: 30;
  background: var(--bg-primary);
}
.statusbar__icons { display: flex; align-items: center; gap: 6px; }
.statusbar__icons svg { display: block; }

/* ==========================================================================
   Screens (stacked, one active)
   ========================================================================== */
.screens {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-primary);
  opacity: 0;
  visibility: hidden;
  transform: translateX(12px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  pointer-events: none;
}
.screen--active {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  z-index: 2;
}
.screen--back { transform: translateX(-12px); }

.screen__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.screen__body--pad { padding: 16px; }
.screen[data-tab] > .screen__body {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   App bar (top)
   ========================================================================== */
.appbar {
  flex: 0 0 auto;
  min-height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  z-index: 20;
}
.appbar__title-wrap { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.appbar__title-btn {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.appbar__title-btn:active {
  opacity: 0.75;
}
.appbar__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__subtitle--online { color: var(--success); }
.appbar__spacer { flex: 1; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.icon-btn:active { background: var(--bg-card); color: var(--text-primary); }
.icon-btn--primary { color: var(--primary); }

.appbar__logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 18px;
}
.appbar__logo-icon { display: flex; color: var(--primary); }
.appbar--home {
  border-bottom: 1px solid var(--border-soft);
}
.appbar--home .appbar__brand {
  display: flex;
  align-items: center;
  min-width: 0;
}
.appbar--home .appbar__search {
  display: none;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}
.appbar--home .appbar__search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}
.appbar--home .appbar__search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition);
}
.appbar--home .appbar__search input:focus {
  border-color: var(--primary);
}
.appbar--home .appbar__search input::placeholder { color: var(--text-muted); }
.appbar--home .appbar__search-cancel {
  display: none;
  flex-shrink: 0;
  padding: 8px 2px 8px 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--primary);
}
.appbar--home.appbar--search-open .appbar__brand,
.appbar--home.appbar--search-open .appbar__spacer,
.appbar--home.appbar--search-open #homeSearchOpen,
.appbar--home.appbar--search-open #homeCreateBtn {
  display: none;
}
.appbar--home.appbar--search-open .appbar__search {
  display: flex;
}
.appbar--home.appbar--search-open .appbar__search-cancel {
  display: inline-flex;
  align-items: center;
}

.appbar__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.appbar__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

/* ==========================================================================
   Search field
   ========================================================================== */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 4px;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}
.search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
}
.search input::placeholder { color: var(--text-muted); }

/* ==========================================================================
   Segmented control (filter tabs)
   ========================================================================== */
.segmented {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented__btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 100px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}
.segmented__btn--active {
  background: var(--primary-soft);
  border-color: rgba(79, 140, 255, 0.35);
  color: var(--primary);
}

/* ==========================================================================
   Chat list rows
   ========================================================================== */
.chat-list { padding: 6px 8px 16px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: pointer;
}
.row:active { background: var(--bg-card); }

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar--bot { background: rgba(79, 140, 255, 0.18); color: var(--primary); font-weight: 700; }
.avatar__hash--bot { color: var(--primary); }
.avatar--channel { background: rgba(34, 197, 94, 0.18); color: var(--success); font-weight: 700; }
.avatar--group { background: linear-gradient(135deg, #A855F7, #7c3aed); }
.avatar--dm { background: linear-gradient(135deg, #F59E0B, #d97706); }
.avatar--sm { width: 40px; height: 40px; font-size: 15px; }
.avatar--lg { width: 72px; height: 72px; font-size: 28px; border-radius: 22px; }
.avatar__hash { font-size: 22px; }

.avatar__status {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2.5px solid var(--bg-primary);
}
.avatar__status--online { background: var(--success); }

.row__main { flex: 1; min-width: 0; }
.row__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px 8px;
  align-items: center;
  margin-bottom: 2px;
}
.row__name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.row__time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.row__bottom { display: flex; align-items: center; gap: 8px; }
.row__preview {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__preview b { color: var(--text-secondary); font-weight: 600; }

.badge-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.badge-count--muted { background: var(--bg-elevated); color: var(--text-secondary); }

.pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.pill--bot { background: var(--primary-soft); color: var(--primary); }

/* ==========================================================================
   Chat / feed screen
   ========================================================================== */
.feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px 20px;
}
.date-chip {
  align-self: center;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 4px 12px;
  border-radius: 100px;
  margin: 4px 0;
}

.msg { display: flex; gap: 10px; max-width: 92%; }
.msg__avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  color: #fff;
}
.msg__avatar--bot { background: rgba(79, 140, 255, 0.18); color: var(--primary); font-weight: 700; }
.msg__avatar--channel { background: rgba(34, 197, 94, 0.18); color: var(--success); font-size: 15px; font-weight: 700; }
.msg__avatar--user { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.msg__avatar--system { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.msg__content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.msg__bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 12px;
  min-width: 0;
}
.msg__head { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.msg__author { font-size: 13px; font-weight: 600; }
.msg__tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg__time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.msg__text { font-size: 14px; color: var(--text-primary); line-height: 1.5; word-wrap: break-word; }
.msg__text code { font-size: 0.82em; }
.msg__image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.msg__buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.chip-btn {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: background var(--transition), border-color var(--transition);
}
.chip-btn:active { background: var(--bg-card); }
.msg__buttons--pending .chip-btn {
  opacity: 0.55;
  cursor: wait;
}
.msg--out { flex-direction: row-reverse; align-self: flex-end; }
.msg--out .msg__bubble {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: 14px 4px 14px 14px;
}
.msg--out .msg__author, .msg--out .msg__text { color: #fff; }
.msg--out .msg__time { color: rgba(255, 255, 255, 0.7); }

/* system message */
.msg--system {
  align-self: center;
  max-width: 90%;
  text-align: center;
}
.msg--system .msg__text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Compose bar ===== */
.compose {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-soft);
}
.compose__input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 100px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.compose__input::placeholder { color: var(--text-muted); }

.msg__text--command {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--info);
}

.msg__text--command code {
  font-family: inherit;
}
.compose__input:focus { border-color: var(--primary); }
.compose__send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.compose__send:active { transform: scale(0.92); }
.compose--readonly {
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  gap: 6px;
}

/* ==========================================================================
   Cards & generic content
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card__title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.list-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  transition: background var(--transition);
}
.list-item + .list-item { border-top: 1px solid var(--border-soft); }
.list-item:active { background: var(--bg-elevated); }
.list-item__icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary);
}
.list-item__icon--green { background: rgba(34,197,94,.14); color: var(--success); }
.list-item__icon--purple { background: rgba(168,85,247,.14); color: var(--purple); }
.list-item__icon--amber { background: rgba(245,158,11,.14); color: var(--warning); }
.list-item__icon--red { background: rgba(239,68,68,.14); color: var(--danger); }
.list-item__icon--muted { background: var(--bg-elevated); color: var(--text-secondary); }
.list-item__main { flex: 1 1 auto; min-width: 0; }
.list-item__title { font-size: 14px; font-weight: 500; }
.list-item__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__meta { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.list-item__chevron { color: var(--text-muted); flex-shrink: 0; }

/* ===== Bot card ===== */
.bot-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 14px;
  transition: border-color var(--transition);
}
.bot-card + .bot-card { margin-top: 12px; }
.bot-card:active { border-color: rgba(79,140,255,.35); }
.bot-card__head { display: flex; align-items: center; gap: 12px; }
.bot-card__info { flex: 1 1 auto; min-width: 0; }
.bot-card__name { font-size: 15px; font-weight: 600; }
.bot-card__desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card__stats {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.bot-stat { flex: 1; text-align: center; }
.bot-stat__value { font-size: 15px; font-weight: 700; font-family: var(--font-mono); }
.bot-stat__label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

.kv { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 13px; }
.kv + .kv { border-top: 1px solid var(--border-soft); }
.kv__key { color: var(--text-secondary); }
.kv__val { color: var(--text-primary); font-weight: 500; }
.kv__val--mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }

/* ===== Webhook log ===== */
.wh-log {
  background: var(--bg-primary);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.wh-log + .wh-log { margin-top: 8px; }
.wh-log__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.wh-log__event { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.wh-log__status {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 1px 7px;
  border-radius: 5px;
}
.wh-log__status--ok { background: rgba(34,197,94,.14); color: var(--success); }
.wh-log__status--err { background: rgba(239,68,68,.14); color: var(--danger); }
.wh-log__meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Code block ===== */
.code-block {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
}
.code-block pre {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre;
}
.jk { color: var(--info); }
.js-str { color: var(--success); }
.jn { color: var(--warning); }

/* ==========================================================================
   Toggle, buttons, forms
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.app .btn { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--outline { border: 1px solid var(--border); color: var(--text-primary); background: var(--bg-card); }
.btn--danger { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.btn--ghost { color: var(--primary); }
.btn--sm { padding: 9px 14px; font-size: 13px; width: auto; }

.toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle__track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 100px;
  transition: background var(--transition);
}
.toggle__track::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle__track { background: var(--primary); }
.toggle input:checked + .toggle__track::before { transform: translateX(18px); }

.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 7px; }
.field__input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field__input::placeholder { color: var(--text-muted); }
.field__input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,140,255,.15); }
textarea.field__input { resize: none; }
.field__input--readonly {
  opacity: 0.72;
  cursor: default;
  background: var(--bg-card);
}

.chat-info__hint {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.chat-info__hint a {
  color: var(--primary);
  text-decoration: none;
}

.chat-info__action {
  margin-top: 16px;
}
.field__hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ==========================================================================
   Bottom tab bar
   ========================================================================== */
.tabbar {
  flex: 0 0 auto;
  min-height: var(--tabbar-h);
  display: flex;
  align-items: center;
  background: rgba(21, 25, 36, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 25;
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar-h);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  transition: color var(--transition);
  position: relative;
}
.tab svg { transition: transform var(--transition); flex-shrink: 0; }
.tab--active { color: var(--primary); }
.tab--active svg { transform: translateY(-1px); }

.tab__badge {
  position: absolute;
  top: 0;
  right: 50%;
  margin-right: -18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-secondary);
}

/* ==========================================================================
   Activity feed
   ========================================================================== */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
}
.activity-item + .activity-item { border-top: 1px solid var(--border-soft); }
.activity-item__dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-item__dot--ok { background: rgba(34,197,94,.14); color: var(--success); }
.activity-item__dot--err { background: rgba(239,68,68,.14); color: var(--danger); }
.activity-item__dot--info { background: var(--primary-soft); color: var(--primary); }
.activity-item__dot--warn { background: rgba(245,158,11,.14); color: var(--warning); }
.activity-item__main { flex: 1; min-width: 0; }
.activity-item__text { font-size: 13.5px; line-height: 1.45; }
.activity-item__text b { font-weight: 600; }
.activity-item__time { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ==========================================================================
   Bottom sheet (message details)
   ========================================================================== */
.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  z-index: 50;
}
.sheet-overlay--open { opacity: 1; visibility: visible; }

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82%;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-sheet);
  transform: translateY(100%);
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
  z-index: 51;
}
.sheet-overlay--open .sheet { transform: translateY(0); }
.sheet__handle {
  width: 38px;
  height: 4px;
  border-radius: 100px;
  background: var(--border);
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet__title { font-size: 16px; font-weight: 700; }
.sheet__header-text { min-width: 0; }
.sheet__body { overflow-y: auto; padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }

.chat-info__type {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.chat-info__desc {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.chat-info__meta {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chat-info__meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-info__meta-row + .chat-info__meta-row {
  border-top: 1px solid var(--border-soft);
}

.chat-info__meta-value {
  color: var(--text-secondary);
  text-align: right;
  word-break: break-all;
}

.chat-info__meta-value--mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--info);
}

.token-field {
  margin-bottom: 14px;
}

.token-field__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.token-field__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.token-field__value {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--info);
  word-break: break-all;
}

.token-field__btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  flex-shrink: 0;
}

.token-field__btn--text {
  width: auto;
  height: auto;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--primary);
}

.token-field__hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.sheet__section + .sheet__section { margin-top: 18px; }
.sheet__section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet__count {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 100px;
  letter-spacing: 0;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  font-size: 13px;
}
.action-row + .action-row { border-top: 1px solid var(--border-soft); }
.action-row__label { flex: 1; font-weight: 500; }
.action-row__id { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.action-row__status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 100px; }
.action-row__status--clicked { background: rgba(34,197,94,.14); color: var(--success); }
.action-row__status--pending { background: var(--bg-card); color: var(--text-muted); }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 32px;
  color: var(--text-muted);
}
.empty svg { margin-bottom: 16px; color: var(--border); }
.empty__title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty__text { font-size: 13px; line-height: 1.6; }

/* ==========================================================================
   Login / onboarding screen
   ========================================================================== */
.auth {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 28px calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.auth__hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 0;
  position: relative;
}
.auth__glow {
  position: absolute;
  top: 10%;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(79,140,255,.25), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}
.auth__logo-badge {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(79,140,255,.4);
  position: relative;
}
.auth__title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
.auth__title .grad {
  background: linear-gradient(135deg, var(--primary), var(--info));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth__subtitle { font-size: 14px; color: var(--text-secondary); max-width: 280px; line-height: 1.6; }
.auth__form { flex-shrink: 0; }
.auth__divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.auth__divider::before, .auth__divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth__social { display: flex; gap: 12px; }
.auth__social .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  gap: 8px;
  padding: 12px 10px;
  font-size: 14px;
}
.auth__foot { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 22px; }
.auth__foot a { color: var(--primary); font-weight: 500; }

/* ==========================================================================
   Profile screen
   ========================================================================== */
.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px 20px;
}
.profile-head__name { font-size: 19px; font-weight: 700; margin-top: 14px; }
.profile-head__email { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

.group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 18px 20px 8px;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 100px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
  z-index: 60;
  white-space: nowrap;
  max-width: 88%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast--show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.app--tabs-visible .toast {
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px));
}
.toast--success { border-color: rgba(34,197,94,.4); }
.toast--success::before { content: '✓ '; color: var(--success); }
.toast--error { border-color: rgba(239,68,68,.4); }
.toast--error::before { content: '✕ '; color: var(--danger); }

/* ==========================================================================
   Create chooser
   ========================================================================== */
.choose-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color var(--transition);
}
.choose-card + .choose-card { margin-top: 12px; }
.choose-card:active { border-color: var(--primary); }
.choose-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.choose-card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.choose-card__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.choose-card__desc {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.choose-card .list-item__chevron {
  flex-shrink: 0;
  align-self: center;
}

/* ==========================================================================
   Showcase page (index.html) — device frames gallery
   ========================================================================== */
.showcase {
  min-height: 100vh;
  overflow-x: hidden;
}
.sc-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.sc-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  min-width: 0;
  flex: 1 1 auto;
}
.sc-header__logo-icon { color: var(--primary); display: flex; flex-shrink: 0; }
.sc-header .btn {
  width: auto;
  padding: 9px 16px;
  font-size: 14px;
  flex-shrink: 0;
  white-space: nowrap;
}
.sc-header__cta-short { display: none; }
.sc-header__cta-full { display: inline; }
@media (max-width: 520px) {
  .sc-header {
    padding: 12px 16px;
  }
  .sc-header__logo {
    font-size: 16px;
    gap: 8px;
  }
  .sc-header .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  .sc-header__cta-full { display: none; }
  .sc-header__cta-short { display: inline; }
}

.sc-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.sc-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 48px;
  align-items: center;
  padding: 72px 0 64px;
}
.sc-hero > div:first-child {
  max-width: 560px;
}
@media (max-width: 880px) {
  .sc-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 48px 0;
    justify-items: center;
  }
  .sc-hero > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 520px;
  }
  .sc-hero__phone { margin: 0 auto; }
}
@media (max-width: 480px) {
  .sc-container { padding: 0 16px; }
  .sc-hero { padding: 32px 0 40px; }
  .sc-hero__title { font-size: clamp(28px, 8.5vw, 36px); }
  .sc-hero__actions,
  .sc-stores {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 320px;
  }
  .sc-hero__actions .btn,
  .store-btn {
    width: 100%;
    justify-content: center;
  }
  .store-btn__text { align-items: center; }
  .device--lg {
    width: min(calc(100vw - 32px), 300px);
    height: 580px;
  }
  .sc-section { padding: 40px 0; }
  .sc-section__head { margin-bottom: 32px; }
}
.sc-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 22px;
}
.sc-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.sc-hero__title {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}
.sc-hero__title .grad {
  background: linear-gradient(135deg, var(--primary), var(--info));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sc-hero__desc { font-size: 17px; color: var(--text-secondary); line-height: 1.7; max-width: 460px; margin-bottom: 30px; }
@media (max-width: 880px) { .sc-hero__desc { margin-left: auto; margin-right: auto; } }
.sc-hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }
@media (max-width: 880px) { .sc-hero__actions { justify-content: center; } }
.sc-hero__actions .btn { width: auto; padding: 12px 22px; }
.sc-stores { display: flex; gap: 12px; flex-wrap: wrap; }
@media (max-width: 880px) { .sc-stores { justify-content: center; } }
.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-width: 158px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.store-btn > svg { flex-shrink: 0; }
.store-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  line-height: 1.15;
  min-width: 0;
}
.store-btn:hover { border-color: var(--primary); transform: translateY(-2px); }
.store-btn__sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.store-btn__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

/* Device frame */
.device {
  position: relative;
  width: 300px;
  height: 620px;
  background: #060810;
  border: 10px solid #060810;
  border-radius: 44px;
  box-shadow: var(--shadow), 0 0 0 1.5px var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.device--lg { width: 320px; height: 660px; }
.device__notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 130px;
  height: 26px;
  background: #060810;
  border-radius: 0 0 16px 16px;
  z-index: 10;
}
.device__notch::after {
  content: '';
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 5px;
  background: #1a1f2e;
  border-radius: 100px;
}
.device iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 34px;
  background: var(--bg-primary);
  display: block;
}

.sc-section { padding: 56px 0; }
.sc-section__head { text-align: center; max-width: 600px; margin: 0 auto 48px; }
.sc-section__tag { font-size: 13px; font-weight: 500; color: var(--primary); margin-bottom: 12px; display: block; }
.sc-section__title { font-size: clamp(26px, 3.5vw, 36px); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 14px; }
.sc-section__desc { font-size: 16px; color: var(--text-secondary); line-height: 1.7; }

.gallery {
  display: flex;
  gap: 40px 28px;
  flex-wrap: wrap;
  justify-content: center;
}
@media (max-width: 640px) {
  .gallery {
    gap: 36px 16px;
  }
  .device {
    width: min(calc(100vw - 48px), 280px);
    height: 578px;
  }
  .gallery__caption-desc { max-width: min(280px, calc(100vw - 48px)); }
}
.gallery__item { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.gallery__caption { text-align: center; }
.gallery__caption-title { font-size: 15px; font-weight: 600; }
.gallery__caption-desc { font-size: 13px; color: var(--text-muted); margin-top: 3px; max-width: 240px; }
.gallery__link-wrap { position: relative; }
.gallery__open {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: 44px;
}

.sc-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 880px) { .sc-features { grid-template-columns: 1fr; } }
.sc-feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.sc-feature__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  background: var(--primary-soft);
  color: var(--primary);
}
.sc-feature__icon--green { background: rgba(34,197,94,.12); color: var(--success); }
.sc-feature__icon--amber { background: rgba(245,158,11,.12); color: var(--warning); }
.sc-feature__title { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.sc-feature__desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

.sc-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 calc(32px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.sc-footer p {
  line-height: 1.7;
  padding: 0 8px;
}
.sc-footer a { color: var(--text-secondary); }
.sc-footer a:hover { color: var(--text-primary); }

/* utility */
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.fade-in { animation: fadeUp 0.4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
