:root {
  --bg: #f6f2ec;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #7a706a;
  --line: #e6dfd6;
  --accent: #6e1a26;
  --accent-ink: #ffffff;
  --accent-soft: #f3e4e4;
  --gold: #b88a2e;
  --rehearsal: #2f5d8a;
  --rehearsal-soft: #e3ecf5;
  --performance: #6e1a26;
  --performance-soft: #f5e3e5;
  --other: #5b6b4a;
  --other-soft: #e9eee2;
  --ok: #2e7d4f;
  --warn: #b8741a;
  --bad: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 20, 10, .06), 0 4px 14px rgba(40, 20, 10, .05);
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161312;
    --card: #211c1a;
    --ink: #f1ebe5;
    --muted: #a69b93;
    --line: #342d29;
    --accent: #c8505f;
    --accent-soft: #3a2226;
    --gold: #d9ad55;
    --rehearsal: #7fb0e0;
    --rehearsal-soft: #1e2b38;
    --performance: #e07884;
    --performance-soft: #3a2226;
    --other: #a6bf8c;
    --other-soft: #252e1f;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--accent); }
.splash { display: grid; place-items: center; min-height: 80vh; color: var(--muted); }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 20px; margin: 0; flex: 1; font-weight: 700; letter-spacing: -.01em; }
.top .back { font-size: 22px; text-decoration: none; color: var(--ink); padding: 2px 8px 2px 0; }
.top .act { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 15px; padding: 6px 4px; }

main { padding: 12px 16px 24px; max-width: 720px; margin: 0 auto; }

/* нижние вкладки */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex;
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11.5px; position: relative;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs .dot {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 17px; height: 17px; border-radius: 9px; padding: 0 4px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 700;
}

/* карточки и списки */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--line); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; gap: 12px; align-items: stretch; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.past { opacity: .55; }
.item.cancelled .title { text-decoration: line-through; }
.time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 48px; font-size: 15px; }
.time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.bar { width: 4px; border-radius: 4px; background: var(--rehearsal); flex: none; }
.bar.performance { background: var(--performance); }
.bar.other { background: var(--other); }

.day-h { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 2px 8px; font-weight: 600; }
.day-h.today { color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 36px 12px; }

/* бейджи */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--rehearsal-soft); color: var(--rehearsal); white-space: nowrap; }
.badge.performance { background: var(--performance-soft); color: var(--performance); }
.badge.other { background: var(--other-soft); color: var(--other); }
.badge.gray { background: var(--line); color: var(--muted); }
.badge.warn { background: #fbecd6; color: #8a5410; }
.badge.bad { background: #f9dedc; color: var(--bad); }
.badge.ok { background: #dcefe3; color: var(--ok); }
@media (prefers-color-scheme: dark) {
  .badge.warn { background: #3a2c16; color: #e8b46a; }
  .badge.bad { background: #3b1e1c; color: #f09a93; }
  .badge.ok { background: #1c3326; color: #84cfa1; }
}
.me-mark { color: var(--gold); font-size: 13px; font-weight: 600; }

/* сегменты и чипы */
.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 8px; font: inherit; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 13.5px; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* календарь месяца */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.month-nav b { font-size: 17px; text-transform: capitalize; }
.month-nav button { border: 0; background: var(--card); width: 38px; height: 38px; border-radius: 10px; font-size: 18px; color: var(--ink); border: 1px solid var(--line); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: var(--card); border-radius: var(--radius); padding: 8px; border: 1px solid var(--line); }
.cal .wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 6px; text-transform: uppercase; }
.cal .d { aspect-ratio: 1 / .9; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 9px; font-size: 14px; border: 0; background: none; color: var(--ink); font-variant-numeric: tabular-nums; padding: 0; }
.cal .d.out { color: var(--line); }
.cal .d.today { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.cal .d.sel { outline: 2px solid var(--accent); }
.cal .dots { display: flex; gap: 2px; height: 6px; margin-top: 2px; }
.cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--rehearsal); }
.cal .dots i.performance { background: var(--performance); }
.cal .dots i.other { background: var(--other); }

/* формы */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--card); font-size: 14.5px; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; cursor: pointer;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--bad); border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.btns .btn { flex: 1; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); z-index: 9;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(110, 26, 38, .35); text-decoration: none;
  display: grid; place-items: center;
}

/* детали */
.detail h2 { margin: 8px 0 6px; font-size: 24px; line-height: 1.2; }
.kv { display: grid; grid-template-columns: 26px 1fr; gap: 10px 8px; margin: 12px 0; align-items: start; }
.kv .ic { color: var(--muted); text-align: center; }
.notes { white-space: pre-wrap; }
.rsvp { display: flex; gap: 6px; }
.rsvp button { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 11px 4px; font: inherit; font-size: 14.5px; font-weight: 600; }
.rsvp button.on.yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.rsvp button.on.no { background: var(--bad); border-color: var(--bad); color: #fff; }
.rsvp button.on.maybe { background: var(--warn); border-color: var(--warn); color: #fff; }
.people .p { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.people .p:last-child { border-bottom: 0; }
.people .p small { color: var(--muted); display: block; }
.section-t { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin: 20px 2px 8px; }
.summary { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }

.contact-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.contact-actions a { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--accent); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; font-size: 12.5px; font-weight: 600; }
.contact-actions a span { font-size: 20px; }
.contact-actions a.off { opacity: .35; pointer-events: none; }
.remind-box { border-left: 4px solid var(--gold); }
.remind-box.due { border-left-color: var(--bad); }
.log .e { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log .e:last-child { border-bottom: 0; }
.log .e small { color: var(--muted); }

.search { margin-bottom: 10px; }
.notif { display: block; text-decoration: none; color: inherit; }
.notif.unread { border-left: 4px solid var(--accent); }
.notif .when { color: var(--muted); font-size: 12.5px; }
.notif .body { white-space: pre-wrap; font-size: 14.5px; margin-top: 2px; }

/* вход */
.login { max-width: 380px; margin: 0 auto; padding: 12vh 24px 24px; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 26px; }
.login p { text-align: center; color: var(--muted); margin: 0 0 26px; }
.err { color: var(--bad); font-size: 14px; margin: 4px 0 10px; min-height: 1em; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: #2a2422; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14.5px; z-index: 50;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hint { color: var(--muted); font-size: 13.5px; margin: 4px 0 10px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-size: 12.5px; }
