/* «Медь»: токены, каркас мини-приложения, общие элементы управления. */
:root {
  color-scheme: light;
  --backdrop: #e6dccf;
  --paper: #f6f0e7;
  --surface: #fffcf7;
  --surface-2: #efe6da;
  --ink: #2a1f18;
  --ink-2: #5b4b3f;
  --muted: #6f5e51;
  --line: rgba(42, 31, 24, 0.1);
  --line-strong: rgba(42, 31, 24, 0.2);
  --accent: #9a4220;
  --accent-press: #7f3519;
  --accent-soft: #f3e2d4;
  --espresso: #2f221b;
  --ok: #3b6a4a;
  --ok-soft: #e2ece1;
  --warn: #84560f;
  --err: #a1352b;
  --tile-beans: #eadccb;
  --tile-drinks: #e4dfd5;
  --tile-pastry: #f1e2c8;
  --r-ctl: 12px;
  --r-card: 18px;
  --side: 16px;
  --app-w: 440px;
  --dock-h: 80px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 0.16s;
  --t-enter: 0.24s;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
}

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

html {
  background: var(--backdrop);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Фокус и прокрутка к полю не прячут его под липкой шапкой и нижней панелью. */
  scroll-padding: 76px 0 112px;
}

body {
  margin: 0;
  background: var(--backdrop);
  color: var(--ink);
  font: 400 15px/1.45 var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* Заголовок экрана получает фокус программно для читалок экрана; рамка вокруг текста только мешает. */
[data-screen-title]:focus,
[data-screen-title]:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- каркас ---------- */

.app {
  position: relative;
  max-width: var(--app-w);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  padding-bottom: 32px;
}
.app.has-dock { padding-bottom: calc(var(--dock-h) + 32px + env(safe-area-inset-bottom, 0px)); }

@media (min-width: 520px) {
  .app { box-shadow: 0 0 0 1px var(--line), 0 24px 64px rgba(42, 31, 24, 0.1); }
}

.screen { display: block; }
.screen.enter-fwd { animation: enter-fwd var(--t-enter) var(--ease); }
.screen.enter-back { animation: enter-back var(--t-enter) var(--ease); }
@keyframes enter-fwd { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

.pad { padding: 0 var(--side); }

/* ---------- шапка ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 8px 8px 8px var(--side);
  background: var(--paper);
  border-bottom: 1px solid transparent;
}
.top--inner { padding-left: 8px; border-bottom-color: var(--line); }
.top-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-actions { display: flex; gap: 4px; }

.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--accent); }
.mark { width: 36px; height: 36px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-size: 22px; color: var(--ink); letter-spacing: 0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-ctl);
  color: var(--ink);
  transition: background-color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.is-ghost { visibility: hidden; }

.badge {
  position: absolute;
  top: 2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
}
.badge.is-empty { display: none; }
.is-bump { animation: bump 0.32s var(--ease); }
@keyframes bump { 40% { transform: scale(1.28); } 100% { transform: scale(1); } }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-press); }
.btn--primary:disabled { background: #b98a74; }
.btn--primary.is-done { background: var(--ok); }
.btn--ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--light { background: #f6ecdf; color: var(--espresso); }
.btn--light:hover { background: #fff7ee; }
.btn--danger { background: var(--err); color: #fff; }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 14px; border-radius: var(--r-ctl); }
.btn-price { font-weight: 600; white-space: nowrap; }

.link-btn {
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
.link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- нижняя панель ---------- */

.dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: 100%;
  max-width: var(--app-w);
  transform: translateX(-50%);
  padding: 12px var(--side) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.dock:empty { display: none; }
.btn--dock { width: 100%; min-height: 56px; justify-content: space-between; padding: 0 20px; font-size: 16px; }
.btn--dock > span:first-of-type:not(.dock-count) { margin-right: auto; }
.dock-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  line-height: 28px;
  text-align: center;
}
.btn--dock .dock-count + span { margin-right: auto; }
.dock-pair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.dock-pair .btn--dock { justify-content: center; }

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 40;
  width: 100%;
  max-width: var(--app-w);
  padding: 0 var(--side);
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.has-dock ~ .toast,
.app.has-dock .toast { bottom: calc(var(--dock-h) + 12px + env(safe-area-inset-bottom, 0px)); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 8px 8px 16px;
  border-radius: 14px;
  background: var(--espresso);
  color: #f6ecdf;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(42, 31, 24, 0.2);
}
.toast-text { flex: 1; min-width: 0; }
.toast-act {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: #f3c6a6;
  font-weight: 600;
  white-space: nowrap;
}
.toast-act:hover { background: rgba(255, 255, 255, 0.08); }

.fly-ghost { position: fixed; z-index: 50; pointer-events: none; margin: 0; }

/* ---------- поля ---------- */

.field { display: grid; gap: 6px; margin-top: 16px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px;
  transition: border-color var(--t-fast) var(--ease);
}
.input::placeholder { color: #9a8879; }
.input:focus { border-color: var(--ink); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r-ctl); }
.has-error .input { border-color: var(--err); }
.field-err { min-height: 0; font-size: 13px; color: var(--err); }
.field-err:empty { display: none; }

.muted { color: var(--muted); }
.demo-note { margin-top: 20px; font-size: 13px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
