/* Внешний вид в стиле iOS. Цвета — системная палитра Apple,
   светлая/тёмная тема переключается сама вместе с настройкой телефона. */

:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f7f7fa;
  --label: #000000;
  --secondary: rgba(60, 60, 67, 0.62);
  --tertiary: rgba(60, 60, 67, 0.32);
  --separator: rgba(60, 60, 67, 0.2);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --pressed: rgba(0, 0, 0, 0.06);
  --bar: rgba(249, 249, 249, 0.8);
  --toast: rgba(255, 255, 255, 0.86);
  --shade: rgba(0, 0, 0, 0.1);
  --switch-off: #e9e9ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);

  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --purple: #af52de;
  --teal: #30b0c7;
  --indigo: #5856d6;
  --pink: #ff2d55;
  --gray: #8e8e93;
  --accent: var(--blue);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 44px;
  --tabbar-h: calc(50px + var(--safe-bottom));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #242426;
    --label: #ffffff;
    --secondary: rgba(235, 235, 245, 0.62);
    --tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --pressed: rgba(255, 255, 255, 0.08);
    --bar: rgba(22, 22, 23, 0.8);
    --toast: rgba(44, 44, 46, 0.9);
    --shade: rgba(0, 0, 0, 0.45);
    --switch-off: #39393d;
    --shadow: none;

    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --purple: #bf5af2;
    --teal: #40c8e0;
    --indigo: #5e5ce6;
    --pink: #ff375f;
  }
}

/* ---------- Основа ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--label);
  font: 17px/1.3 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-user-select: none; user-select: none; }
a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); font-size: 0.86em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.i { display: inline-flex; flex: none; }
.icon { display: block; }
.tabnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--secondary); }

#app { position: fixed; inset: 0; }
.stack { position: absolute; inset: 0; overflow: hidden; }

/* ---------- Экран, панель заголовка ---------- */

.screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  will-change: transform;
}
.screen.moving { box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12); }
.shade { position: absolute; inset: 0; background: var(--shade); opacity: 0; pointer-events: none; z-index: 20; }

.nav {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  height: calc(var(--nav-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  border-bottom: 0.5px solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
}
.nav.scrolled, .nav.no-large {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--separator);
}
.screen.bare .nav { display: none; }
.nav-title {
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0 4px;
}
.nav.scrolled .nav-title, .nav.no-large .nav-title { opacity: 1; }
.nav-left { display: flex; min-width: 0; }
.nav-right { display: flex; justify-content: flex-end; gap: 2px; }
.nav-back {
  display: flex;
  align-items: center;
  color: var(--accent);
  height: 44px;
  margin-left: -4px;
  min-width: 0;
}
.nav-back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.nav-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  border-radius: 22px;
}
.nav-btn.spinning .icon { animation: spin 0.8s linear infinite; }

.scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(var(--nav-h) + var(--safe-top));
  padding-bottom: calc(var(--tabbar-h) + 28px);
}
body.no-tabbar .scroll { padding-bottom: calc(var(--safe-bottom) + 28px); }
.screen.bare .scroll { padding-top: calc(var(--safe-top) + 24px); }

.page { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.page.wide { max-width: 1200px; }
.large-title {
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 2px 0 14px;
}

/* ---------- Нижняя панель вкладок ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: var(--tabbar-h);
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
body.no-tabbar .tabbar { display: none; }
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--gray);
  transition: color 0.2s;
}
.tab.active { color: var(--accent); }
.tab-icon { position: relative; }
.tab-label { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
.tab-badge {
  position: absolute;
  top: -1px; right: -5px;
  min-width: 10px; height: 10px;
  border-radius: 5px;
  background: var(--blue);
  border: 1.5px solid var(--bar);
  font-size: 10px; line-height: 7px; color: #fff; text-align: center;
  animation: breathe 1.6s ease-in-out infinite;
}

/* ---------- Карточки и группы ---------- */

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.cards { display: flex; flex-direction: column; gap: 10px; }

.group { margin: 26px 0; }
.group:first-child { margin-top: 8px; }
.group-title {
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--secondary);
  margin: 0 16px 7px;
}
.group-title.with-action { display: flex; align-items: center; justify-content: space-between; text-transform: none; margin-bottom: 2px; }
.group-title.with-action h2 { font: inherit; text-transform: uppercase; margin: 0; }
.group-body { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.group-footer { font-size: 13px; color: var(--secondary); margin: 7px 16px 0; line-height: 1.35; }

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  text-align: left;
  color: var(--label);
  background: var(--card);
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  left: 16px;
  border-top: 0.5px solid var(--separator);
}
.row:has(> .tile) + .row::before, .row + .row:has(> .tile)::before { left: 57px; }
.row.tappable { transition: background-color 0.15s; }
.row.tappable:active { background: var(--pressed); }
.row.danger .row-title { color: var(--red); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--secondary); line-height: 1.3; }
.row-value { color: var(--secondary); text-align: right; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--tertiary); margin-right: -4px; }
.row .nav-btn { margin: -10px -6px; }
.row.field.column { flex-direction: column; align-items: stretch; gap: 6px; }
.row.field input[type="text"] {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 16px;
}
.row.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

/* Цветные квадратики-иконки, как в «Настройках» iPhone */
.tile {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff;
  background: var(--gray);
}
.tile.small { width: 29px; height: 29px; border-radius: 7px; }
.tile.large { width: 58px; height: 58px; border-radius: 14px; }
.tile.blue { background: var(--blue); }
.tile.green { background: var(--green); }
.tile.red { background: var(--red); }
.tile.orange { background: var(--orange); }
.tile.purple { background: var(--purple); }
.tile.teal { background: var(--teal); }
.tile.indigo { background: var(--indigo); }
.tile.pink { background: var(--pink); }
.tile.gray { background: var(--gray); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity 0.2s, background-color 0.2s;
}
.btn.big { height: 54px; border-radius: 14px; font-size: 18px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 15px; border-radius: 16px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary-soft { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.btn.red { background: var(--red); color: #fff; }
.btn.red-soft { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); }
.btn.plain { background: var(--card); color: var(--accent); }
.btn.plain-soft { background: var(--fill); color: var(--label); }
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent);
  font-size: 15px;
  padding: 6px 0;
}
.link-btn.center { display: flex; margin: 18px auto 0; }

.sticky-action {
  position: sticky;
  bottom: calc(var(--tabbar-h) + 12px);
  z-index: 3;
  margin: 18px 0;
}
.sticky-action .btn { box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 30%, transparent); }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  animation: spin 0.75s linear infinite;
  flex: none;
}

/* ---------- Переключатель и степпер ---------- */

.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0;
  border-radius: 16px;
  background: var(--switch-off);
  transition: background-color 0.25s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:disabled + .switch-track { opacity: 0.5; }

.stepper {
  flex: none;
  display: inline-flex;
  align-items: center;
  background: var(--fill);
  border-radius: 9px;
  height: 34px;
}
.stepper button { width: 40px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--label); }
.stepper input {
  width: 46px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
  border-left: 0.5px solid var(--separator);
  border-right: 0.5px solid var(--separator);
  height: 20px;
  padding: 0;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; }

.command {
  display: block;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label);
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- Главный экран ---------- */

.script-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 14px 14px 16px;
  text-align: left;
  color: var(--label);
}
.script-card > .i:last-child, .live-card > .i:last-child { color: var(--tertiary); }
.script-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.script-title { font-weight: 600; }
.script-sub {
  font-size: 15px;
  color: var(--secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.script-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--secondary); margin-top: 3px; }
.script-meta code { background: var(--fill); padding: 1px 6px; border-radius: 5px; color: var(--secondary); }

.active-runs { display: flex; flex-direction: column; gap: 10px; }
.active-runs:not(:empty) { margin-bottom: 10px; }
.live-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  color: var(--label);
  background: color-mix(in srgb, var(--blue) 12%, var(--card));
}
.live-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.live-title { font-weight: 600; }
.live-sub { font-size: 14px; color: var(--blue); }

.pulse { position: relative; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); margin: 0 4px; }
.pulse::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--blue);
  animation: ring 1.6s ease-out infinite;
}
.pulse.small { width: 8px; height: 8px; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gray); margin-left: 4px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.blue { background: var(--blue); }

.footnote { font-size: 13px; color: var(--secondary); margin: 16px 16px; line-height: 1.4; }
.footnote.center { text-align: center; }

.skeleton { height: 88px; background: linear-gradient(90deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton.tall { height: 320px; }

.empty { text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; }
.empty-icon { width: 72px; height: 72px; border-radius: 36px; background: var(--fill); color: var(--secondary); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.empty h3 { font-size: 20px; margin: 0 0 6px; }
.empty p { color: var(--secondary); font-size: 15px; margin: 0 0 18px; max-width: 320px; }

.error-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  color: var(--label);
}
.error-card > .i { color: var(--red); }
.error-card div { flex: 1; min-width: 0; }
.error-card p { margin: 2px 0 0; font-size: 14px; color: var(--secondary); }

.demo-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 8px;
  background: color-mix(in srgb, var(--purple) 12%, var(--card));
  color: var(--purple);
  font-size: 15px; font-weight: 500;
}

/* ---------- Экран скрипта ---------- */

.about { padding: 16px; }
.about-head { display: flex; gap: 14px; align-items: flex-start; }
.about-summary { margin: 0 0 8px; font-size: 16px; line-height: 1.35; }
.chip { display: inline-block; background: var(--fill); color: var(--secondary); padding: 2px 7px; border-radius: 6px; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.about .link-btn { margin-top: 8px; }
.details {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--secondary);
  font: 12.5px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Экран запуска ---------- */

.status-card { padding: 16px; }
.status-card[data-tone="green"] { --tone: var(--green); }
.status-card[data-tone="red"] { --tone: var(--red); }
.status-card[data-tone="gray"] { --tone: var(--gray); }
.status-card[data-tone="blue"] { --tone: var(--blue); }
.status-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.status-slot { min-height: 22px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.status.small { font-size: 13px; }
.status.blue { color: var(--blue); }
.status.green { color: var(--green); }
.status.red { color: var(--red); }
.status.gray { color: var(--gray); }
.st-queued .icon, .st-starting .icon { animation: spin 1.2s linear infinite; }
.st-running .icon { animation: breathe 1.4s ease-in-out infinite; }

.status-time { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 10px 0 12px; flex-wrap: wrap; }
.big-clock { font-size: 54px; line-height: 1; font-weight: 300; letter-spacing: -0.02em; }
.eta { font-size: 15px; color: var(--secondary); }

.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; position: relative; }
.progress-fill { height: 100%; width: 0; border-radius: 3px; background: var(--tone, var(--blue)); transition: width 0.9s ease, background-color 0.3s; }
.progress[data-mode="indeterminate"] .progress-fill { width: 35%; animation: slide 1.4s ease-in-out infinite; }

.summary {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  background: color-mix(in srgb, var(--tone, var(--blue)) 12%, transparent);
}

.run-actions { display: flex; gap: 10px; margin: 14px 0 4px; }
.run-actions .btn { flex: 1; }
.run-actions a.btn { flex: 0 0 auto; }

.log-wrap { position: relative; }
.log-box {
  background: var(--card);
  border-radius: 12px;
  height: 260px; /* точную высоту подбирает screens.js → fitLog() */
  overflow: auto;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.log-box.plain { height: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; margin: 0; }
.log {
  margin: 0;
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--label);
}
.log-wait { display: inline-flex; align-items: center; gap: 8px; color: var(--secondary); font-family: var(--font); font-size: 15px; }
.to-bottom {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 36px; height: 36px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--secondary); background: var(--fill); padding: 2px 8px; border-radius: 10px; }
code.args { margin-left: 6px; font-size: 13px; color: var(--secondary); }

/* ---------- Таблица ---------- */

.searchbar {
  display: flex; align-items: center; gap: 6px;
  height: 38px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--fill);
  color: var(--secondary);
}
.searchbar input { flex: 1; min-width: 0; border: 0; background: none; font-size: 17px; color: var(--label); outline: none; }
.searchbar input::-webkit-search-cancel-button { opacity: 0.5; }

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented button {
  flex: 1 0 auto;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s;
}
.segmented button.active { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04); }

.table-count { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; font-size: 13px; color: var(--secondary); margin: 4px 4px 4px; }
.link-btn.small { font-size: 13px; font-weight: 600; padding: 6px 0; }
.table-scroll {
  overflow: auto;
  max-height: calc(100dvh - var(--nav-h) - var(--safe-top) - var(--tabbar-h) - 190px);
  min-height: 240px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
table.data { border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 100%; }
table.data th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-2);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  padding: 10px 12px;
  min-width: 64px;
  max-width: 150px;
  line-height: 1.2;
  vertical-align: bottom;
  cursor: pointer;
  border-bottom: 0.5px solid var(--separator);
  -webkit-user-select: none; user-select: none;
}
table.data th.sorted { color: var(--accent); }
table.data td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--separator);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--card);
}
table.data th:first-child, table.data td:first-child { position: sticky; left: 0; z-index: 1; }
table.data th:first-child { z-index: 3; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:active td { background: var(--card-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-link { color: var(--accent); }
/* Магазин отмечен «уже написал»: строка приглушена, в первой ячейке зелёная полоска */
table.data tr.marked td { color: var(--secondary); }
table.data tr.marked td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.sentinel { height: 1px; }

/* ---------- Шторка снизу ---------- */

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 100; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 101;
  max-width: 680px;
  margin: 0 auto;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding-bottom: calc(var(--safe-bottom) + 12px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary); margin: 7px auto 4px; flex: none; }
.sheet-title { font-weight: 600; text-align: center; padding: 6px 20px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.sheet-body { overflow-y: auto; padding: 0 16px 8px; -webkit-overflow-scrolling: touch; }

/* Быстрые действия в карточке строки: как кнопки под контактом в iOS */
.row-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin-bottom: 12px; }
.row-action {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px 9px;
  border-radius: 12px;
  background: var(--card);
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  text-decoration: none;
}
.row-action:active { background: var(--card-2); }
.row-action-icon { display: flex; }
.mark-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}
.mark-text { display: flex; flex-direction: column; gap: 2px; }
.mark-hint { font-size: 13px; color: var(--secondary); }
.kv-list { display: flex; flex-direction: column; gap: 1px; border-radius: 12px; overflow: hidden; background: var(--separator); }
.kv { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 11px 16px; text-align: left; background: var(--card); color: var(--label); }
.kv:active { background: var(--card-2); }
.kv-key { font-size: 13px; color: var(--secondary); }
.kv-value { font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.kv-value.link { color: var(--accent); }
.kv-list + .footnote, .kv-list .footnote { background: var(--bg); margin: 0; padding: 12px 4px 0; }

.confirm { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.confirm-text { text-align: center; color: var(--secondary); font-size: 15px; margin: 0 8px 8px; }

/* ---------- Всплывающее сообщение ---------- */

.toast {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 0; right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 200;
  padding: 11px 18px;
  border-radius: 22px;
  background: var(--toast);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16);
  font-size: 15px;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.green::before { background: var(--green); }
.toast.red::before { background: var(--red); }
.toast.gray::before { background: var(--gray); }

/* ---------- Подключение ---------- */

.connect { padding-bottom: 20px; }
.hero { text-align: center; padding: 20px 8px 24px; }
.hero-icon { border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.hero h1 { font-size: 32px; margin: 16px 0 8px; letter-spacing: 0.01em; }
.hero p { color: var(--secondary); margin: 0 auto; max-width: 360px; line-height: 1.4; }
.steps { list-style: none; margin: 0 0 18px; padding: 4px 16px; }
.step { display: flex; gap: 14px; padding: 16px 0; }
.step + .step { border-top: 0.5px solid var(--separator); }
.step > div { flex: 1; min-width: 0; }
.step p { font-size: 15px; color: var(--secondary); margin: 5px 0 12px; line-height: 1.4; }
.step p b { color: var(--label); font-weight: 600; }
.step-num {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.token-field {
  display: flex; align-items: center; gap: 8px;
  height: 46px;
  padding: 0 12px;
  margin-top: 10px;
  border-radius: 11px;
  background: var(--fill);
  color: var(--secondary);
}
.token-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 16px var(--mono); color: var(--label); }
.token-field + .muted { font-size: 13px; margin: 8px 0 0; }

/* ---------- Анимации ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ring { from { transform: scale(1); opacity: 0.6; } to { transform: scale(2.6); opacity: 0; } }
@keyframes breathe { 50% { opacity: 0.45; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

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

/* На широком экране (компьютер) — чуть больше воздуха */
@media (min-width: 760px) {
  .page { padding: 0 24px; }
  .large-title { margin-top: 12px; }
}
