/* Приложение Ани (вкладки, экраны меню, ИИ-чат, аккаунт). Палитра и кнопки — base.css. */
:root { --tabs-h: 68px; }
body { min-height: 100vh; }

#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 60px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; background: var(--glass);
  border-bottom: 1px solid var(--line);
}
.tg #topbar { padding-top: 8px; }
#brand img { width: 30px; height: 30px; border-radius: 9px; }
#brand b { font-size: 17px; }
#title { flex: 1; min-width: 0; margin: 0 0 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top-actions { display: flex; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(.95); }
#theme-toggle .moon { display: none; }
:root[data-theme="dark"] #theme-toggle .sun { display: none; }
:root[data-theme="dark"] #theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) #theme-toggle .moon { display: block; }
}
.chip-btn { border: 1px solid var(--line-2); background: var(--paper); color: var(--text); border-radius: 999px; padding: 7px 14px;
  font: 500 14px var(--f-body); white-space: nowrap; }
.chip-btn:active { transform: scale(.97); }

#view { max-width: 760px; margin: 0 auto; padding: 16px 14px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 14px; }
.hero-img { display: block; width: 100%; max-height: 270px; object-fit: cover; border-radius: var(--r); margin-bottom: 14px; border: 1px solid var(--line); background: var(--paper-2); }
.hero-img.zoom { max-height: none; object-fit: contain; background: #fff; cursor: zoom-in; }
.rich { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.55; }
.rich b, .rich strong { font-weight: 600; }
.rich pre, .rich code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.rich pre { white-space: pre; overflow-x: auto; background: var(--bg-2); padding: 12px; border-radius: 14px; margin: 8px 0; }
.rich code { background: var(--bg-2); padding: 1px 5px; border-radius: 6px; }
.rich pre code { background: none; padding: 0; }
.rich blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--teal-2); background: var(--bg-2); border-radius: 0 14px 14px 0; }
.rich .spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; }
.rich .spoiler.open { background: none; color: inherit; }
.error { color: var(--danger); }

/* кнопки разделов — сетка как меню бота */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1 1 0; min-width: 0; min-height: 52px; padding: 8px 14px; white-space: normal; line-height: 1.2; }
.btn--link { background: var(--paper); color: var(--text); border-color: var(--line); }
.btn--link::after { content: "↗"; color: var(--teal-2); font-size: 14px; }
.btn--link:hover { border-color: var(--line-2); }
.btn--section { background: var(--btn); color: var(--btn-text); }
.btn--back { background: transparent; color: var(--muted); border-color: var(--line-2); }

.input-row { display: flex; gap: 8px; margin-top: 14px; }
.input, textarea, select.input {
  flex: 1; min-width: 0; min-height: 50px; font: 16px var(--f-body); color: var(--text); background: var(--bg-2);
  border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 16px; outline: none; transition: border-color .2s;
}
.input:focus, textarea:focus { border-color: var(--teal-2); }
.input.upper { text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }

#tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 20;
  display: flex; gap: 2px; width: min(560px, calc(100% - 20px)); height: var(--tabs-h); padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 999px; box-shadow: var(--shadow);
}
#tabs button { flex: 1; border: 0; background: none; color: var(--muted); border-radius: 999px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font: 500 11px var(--f-body); transition: background .25s, color .25s; }
#tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
#tabs button.active { background: var(--btn); color: var(--btn-text); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 22px);
  z-index: 50; max-width: min(92vw, 520px); background: var(--btn); color: var(--btn-text); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); text-align: center; }
#viewer { position: fixed; inset: 0; z-index: 60; background: rgba(8, 14, 24, .94); overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
#viewer img { width: 100%; height: auto; max-width: 1100px; touch-action: pinch-zoom; }
#viewer .close { position: fixed; top: calc(env(safe-area-inset-top) + 12px); right: 12px; z-index: 61; }

.spinner { width: 30px; height: 30px; border: 3px solid var(--line-2); border-top-color: var(--teal-2); border-radius: 50%; animation: spin .8s linear infinite; margin: 48px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.screen-in { animation: screen-in .18s ease-out; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

/* главная */
.home-hero { position: relative; display: flex; align-items: center; gap: 16px; padding: 20px; margin-bottom: 14px; border-radius: var(--r);
  color: #fff; background: linear-gradient(135deg, #0A8C9C 0%, #006B7A 55%, #04363F 100%); overflow: hidden; }
.home-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(180,212,0,.35), transparent 70%); }
.home-hero img { width: 64px; height: 64px; border-radius: 16px; flex: none; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.home-hero h2 { font-size: 24px; }
.home-hero p { opacity: .85; font-size: 14px; margin-top: 2px; line-height: 1.45; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quick button { text-align: left; border: 1px solid var(--line); background: var(--paper); color: var(--text); border-radius: 20px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; min-height: 120px; transition: background .2s, border-color .2s; }
.quick button:hover { border-color: var(--line-2); }
.quick button:active { background: var(--paper-2); }
.quick .ios-tile { width: 42px; height: 42px; border-radius: 12px; }
.quick .ios-tile svg { width: 23px; height: 23px; }
.quick b { font-size: 16px; font-weight: 600; line-height: 1.25; }
.quick small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.list-rows { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.list-rows button { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; background: none; color: var(--text); text-align: left; font-size: 16px; }
.list-rows button + button { border-top: 1px solid var(--line); }
.list-rows button:active { background: var(--paper-2); }
.list-rows .ios-tile { width: 32px; height: 32px; border-radius: 9px; }
.list-rows .ios-tile svg { width: 19px; height: 19px; }
.list-rows span.grow { flex: 1; }
.list-rows .chev { color: var(--muted); }

/* вход и регистрация */
.auth { max-width: 440px; margin: 0 auto; padding-top: 12px; }
.auth__logo { width: 96px; height: 96px; border-radius: 28px; margin: 18px auto 16px; box-shadow: var(--shadow); }
.auth h2 { font-size: 32px; text-align: center; }
.auth .lead { text-align: center; color: var(--muted); margin: 10px 0 22px; }
.auth .btn { width: 100%; }
.auth__providers { display: flex; flex-direction: column; gap: 10px; }
.btn--tg { background: #2AABEE; color: #fff; }
.btn--apple { background: #000; color: #fff; }
:root[data-theme="dark"] .btn--apple { background: #fff; color: #000; }
.provider-ic { width: 20px; height: 20px; flex: none; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.auth__status { text-align: center; margin-top: 14px; color: var(--muted); font-size: 14px; min-height: 20px; }
.auth__small { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 4px; }

/* ИИ-чат */
.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 92px; }
.msg { max-width: 92%; padding: 12px 15px; border-radius: 22px; background: var(--paper); border: 1px solid var(--line); }
.msg.user { align-self: flex-end; background: var(--btn); color: var(--btn-text); border-color: transparent; border-bottom-right-radius: 8px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; border-bottom-left-radius: 8px; }
.msg .progress { color: var(--muted); display: flex; gap: 10px; align-items: center; }
.msg .progress::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--teal-2); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.msg .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.msg .actions .btn { min-height: 38px; padding: 0 14px; font-size: 14px; }
.msg details { margin-top: 12px; font-size: 14px; }
.msg summary { cursor: pointer; color: var(--link); font-weight: 500; }
.src { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); }
.src span { flex: 1; color: var(--muted); }
.composer { position: fixed; left: 50%; transform: translateX(-50%); width: min(760px, 100%); z-index: 15;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px); padding: 0 12px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; padding: 6px; border-radius: 28px; background: var(--glass);
  border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.composer textarea { resize: none; max-height: 140px; min-height: 46px; border: 0; background: transparent; border-radius: 22px; line-height: 1.35; }
.composer .btn { flex: none; width: 46px; min-height: 46px; padding: 0; background: var(--cta); color: var(--cta-text); }
.empty-chat { text-align: center; color: var(--muted); padding: 18px 8px; }
.empty-chat .ic { font-size: 40px; }
.examples { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.examples .btn { justify-content: flex-start; text-align: left; white-space: normal; min-height: 48px; }

/* аккаунт */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 6px 8px; font-weight: 600; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(160deg, var(--teal-2), var(--teal)); color: #fff; display: grid; place-items: center;
  font: 700 22px var(--f-body); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--bg-2); font-size: 14px; font-weight: 700; letter-spacing: .06em; }
.chip a { color: var(--text); text-decoration: none; }
.chip button { border: 0; background: none; color: var(--muted); padding: 0 2px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--success); }
.doc-link { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.doc-link:first-child { border-top: 0; padding-top: 0; }
.doc-link::after { content: "↗"; margin-left: auto; color: var(--teal-2); }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; min-height: 42px; font-size: 14px; gap: 6px; }

@media (min-width: 760px) {
  #view { padding-top: 24px; }
  .quick { grid-template-columns: repeat(4, 1fr); }
}
