:root {
  --accent: #F0532E;
  --accent-2: #ff7a4d;
  --accent-soft: rgba(240, 83, 46, .12);
  --bg: #ffffff;
  --fg: #111114;
  --muted: #6e6e76;
  --card: #f2f2f5;
  --card-2: #e8e8ed;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9f0a;
  --radius: 18px;
  --page-bg: #e6e6ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #FF7455;
    --accent-2: #ff9270;
    --accent-soft: rgba(255, 116, 85, .16);
    --bg: #000000;
    --fg: #f5f5f7;
    --muted: #98989f;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --page-bg: #18181c;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior-y: none; background: var(--bg); }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.42 ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input { font-family: inherit; font-size: 16px; }
button { cursor: pointer; border: 0; background: none; color: inherit; }

/* Экраны */
#app {
  height: 100dvh; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  max-width: 560px; margin: 0 auto; width: 100%;
  position: relative;
}
/* На широких экранах приложение — колонка по центру с мягкими границами */
@media (min-width: 620px) {
  body { background: var(--page-bg); }
  #app {
    height: min(100dvh, 900px); margin: max(0px, calc((100dvh - 900px) / 2)) auto;
    border-radius: 26px; overflow: hidden;
    background: var(--bg);
    box-shadow: 0 20px 70px rgba(0,0,0,.28), 0 0 0 1px rgba(128,128,128,.2);
  }
  .overlay { max-width: 560px; left: 50%; transform: translateX(-50%); }
  @media (min-height: 940px) { .overlay { max-height: 900px; top: calc((100dvh - 900px) / 2); border-radius: 26px; } }
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 20px; }

.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--card);
}
.bar h2 { flex: 1; text-align: center; font-size: 17px; font-weight: 700; margin: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--card);
  font-size: 17px; display: grid; place-items: center; flex: none;
}

/* Онбординг */
.onboarding { height: 100dvh; overflow-y: auto; max-width: 560px; margin: 0 auto; padding: env(safe-area-inset-top) 20px calc(24px + env(safe-area-inset-bottom)); }
.ob-inner { max-width: 460px; margin: 0 auto; display: grid; gap: 14px; padding-top: 28px; }
.logo {
  font-size: 44px; font-weight: 900; text-align: center; margin: 0;
  background: linear-gradient(90deg, var(--accent), #ffa03a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { text-align: center; color: var(--muted); margin: 0 0 4px; }
.steps { list-style: none; padding: 16px; margin: 0; background: var(--card); border-radius: var(--radius); display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps span {
  width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); font-weight: 800; font-size: 14px; display: grid; place-items: center;
}
.steps p { margin: 2px 0 0; font-size: 15px; }
.fine { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.fine.center { text-align: center; }
.link, a { color: var(--accent); }

/* Кнопки */
.btn {
  display: block; width: 100%; padding: 15px; border-radius: var(--radius);
  font-weight: 700; text-align: center; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .45; }
.btn.ghost { background: var(--card); color: var(--accent); }
/* В карточках настроек фон кнопки совпадал с фоном карточки — кнопка не читалась */
.card .btn.ghost { background: var(--card-2); }
.card .btn.small { flex: 1; }
.btn.white { background: #fff; color: var(--accent); width: auto; padding: 15px 30px; border-radius: 40px; }
.btn.small { padding: 10px 14px; font-size: 15px; width: auto; }
.btn.danger { color: var(--red); }
.row { display: flex; gap: 10px; margin-top: 10px; }

input[type="password"], input[type="text"] {
  width: 100%; padding: 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--card); color: var(--fg);
}
input:focus { outline: none; border-color: var(--accent); }

/* Лента диалога */
.msg { max-width: 86%; padding: 12px 15px; border-radius: 22px; margin-bottom: 11px; }
.msg .src { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.msg .tr { font-size: 19px; font-weight: 650; }
.msg.mine { background: linear-gradient(135deg, var(--accent), var(--accent-2)); margin-left: auto; }
.msg.mine .src { color: rgba(255,255,255,.78); }
.msg.mine .tr { color: #fff; }
.msg.theirs { background: var(--card); }
.msg.pending { opacity: .55; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty h3 { color: var(--fg); font-size: 19px; margin: 0 0 8px; }
.empty p { margin: 0 0 14px; font-size: 15px; }
.chip { display: inline-block; padding: 8px 14px; border-radius: 30px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }

/* Баннер «говорите» */
.banner {
  display: none; margin: 10px 16px 0; padding: 14px; border-radius: 20px; text-align: center;
  background: linear-gradient(135deg, var(--green), #2aa14a); color: #fff;
  font-size: 26px; font-weight: 800; line-height: 1.15;
}
.banner small { display: block; font-size: 13px; font-weight: 600; opacity: .92; margin-top: 3px; }
.banner.on { display: block; }
.banner.rec { background: linear-gradient(135deg, var(--red), #d32b22); }

/* Статус */
.statusline {
  display: flex; align-items: center; gap: 8px; margin: 8px 16px 0;
  padding: 9px 13px; border-radius: 30px; background: var(--card); font-size: 13px;
}
.statusline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.statusline.live .dot { background: var(--green); }
.statusline.busy .dot { background: var(--orange); }
.statusline.err .dot { background: var(--red); }
.statusline span:nth-child(2) { flex: 1; }
.statusline button { color: var(--accent); font-weight: 600; font-size: 13px; }

/* Панель ввода */
.inputbar {
  display: flex; gap: 9px; align-items: center;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom) * 0.35);
  border-top: 1px solid var(--card); background: var(--bg);
}
.inputbar input { flex: 1; border-radius: 24px; padding: 12px 15px; }
.round {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff;
}
.round.live { background: var(--accent-soft); }
.round.live.on { background: linear-gradient(180deg, var(--green), #2aa14a); animation: pulse 1.6s ease-in-out infinite; }
.round.mic.rec { background: linear-gradient(180deg, var(--red), #e0352c); }
.round:disabled { opacity: .4; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* Таббар */
/* Плавающая капсула по центру — как таббар в iOS 26, а не растянутая полоса */
.tabbar {
  display: flex; justify-content: center; gap: 2px;
  background: var(--bg);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom) * 0.45);
}
.tab {
  flex: none; padding: 7px 20px 6px; border-radius: 18px;
  font-size: 11px; color: var(--muted);
  display: grid; gap: 2px; justify-items: center;
}
.tab [data-icon] { height: 23px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

/* Фото */
.pickers { display: flex; gap: 10px; margin-bottom: 14px; }
.pickers .btn { padding: 13px; }
.preview { width: 100%; border-radius: 20px; margin-bottom: 14px; display: block; }
.hint-tap { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--accent); letter-spacing: .04em; margin: 16px 0 8px 4px; }
.dish {
  background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 10px;
  border: 1.5px solid transparent;
}
.dish.on { background: var(--accent-soft); border-color: var(--accent); }
.dish-top { display: flex; align-items: baseline; gap: 8px; }
.dish-name { flex: 1; font-weight: 650; }
.dish-price { font-size: 14px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 30px; white-space: nowrap; }
.dish-orig { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dish-ing { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 3px; }
.counter { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 8px; }
.counter button { font-size: 26px; color: var(--accent); line-height: 1; }
.counter b { font-size: 19px; min-width: 24px; text-align: center; }
.block-card { background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.block-card .orig { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.summary-card { background: var(--accent-soft); border-radius: 16px; padding: 15px; margin-bottom: 14px; }
.summary-card h4 { margin: 0 0 6px; color: var(--accent); font-size: 14px; }
.photobar {
  padding: 10px 12px calc(4px + env(safe-area-inset-bottom) * 0.25); border-top: 1px solid var(--card); background: var(--bg);
  display: grid; gap: 9px;
}
.photobar .pickers { margin: 0; }
.photobar .btn { padding: 14px; }

.loading { text-align: center; padding: 36px 20px; color: var(--muted); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--card-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--red); text-align: center; padding: 20px; }

/* Карточки настроек */
.card { background: var(--card); border-radius: var(--radius); padding: 15px; margin-bottom: 12px; }
.card h4 { margin: 0 0 10px; font-size: 15px; }
.card summary { font-size: 15px; font-weight: 600; cursor: pointer; }
#log {
  margin-top: 10px; font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border-radius: 12px; padding: 10px;
  max-height: 260px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* Оверлеи */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.overlay.sheet { padding-top: env(safe-area-inset-top); }
#bigView {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  align-items: center; justify-content: center; padding: 24px;
}
.big-inner {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; width: 100%; overflow-y: auto;
  transition: transform .35s cubic-bezier(.22,.9,.3,1);
}
.big-inner.flipped { transform: rotate(180deg); }
.big-actions { padding: 10px 0 calc(14px + env(safe-area-inset-bottom) * 0.4); display: flex; justify-content: center; }
.flip {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 16px;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.22); color: #fff;
  display: grid; place-items: center;
}
.big-src { color: rgba(255,255,255,.72); font-size: 17px; font-weight: 600; margin: 0; }
.big-tr { color: #fff; font-size: 46px; font-weight: 800; line-height: 1.1; margin: 0; }
.close {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.22); color: #fff; font-size: 17px;
}
.segmented { display: flex; gap: 6px; padding: 10px 16px; }
.seg { flex: 1; padding: 9px; border-radius: 12px; background: var(--card); font-size: 14px; font-weight: 600; color: var(--muted); }
.seg.active { background: var(--accent); color: #fff; }
/* Список истории: карточки со свайпом влево */
.swipe-wrap { position: relative; margin-bottom: 10px; border-radius: 16px; }
.swipe-delete {
  position: absolute; inset: 0 0 0 auto; width: 96px;
  background: var(--red); color: #fff; border-radius: 0 16px 16px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 600;
}
.swipe-card {
  position: relative; display: flex; gap: 12px; align-items: center;
  padding: 13px 14px; background: var(--card); border-radius: 16px;
  will-change: transform;
}
.swipe-card .thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; background: var(--card-2); }
.swipe-card .info { flex: 1; min-width: 0; }
.swipe-card .info b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swipe-card .info small { color: var(--muted); font-size: 13px; }
.swipe-card .preview {
  display: block; margin-top: 4px; font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85;
}
.hint-swipe { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0 10px; }

/* Скелетон разбора фото */
.reading { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse-dot 1.1s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: .3; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
.skeleton-card { background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 10px; display: grid; gap: 9px; }
.sk { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--card-2) 25%, var(--card) 50%, var(--card-2) 75%); background-size: 240% 100%; animation: sk-shine 1.4s linear infinite; }
.sk-title { height: 15px; width: 62%; }
.sk-line { width: 100%; }
.sk-line.short { width: 45%; }
@keyframes sk-shine { to { background-position: -240% 0; } }
@media (prefers-reduced-motion: reduce) { .sk, .pulse-dot { animation: none; } }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 11px 18px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 90; max-width: 88%; text-align: center;
}

/* Иконки */
[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex: none; }
[data-icon] svg { display: block; }
.btn [data-icon] { margin-right: 8px; vertical-align: -3px; }
.btn { display: flex; align-items: center; justify-content: center; }
a.btn { text-decoration: none; }
.fine.link.inline { display: inline-flex; align-items: center; gap: 5px; }
.tab [data-icon] { height: 23px; }
.empty-icon { color: var(--accent); opacity: .55; display: flex; justify-content: center; }
.round [data-icon] { color: #fff; }
.round.live [data-icon] { color: var(--accent); }
.round.live.on [data-icon] { color: #fff; }
.round.live.on svg path { animation: wave-bounce 1.1s ease-in-out infinite; transform-origin: center; }
.round.live.on svg path:nth-child(1) { animation-delay: 0s; }
.round.live.on svg path:nth-child(2) { animation-delay: .12s; }
.round.live.on svg path:nth-child(3) { animation-delay: .24s; }
.round.live.on svg path:nth-child(4) { animation-delay: .36s; }
.round.live.on svg path:nth-child(5) { animation-delay: .48s; }
@keyframes wave-bounce { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.45); } }
.hist-item .del [data-icon] { color: var(--red); }
.dish-name [data-icon] { color: var(--accent); margin-right: 5px; vertical-align: -3px; }
.status-icon { display: inline-flex; vertical-align: -3px; margin-right: 5px; }
.status-icon.ok { color: var(--green); }
.status-icon.bad { color: var(--red); }
.counter button { display: inline-flex; align-items: center; }
.banner [data-icon] { color: #fff; margin-right: 8px; vertical-align: -4px; }

/* Появление реплик */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.msg { animation: msg-in .28s cubic-bezier(.22,.9,.3,1); }
@media (prefers-reduced-motion: reduce) { .msg { animation: none; } }

/* Отклик на нажатие — заметнее на телефоне, где нет курсора */
.btn:active, .round:active, .icon-btn:active, .dish:active, .tab:active { transform: scale(.97); }
.btn, .round, .icon-btn, .dish, .tab { transition: transform .12s ease; }

/* Индикатор отсутствия сети */
.offline-bar {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin: 8px 16px 0; padding: 9px 14px; border-radius: 14px;
  background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 600;
}

/* Разговорник */
.phrase {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 2px 12px; width: 100%; text-align: left;
  background: var(--card); border-radius: 16px; padding: 13px 15px; margin-bottom: 9px;
}
.ph-ru { font-weight: 650; font-size: 15px; }
.ph-vi { grid-column: 1; font-size: 15px; color: var(--accent); }
.ph-speak { grid-row: 1 / 3; grid-column: 2; color: var(--accent); opacity: .65; }

/* Переход между вкладками */
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.screen:not(.hidden) { animation: tab-in .2s ease; }
@media (prefers-reduced-motion: reduce) { .screen:not(.hidden) { animation: none; } }

/* «Перевожу» прямо в ленте — как печатает собеседник в мессенджере */
.typing {
  display: inline-flex; gap: 5px; align-items: center;
  background: var(--card); border-radius: 22px; padding: 15px 18px; margin-bottom: 11px;
}
.typing i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  animation: typing-bounce 1.1s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Быстрые фразы на пустом экране */
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.quick button {
  background: var(--card); border-radius: 30px; padding: 9px 14px;
  font-size: 14px; font-weight: 600; color: var(--fg);
}
.quick button:active { background: var(--accent-soft); color: var(--accent); }

/* Модальное подтверждение */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(0,0,0,.45); padding: 24px; backdrop-filter: blur(3px);
  animation: fade-in .16s ease;
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--bg); border-radius: 22px; padding: 22px; width: 100%; max-width: 340px;
  animation: modal-in .22s cubic-bezier(.22,.9,.3,1);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.94) } to { opacity: 1; transform: none } }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { padding: 13px; }
.btn.danger-btn { background: var(--red); }

/* Пошаговый мастер */
.ob-steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.ob-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--card-2); transition: all .2s; }
.ob-dot.on { background: var(--accent); width: 20px; border-radius: 4px; }
.ob-step { display: grid; gap: 14px; animation: tab-in .22s ease; }
.ob-title { font-size: 22px; font-weight: 800; text-align: center; margin: 4px 0 0; }
.illust-box { display: grid; gap: 12px; justify-items: center; }
.illust { width: 100%; max-width: 300px; height: auto; display: block; }
.illust-pointer { animation: point-nudge 1.6s ease-in-out infinite; }
@keyframes point-nudge { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-4px, -4px); } }
@media (prefers-reduced-motion: reduce) { .illust-pointer { animation: none; } }

.ob-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ob-list li { position: relative; padding-left: 20px; font-size: 15px; }
.ob-list li::before {
  content: '•'; position: absolute; left: 2px; top: -1px;
  color: var(--accent); font-weight: 800; font-size: 20px; line-height: 1.2;
}

.ob-numbered { padding-left: 0; margin: 0; display: grid; gap: 12px; counter-reset: step; list-style: none; }
.ob-numbered li {
  position: relative; padding-left: 38px; min-height: 26px;
  font-size: 15px; line-height: 1.45;
}
.ob-numbered li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 14px; display: grid; place-items: center;
}
.ob-numbered b { color: var(--accent); }

.ob-facts { display: grid; gap: 10px; }
.ob-facts > div { background: var(--card); border-radius: 14px; padding: 13px 15px; display: grid; }
.ob-facts b { font-size: 15px; }
.ob-facts span { font-size: 13px; color: var(--muted); }

.ob-nav { display: flex; gap: 10px; margin-top: 6px; }
.ob-nav .btn { flex: 1; }
