
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 400 17px/22px var(--font-ui);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
svg { display: block; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.solid { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 20px; border-radius: var(--r-btn); background: var(--accent); color: var(--on-color); font-weight: 600; }
.solid[disabled] { opacity: .4; }
.ghost-btn { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 20px; border-radius: var(--r-btn); background: var(--surface-2); color: var(--text); font-weight: 500; }

/* ---------- каркас ---------- */
.stage { height: 100%; display: flex; align-items: center; justify-content: center; gap: 48px; }
.phone {
  position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; overflow: clip;
  background: var(--bg); --dock-h: 76px;
}
@media (min-width: 900px) {
  .stage { padding: 24px; }
  .phone {
    position: relative; inset: auto; flex: none; width: 400px; height: min(820px, 100%);
    border-radius: 44px; border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  }
}

/* ---------- шапка ---------- */
.top { flex: none; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; column-gap: 2px; height: calc(48px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 8px 0; }
.top-left { justify-self: start; }
.top-right { justify-self: end; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; color: var(--muted); }
.icon-btn:active { background: var(--surface-2); }
.tabs { justify-self: center; display: flex; gap: 0; }
.tab { position: relative; min-width: 44px; min-height: 44px; padding: 0 8px; font-size: 16px; line-height: 20px; font-weight: 500; color: var(--muted); }
.tab span { display: grid; }
.tab span::after { content: attr(data-t); grid-area: 1 / 1; font-weight: 700; visibility: hidden; height: 0; }
.tab[aria-selected="true"] { color: var(--text); font-weight: 700; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }

/* ---------- страницы ---------- */
.pages { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.pages::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; min-width: 0; height: 100%; overflow-x: hidden; overflow-y: auto; scroll-snap-align: start; scroll-snap-stop: always; overscroll-behavior-y: contain; scrollbar-width: none; }
.page::-webkit-scrollbar { display: none; }

/* ---------- поле ввода внизу: микрофон, текст, скрепка ---------- */
.dock { position: relative; flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); }
.pill { width: 100%; height: 56px; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px color-mix(in srgb, var(--shade) var(--shade-s), transparent); }
.pill-ic { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.pill-mic { background: var(--accent); color: var(--on-color); }
.pill-mic .ico { width: 22px; height: 22px; }
.pill-clip { color: var(--muted); }
.pill-clip:active { background: var(--surface-2); }
.pill-text { flex: 1; min-width: 0; height: 48px; padding: 0 4px 0 10px; border-radius: 24px; text-align: left; font-size: 17px; line-height: 22px; color: var(--muted); }

/* ---------- затемнение и листы ---------- */
.scrim { position: absolute; inset: 0; z-index: 20; background: color-mix(in srgb, var(--shade) var(--scrim), transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }
.scrim.on { opacity: 1; visibility: visible; transition-delay: 0s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 100%; overflow-y: auto;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-pop);
  transform: translateY(104%); visibility: hidden; transition: transform .4s var(--ease-out), visibility 0s .4s;
}
.sheet.on { transform: none; visibility: visible; transition-delay: 0s; }
.sheet.top-sheet { z-index: 50; }
#picker { z-index: 52; }
#choice, #duePick, #editor, #timePick, #numPick { z-index: 54; }
#addSheet { z-index: 56; }
.scrim2 { z-index: 45; }
.phone.picker-open #viewer { opacity: .5; }
.sheet.above { bottom: var(--dock-h); left: 8px; right: 8px; padding-bottom: 16px; border-radius: var(--r-sheet); }
.grabber { width: 36px; height: 4px; margin: 0 auto 12px; border-radius: 2px; background: var(--line); }
.sheet-title { font-size: 20px; line-height: 26px; font-weight: 600; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 14px; background: var(--surface-2); }
.seg button { min-height: 44px; padding: 0 8px; border-radius: 11px; font-size: 15px; line-height: 20px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px color-mix(in srgb, var(--shade) var(--shade-s), transparent); }

/* ---------- всплывающая подпись (квитанция, «Вернуть») ---------- */
.toast {
  position: absolute; left: 16px; right: 16px; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 2px 4px 2px 16px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  font-size: 15px; line-height: 20px; font-weight: 500;
  opacity: 0; transform: translateY(-16px) scale(.97); visibility: hidden; transition: opacity .25s, transform .4s var(--ease-out), visibility 0s .4s;
}
.toast.on { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.toast-act { min-height: 44px; padding: 0 14px; border-radius: 14px; color: var(--accent); font-weight: 600; }
.toast-act:active { background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.on, .note-screen, .note-screen.on { transform: none; transition: opacity .2s, visibility 0s; opacity: 0; }
  .sheet.on, .note-screen.on { opacity: 1; }
  .phone.picker-open #viewer { opacity: .5; }
  .toast, .toast.on { transform: none; }
}
