:root {
  --bg: #f3eee7;
  --bg-2: #e7efe9;
  --surface: rgba(255, 252, 247, 0.82);
  --surface-solid: #fffdf9;
  --ink: #2a2622;
  --muted: #7a7268;
  --pine: #4a6b57;
  --pine-deep: #385445;
  --ochre: #c4895a;
  --line: rgba(42, 38, 34, 0.08);
  --flash-ok: #e7efe8;
  --flash-ok-ink: #2f4a3a;
  --flash-err: #f8e6e1;
  --flash-err-ink: #8a3a2a;
  --busy: #f0e0cf;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 12px 40px rgba(42, 38, 34, 0.07);
  --shadow-soft: 0 6px 20px rgba(42, 38, 34, 0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sans: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(900px 520px at 8% -8%, #fde8d4 0%, transparent 52%),
    radial-gradient(780px 460px at 108% 0%, var(--bg-2) 0%, transparent 48%),
    var(--bg);
  padding-bottom: 1.5rem;
}
body.has-nav {
  padding-bottom: calc(96px + var(--safe-bottom));
}
body.notif-open { overflow: hidden; }
h1, h2, .brand {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.035em;
}
h1 { font-size: 1.7rem; margin: 0 0 0.55rem; line-height: 1.2; }
h2 { font-size: 1.12rem; margin: 1.7rem 0 0.7rem; font-weight: 600; }
a { color: var(--pine); text-decoration: none; }
button, a { -webkit-tap-highlight-color: rgba(74, 107, 87, 0.12); touch-action: manipulation; }
.wrap { max-width: 760px; margin: 0 auto; padding: 1.15rem 1.15rem 2rem; }
.auth-page .wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}
.auth {
  width: 100%;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.5rem 1.35rem 1.6rem;
  box-shadow: var(--shadow);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.7rem + var(--safe-top)) max(0.9rem, env(safe-area-inset-right)) 0.65rem max(0.9rem, env(safe-area-inset-left));
}
.brand {
  font-size: 1.15rem;
  color: var(--ink);
  padding: 0.35rem 0.4rem 0.35rem 0;
  flex-shrink: 0;
}
.who.logout {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-name::after { content: " · "; }
.eyebrow {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ochre);
  margin: 0 0 0.4rem;
}
.lead, .muted { color: var(--muted); line-height: 1.5; }
.stack { display: grid; gap: 0.9rem; margin: 1rem 0; }
.panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.05rem;
  box-shadow: var(--shadow-soft);
}
label { display: grid; gap: 0.4rem; font-size: 0.9rem; color: var(--muted); }
input, textarea, button, select {
  font: inherit;
  color: var(--ink);
}
input, textarea, select {
  border: 1px solid var(--line);
  background: var(--surface-solid);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.9rem;
  min-height: 48px;
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(74, 107, 87, 0.28);
  outline-offset: 1px;
  border-color: transparent;
}
textarea { min-height: 96px; resize: vertical; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--pine);
  color: #f7f3ec;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(74, 107, 87, 0.22);
}
.btn:hover { background: var(--pine-deep); }
.btn.ghost {
  background: transparent;
  color: var(--pine);
  border: 1px solid rgba(74, 107, 87, 0.28);
  box-shadow: none;
}
.btn.tiny { min-height: 38px; padding: 0.35rem 0.8rem; font-size: 0.82rem; }
.actions, .row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.grid2 { display: grid; gap: 0.85rem; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
label.check {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--ink);
  line-height: 1.4;
}
label.check input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  min-height: 1.2rem;
  margin: 0.15rem 0 0;
  padding: 0;
  flex: 0 0 auto;
  box-shadow: none;
  accent-color: var(--pine);
}
.hint {
  margin-top: 1.2rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(74, 107, 87, 0.08);
  color: var(--muted);
  font-size: 0.92rem;
  border: 0;
}
.auth-wait { display: grid; gap: 0.85rem; margin: 1rem 0; }
.auth-wait .stack { margin: 0; }
.auth-wait input[name="code"] {
  letter-spacing: 0.28em;
  font-size: 1.2rem;
  text-align: center;
}
.flash {
  margin: 0.65rem 1.15rem 0;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  color: var(--flash-ok-ink);
  background: var(--flash-ok);
}
.flash.err { background: var(--flash-err); color: var(--flash-err-ink); }
.tabbar {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(8px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: rgba(255, 252, 247, 0.88);
  backdrop-filter: blur(22px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 6px;
  box-shadow: 0 14px 40px rgba(42, 38, 34, 0.12);
  z-index: 20;
}
.tabbar a {
  text-align: center;
  padding: 0.7rem 0.06rem;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 16px;
}
.tabbar a.on,
.tabbar a:active {
  color: var(--pine-deep);
  background: rgba(74, 107, 87, 0.12);
}
.stats {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
.stats li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-soft);
}
.stats strong {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.15rem;
}
.stats a { display: block; color: inherit; }
.list.today li { font-size: 0.92rem; }
.beta-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; color: var(--muted); font-size: 0.82rem; }
.beta-detail { margin: 0.45rem 0 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.chip {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.chip.on { background: rgba(74, 107, 87, 0.14); color: var(--pine-deep); border-color: transparent; }
.contacts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.edit {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 1rem 0.9rem;
}
.edit summary {
  cursor: pointer;
  padding: 0.6rem 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--pine-deep);
}
.edit .stack { margin-top: 0.4rem; }
.card .edit { background: transparent; box-shadow: none; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.month-nav a {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
}
.month-nav h1 { margin: 0; text-transform: capitalize; font-size: 1.35rem; }
.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 1rem 0;
}
.cal-head, .cal-day {
  min-height: 54px;
  padding: 0.4rem 0.3rem;
  font-size: 0.78rem;
}
.cal-head { color: var(--muted); text-align: center; font-weight: 600; min-height: auto; }
.cal-day {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.past { opacity: 0.45; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--pine); }
.cal-day.busy { background: var(--busy); }
.cal-day small { display: block; color: var(--ochre); margin-top: 0.15rem; }
.gallery { display: grid; gap: 1rem; }
@media (min-width: 640px) { .gallery { grid-template-columns: 1fr 1fr; } }
.gallery figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0 0 0.85rem;
  box-shadow: var(--shadow-soft);
}
.gallery .frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: #eadfd3;
}
.gallery img, .gallery video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eadfd3;
}
.gallery figcaption, .gallery .inline, .gallery .row {
  margin-left: 0.85rem;
  margin-right: 0.85rem;
}
.gallery figcaption { color: var(--muted); font-size: 0.86rem; margin-top: 0.7rem; }
.list { list-style: none; padding: 0; display: grid; gap: 0.65rem; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.chat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  width: 100%;
  color: inherit;
}
.chat-item { align-items: flex-start; }
.chat-main { display: grid; gap: 0.2rem; min-width: 0; }
.chat-main .preview {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cards { list-style: none; padding: 0; display: grid; gap: 0.9rem; }
.card {
  border: 1px solid var(--line);
  padding: 1.05rem 1.1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card h2 { margin: 0.35rem 0 0.4rem; font-size: 1.2rem; }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.2rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(42, 38, 34, 0.06);
  color: var(--muted);
}
.badge.pending { background: rgba(196, 137, 90, 0.18); color: #8a5a32; }
.badge.confirmed { background: rgba(74, 107, 87, 0.16); color: var(--pine-deep); }
.badge.rejected, .badge.cancelled { background: rgba(138, 58, 42, 0.1); color: #8a3a2a; }
.badge.live { background: rgba(74, 107, 87, 0.16); color: var(--pine-deep); }
.badge.upcoming { background: rgba(196, 137, 90, 0.18); color: #8a5a32; }
.badge.paused, .badge.ended { background: rgba(42, 38, 34, 0.06); color: var(--muted); }
.status-pending { box-shadow: var(--shadow-soft), inset 3px 0 0 var(--ochre); }
.status-confirmed { box-shadow: var(--shadow-soft), inset 3px 0 0 var(--pine); }
.thread { display: grid; gap: 0.7rem; }
.bubble {
  margin: 0;
  padding: 0.8rem 0.95rem;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 92%;
}
.bubble.assistant {
  background: #eef4ef;
  border-color: transparent;
  border-radius: 18px 18px 6px 18px;
  justify-self: end;
}
.bubble span { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.3rem; }
.qr-card {
  display: inline-block;
  background: #fff;
  padding: 14px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.qr { width: min(240px, 100%); display: block; }
.code-card { text-align: center; }
.pair-code {
  font-size: 2rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  margin: 0.4rem 0 0.8rem;
}
.steps {
  padding-left: 1.2rem;
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
}
.prompt {
  margin-top: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 1rem 1rem;
}
.prompt pre {
  white-space: pre-wrap;
  font-size: 0.8rem;
  background: var(--surface-solid);
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.steps { padding-left: 1.2rem; color: var(--muted); line-height: 1.5; }
.inline { display: flex; gap: 0.4rem; }
.inline input { flex: 1; }
.status-line { color: var(--muted); }
.status-line strong { color: var(--ink); }
.status-line.chat-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
.composer {
  position: sticky;
  bottom: calc(96px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.55rem;
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.composer textarea { flex: 1; resize: vertical; }
.chat-error { color: #8a3a2a; font-size: 0.88rem; margin: 0.5rem 0 0; }
.btn.busy {
  opacity: 0.85;
  cursor: progress;
  gap: 0.45rem;
  pointer-events: none;
}
.btn.busy::after {
  content: "";
  width: 0.85em;
  height: 0.85em;
  border: 2px solid rgba(247, 243, 236, 0.35);
  border-top-color: #f7f3ec;
  border-radius: 50%;
  animation: ptr-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn.ghost.busy::after {
  border-color: rgba(74, 107, 87, 0.22);
  border-top-color: var(--pine);
}

.top-actions { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.bell-wrap { position: relative; flex-shrink: 0; }
.bell {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.bell-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e23d3d;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.notif-scrim {
  position: fixed;
  inset: 0;
  background: rgba(42, 38, 34, 0.28);
  z-index: 40;
}
.notif-panel {
  position: fixed;
  top: calc(3.4rem + var(--safe-top));
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  width: auto;
  max-width: 380px;
  margin-left: auto;
  max-height: min(70dvh, calc(100dvh - 8.5rem - var(--safe-bottom)));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 45;
  padding: 0.8rem;
}
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.notif-head strong { min-width: 0; }
.notif-head-actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.notif-close {
  display: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
}
.notif-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.notif-list a {
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  color: inherit;
  background: rgba(42, 38, 34, 0.04);
  overflow-wrap: anywhere;
}
.notif-list a span { color: var(--muted); font-size: 0.82rem; }
.notif-list li.unread a { background: rgba(226, 61, 61, 0.08); }
.toasts {
  position: fixed;
  top: calc(4.4rem + var(--safe-top));
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  z-index: 50;
  display: grid;
  gap: 0.55rem;
  pointer-events: none;
  max-width: 420px;
  margin-left: auto;
}
.toast {
  pointer-events: auto;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.2rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.toast span { color: var(--muted); font-size: 0.86rem; }
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 38, 34, 0.28);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(96px + var(--safe-bottom));
}
.overlay[hidden],
.notif-panel[hidden],
.notif-scrim[hidden],
.bell-count[hidden],
.cookie-layer[hidden],
.ptr[hidden],
.push-enable[hidden],
.push-hint[hidden] { display: none !important; }
.push-enable { white-space: nowrap; flex-shrink: 1; min-width: 0; }
.push-hint {
  margin: 0;
  padding: 0.55rem max(0.9rem, env(safe-area-inset-right)) 0.55rem max(0.9rem, env(safe-area-inset-left));
  background: rgba(74, 107, 87, 0.1);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.4;
  text-align: center;
}
.sheet {
  width: min(560px, 100%);
  background: #fffdf9;
  border-radius: 24px 24px 20px 20px;
  padding: 1.1rem 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  max-height: 80vh;
  overflow: auto;
}
.cookie-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(96px + var(--safe-bottom));
  background: rgba(42, 38, 34, 0.28);
}
.cookie-card {
  width: min(440px, 100%);
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.15rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}
.cookie-card p { margin: 0 0 0.9rem; line-height: 1.45; }
.cookie-card .btn { width: 100%; }
.auth-page .cookie-layer {
  align-items: center;
  padding-bottom: calc(16px + var(--safe-bottom));
}
.changelog-dialog {
  width: min(440px, calc(100% - 24px));
  max-width: 440px;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.changelog-dialog::backdrop { background: rgba(42, 38, 34, 0.36); }
.changelog-card {
  padding: 1.25rem 1.2rem 1.2rem;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.changelog-card h2 { margin: 0.2rem 0 0.55rem; font-size: 1.35rem; }
.changelog-card p { margin-top: 0; line-height: 1.45; }
.changelog-list { margin: 0 0 1.1rem; padding-left: 1.2rem; line-height: 1.55; }
.changelog-card .btn { width: 100%; }
button.cal-day,
button.chat-row {
  appearance: none;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}
button.cal-day { display: block; }
button.chat-row { background: transparent; border: 0; padding: 0; flex: 1; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .wrap > section { animation: rise 0.15s ease both; }
  .btn, .cal-day, .card, .panel, .bell, .who.logout {
    transition: transform 0.16s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active, .cal-day:active, .bell:active { transform: scale(0.97); }
  .cal-day.busy:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
  .flash { animation: rise 0.4s ease both; }
  .toast { animation: toast-in 0.35s ease both; }
  .toast.out { animation: toast-out 0.25s ease both; }
  .overlay { animation: fade-in 0.2s ease; }
  .sheet { animation: sheet-in 0.32s ease; }
  .cookie-card { animation: sheet-in 0.32s ease; }
  .bell.has-new { animation: bell-shake 0.55s ease; }
  .page-progress.on::after { animation: page-progress-run 1.1s ease-out forwards; }
}
@media (prefers-reduced-motion: reduce) {
  .toast.out { opacity: 0; }
  .ptr-spinner { animation: none; }
  .btn.busy::after { animation: none; }
  .page-progress.on::after { width: 70%; }
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  html, body { overscroll-behavior-y: contain; }
}
html.pwa, html.pwa body { overscroll-behavior-y: contain; }

.ptr {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 0;
  right: 0;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
}
.ptr.visible { opacity: 1; }
.ptr.loading { opacity: 1; transform: none; }
.ptr-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(74, 107, 87, 0.18);
  border-top-color: var(--pine);
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow: var(--shadow-soft);
}
.ptr.ready .ptr-spinner { border-top-color: var(--ochre); }
.ptr.loading .ptr-spinner { animation: ptr-spin 0.7s linear infinite; }
.ptr-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.ptr.ready .ptr-label { color: var(--ochre); }

.page-progress {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 40;
  pointer-events: none;
  background: transparent;
  overflow: hidden;
}
.page-progress[hidden] { display: none; }
.page-progress::after {
  content: "";
  display: block;
  height: 3px;
  width: 0;
  background: var(--pine);
  border-radius: 0 2px 2px 0;
}
.page-progress.on::after { width: 70%; }

@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}
@keyframes page-progress-run {
  0% { width: 0; }
  18% { width: 42%; }
  48% { width: 70%; }
  78% { width: 86%; }
  100% { width: 92%; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}
@keyframes bell-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(12deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(6deg); }
  80% { transform: rotate(-4deg); }
}

@media (max-width: 720px) {
  h1 { font-size: 1.42rem; }
  .wrap {
    padding: 0.85rem max(0.9rem, env(safe-area-inset-right)) 1.4rem max(0.9rem, env(safe-area-inset-left));
  }
  .who-name { display: none; }
  .who.logout { max-width: none; }
  .notif-panel {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    max-width: none;
    margin-left: 0;
    border-radius: 20px;
  }
  .notif-close { display: inline-flex; }
  .notif-head { flex-wrap: wrap; align-items: center; }
  .tabbar a { font-size: 0.62rem; padding: 0.68rem 0.05rem; }
  .cal { gap: 4px; }
  .cal-head, .cal-day { min-height: 46px; font-size: 0.68rem; padding: 0.28rem 0.12rem; }
  .cal-day small { font-size: 0.58rem; }
  .month-nav h1 { font-size: 1.15rem; }
  .actions .btn { flex: 1 1 calc(50% - 0.6rem); }
  .stats strong { font-size: 1.2rem; overflow-wrap: anywhere; }
  .lead { font-size: 0.95rem; }
  .gallery .frame { height: 180px; }
  .prompt pre { overflow-x: auto; }
  .inline { flex-wrap: wrap; }
  .card, .panel { overflow-wrap: anywhere; }
}

@media (min-width: 721px) {
  .notif-scrim { display: none !important; }
  .notif-close { display: none !important; }
}

/* Dashboard visual system */
:focus-visible { outline: 3px solid var(--pine); outline-offset: 3px; }
.welcome-tag { display: inline-flex; padding: .45rem .75rem; border-radius: 999px; background: rgba(74,107,87,.1); color: var(--pine); font-size: .78rem; font-weight: 600; }
.dashboard-stats { margin: 1.4rem 0; }
.dashboard-stats li { min-height: 112px; }
.dashboard-actions { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); }
.action-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .65rem; min-height: 116px; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); font-weight: 600; text-align: center; }
.action-btn.primary { background: var(--pine); color: #fff; }
.action-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-sm); background: rgba(74,107,87,.12); font-size: 1.5rem; }
.action-btn.primary .action-icon { background: rgba(255,255,255,.18); }
.info-card { padding: .35rem 1rem; }
.list li.unread { box-shadow: var(--shadow-soft), inset 3px 0 var(--ochre); background: rgba(196,137,90,.08); }
@media (min-width: 721px) { .dashboard { max-width: 1120px; } .dashboard-stats { grid-template-columns: repeat(3,1fr); } }

.poll-status, .chat-status, .send-status { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }
.poll-status[role="alert"], .chat-error { color: var(--flash-err-ink); }
.send-status.pending { color: var(--pine); }
.send-status.error { color: var(--flash-err-ink); }
