:root {
  --ink: #111827; --muted: #6b7280; --line: #e5e7eb; --bg: #f3f4f6; --card: #ffffff;
  --accent: #0f766e; --accent-soft: #d1fae5; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
button { font: inherit; }
input, select, textarea { font: inherit; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

#app { max-width: 560px; margin: 0 auto; padding: 10px 12px 90px; }

/* ---- верхняя строка контекста ---- */
.topbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 12px;
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; cursor: pointer; }
.chip .lbl { color: var(--muted); font-size: 12px; }
.chip .val { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.chip.empty .val { color: var(--warn); }
.status { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.status.offline .dot { background: #f59e0b; }
.who { font-size: 13px; color: var(--muted); margin: 0 0 8px 4px; display: flex; justify-content: space-between; }
.who .ver { font-size: 11px; }

/* ---- карточка текущей активности ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.running { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card h2 { margin: 0; font-size: 19px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card h2 .timer { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 17px; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.field { margin: 10px 0 0; }
.field .lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field .lbl .req { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; text-align: left; line-height: 1.15; }
.chips button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chips button small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 22px; }
.qty input { width: 80px; height: 44px; text-align: center; border: 1px solid var(--line); border-radius: 10px; font-size: 18px; }
.txt { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; min-height: 44px; }
.finish { width: 100%; margin-top: 14px; padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; }
.finish.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }

/* ---- плитки ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 16px 12px; min-height: 66px;
  font-size: 16px; font-weight: 600; text-align: left; line-height: 1.2; }
.tile:active { background: var(--accent-soft); }
.tile.custom { color: var(--accent); background: transparent; border-style: dashed; }
.tile.pending { color: var(--warn); }
.tile.pending small { display: block; font-size: 11px; font-weight: 400; }

/* ---- список дня ---- */
h3 { font-size: 14px; color: var(--muted); margin: 14px 4px 6px; font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; }
.item .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; min-width: 92px; }
.item .name { font-weight: 600; flex: 1; }
.item .meta { color: var(--muted); font-size: 12px; }
.item .dur { color: var(--muted); font-size: 13px; white-space: nowrap; }
.item.unc { border-color: var(--bad); background: var(--bad-soft); }
.item.bf { border-style: dashed; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 4px; }
.gap { text-align: center; color: var(--muted); font-size: 12px; }

/* ---- нижняя панель ---- */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; justify-content: center; }
.bottom button { flex: 1; max-width: 270px; padding: 12px; border: 1px solid var(--line); background: #fff; border-radius: 12px; color: var(--ink); }

/* ---- нижний лист ---- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 20; }
.sheet { background: var(--card); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto; }
.sheet h4 { margin: 0 0 10px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.sheet h4 button { border: 0; background: transparent; color: var(--muted); font-size: 22px; padding: 0 4px; }
.sheet .opt { display: block; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 6px; }
.sheet .opt.on { border-color: var(--accent); background: var(--accent-soft); }
.sheet .opt.add { color: var(--accent); border-style: dashed; }
.sheet .search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.sheet .grp { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.sheet .row { display: flex; gap: 8px; }
.sheet .row button { flex: 1; padding: 12px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sheet .row button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; margin-top: 0; }
.sheet .primary { width: 100%; margin-top: 10px; padding: 13px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.sheet .danger { background: var(--bad); }
.sheet .muted { color: var(--muted); font-size: 13px; }
.sheet input[type=time], .sheet input[type=datetime-local], .sheet input[type=date], .sheet select { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.confirm p { margin: 6px 0 14px; }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 14px;
  border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; }
#toast.show { opacity: 1; }
