/* Agni Mini App — светлая тема в стиле Mira */
:root {
  --bg: #eef0f4;
  --card: #ffffff;
  --text: #14151a;
  --hint: #8b8f98;
  --accent: #2f81f7;
  --accent-soft: #e9f2ff;
  --pro1: #7c5cff; --pro2: #b45cff;
  --new: #2f9cf7;
  --line: rgba(0,0,0,.06);
  --shadow: 0 6px 20px rgba(20,30,60,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

/* header */
#topbar { display: flex; align-items: center; padding: 12px 16px; flex: 0 0 auto; }
.logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; margin-right: 9px; box-shadow: var(--shadow); }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.3px; }
.verified { color: var(--accent); font-size: 15px; }
.icon-btn { background: none; border: none; color: var(--hint); font-size: 20px; padding: 4px 8px; cursor: pointer; border-radius: 8px; margin-left: auto; }

/* view */
#view { flex: 1 1 auto; overflow-y: auto; padding: 4px 14px 96px; }
.section-title { font-weight: 800; font-size: 20px; margin: 18px 4px 10px; letter-spacing: -.3px; }
.card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 12px; }

/* list rows inside a card */
.lrow { display: flex; align-items: center; gap: 13px; padding: 14px 16px; cursor: pointer; }
.lrow + .lrow { border-top: 1px solid var(--line); }
.lrow .emo { font-size: 22px; width: 26px; text-align: center; flex: 0 0 auto; }
.lrow .grow { flex: 1; min-width: 0; }
.lrow .ttl { font-weight: 600; }
.lrow .sub { color: var(--hint); font-size: 13px; margin-top: 1px; }
.lrow .chev { color: #c3c7cf; font-size: 18px; }
.lrow .rval { color: var(--hint); font-size: 14px; margin-right: 4px; }

.badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 8px; margin-left: 7px; vertical-align: middle; color: #fff; }
.badge.pro { background: linear-gradient(90deg,var(--pro1),var(--pro2)); }
.badge.new { background: var(--new); }
.badge.soon { background: #b9bec7; }

/* hero (discover) */
.hero { border-radius: 22px; padding: 22px 18px 18px; background: linear-gradient(160deg,#3a7bff,#7b5cff 70%,#b45cff); color: #fff; box-shadow: var(--shadow); position: relative; }
.hero .buy-pro { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.22); color: #fff; border: none; padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.hero .hpic { display: block; width: 84px; height: 84px; border-radius: 20px; object-fit: cover; margin: 22px auto 0; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.hero .htxt { font-size: 24px; font-weight: 800; text-align: center; margin: 14px 0 14px; letter-spacing: -.4px; }
.hero .hinput { display: flex; gap: 8px; background: rgba(255,255,255,.95); border-radius: 16px; padding: 6px 6px 6px 14px; }
.hero .hinput input { flex: 1; border: none; background: none; outline: none; font: inherit; color: #14151a; }
.hero .hinput button { border: none; border-radius: 12px; width: 38px; background: var(--accent); color: #fff; font-size: 16px; }

/* token card (create) */
.token-card { display: flex; align-items: center; padding: 16px; }
.token-card .tk { flex: 1; }
.token-card .tk .lbl { color: var(--hint); font-size: 13px; }
.token-card .tk .val { font-size: 22px; font-weight: 800; margin-top: 2px; }
.btn { border: none; border-radius: 14px; padding: 10px 16px; font: inherit; font-weight: 700; background: var(--accent); color: #fff; cursor: pointer; }
.btn.pro { background: linear-gradient(90deg,var(--pro1),var(--pro2)); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.block { width: 100%; padding: 14px; }

/* big action tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.tile { background: var(--card); border-radius: 18px; padding: 18px 16px; box-shadow: var(--shadow); cursor: pointer; }
.tile .te { font-size: 26px; }
.tile .tt { font-weight: 700; margin-top: 8px; }
.tile .ts { color: var(--hint); font-size: 12px; margin-top: 2px; }

/* templates / gallery grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.gcell { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 1/1; background: #dfe3ea; cursor: pointer; }
.gcell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gcell .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; color: #fff; font-weight: 700; font-size: 13px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }

/* profile forms */
.field { padding: 8px 0; }
.field label { color: var(--hint); font-size: 13px; }
.field input, .field textarea { width: 100%; margin-top: 4px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: #f6f7f9; color: var(--text); font: inherit; outline: none; }

/* bottom nav */
#tabbar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 4px; background: #fff; border-radius: 999px; box-shadow: 0 8px 28px rgba(20,30,60,.16); padding: 7px 8px; z-index: 15; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; border: none; background: none; padding: 7px 20px; border-radius: 999px; color: var(--hint); cursor: pointer; }
.tab .ti { font-size: 19px; filter: grayscale(1) opacity(.7); }
.tab .tl { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.tab.active .ti { filter: none; }

/* chat overlay */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 25; display: flex; flex-direction: column; }
.overlay.hidden { display: none; }
.ov-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.ov-head .icon-btn { margin: 0; font-size: 26px; color: var(--accent); }
.ov-head b { font-size: 17px; }
.ov-head .pill { margin-left: auto; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
#chat { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 84%; padding: 9px 13px; border-radius: 17px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: #fff; box-shadow: var(--shadow); border-bottom-left-radius: 5px; }
.msg.sys { align-self: center; background: transparent; color: var(--hint); font-size: 13px; text-align: center; }
.msg.typing { color: var(--hint); font-style: italic; }
.msg.img { padding: 4px; background: #fff; }
.msg.img img { max-width: 100%; border-radius: 13px; display: block; }
#composer { display: flex; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
#input { flex: 1; resize: none; max-height: 120px; padding: 11px 14px; border-radius: 20px; border: none; background: #f2f3f6; color: var(--text); font: inherit; outline: none; }
#send { width: 44px; border: none; border-radius: 50%; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; }
#send:disabled { opacity: .5; }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 30; }
.sheet.hidden { display: none; }
.sheet-inner { width: 100%; background: var(--bg); border-radius: 20px 20px 0 0; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.sheet-head { display: flex; align-items: center; margin-bottom: 8px; }
.sheet-head b { font-size: 17px; }
.sheet-head .icon-btn { margin-left: auto; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(20,22,30,.92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px; z-index: 40; }
.toast.hidden { display: none; }
.seg { display: inline-flex; gap: 4px; }
.seg button { padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; }
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
