:root {
  --navy: #1e2a4a;
  --navy-2: #2c3c66;
  --gold: #c9a24a;
  --gold-2: #e4c77b;
  --terra: #b4451f;
  --ink: #2a2118;
  --muted: #6f6256;
  --line: #eadfcd;
  --bg: #f4efe6;
  --card: #fffdf9;
  --rose: #dc3c5a;
  --anniv: #a56b12;
  --yz: #5a3c8c;
  --hol: #285aaa;
  --shadow: 0 10px 28px rgba(30, 42, 74, 0.08);
  --nav: calc(62px + env(safe-area-inset-bottom));
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.35;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
}
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
  background: var(--navy);
  color: #fff;
}
header img.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: none;
  background: #fff;
}
.titles { min-width: 0; flex: 1; }
.brand {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-2);
  font-weight: 700;
}
h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#fam-no { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: var(--gold-2); }
#fam-no.miss-no, #fam-no.demo-no { font-weight: 600; color: #d9d3ea; font-size: 13px; }
#switcher {
  flex: none;
  border: 0;
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 800;
}
.demo, .offline {
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 650;
  text-align: center;
}
.pill { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 8px; background: #efe6d8; color: var(--navy); }
.pill.edit { background: #e7f2ea; color: #1d5c32; }
.pill.wait { background: #fff3d6; color: #7a4e00; }
.demo { background: var(--gold); color: var(--navy); }
.offline { background: #3b2414; color: #fff; }
main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 20px;
}
h2 { margin: 0 0 8px; font-size: 20px; font-family: Georgia, serif; }
.lede { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px;
  margin: 0 0 12px;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px;
  margin: 0 0 10px;
}
.row .who, .prow .who { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nm { font-weight: 750; font-size: 17px; }
.he { color: #7a5a28; font-size: 15px; direction: rtl; unicode-bidi: isolate; display: inline-block; }
.meta, .muted { color: var(--muted); font-size: 14px; }
.when { font-weight: 750; color: var(--terra); font-size: 13px; }
.kind {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.kind.bd { color: var(--rose); }
.kind.an { color: var(--anniv); }
.kind.yz { color: var(--yz); }
.kind.sim { color: var(--anniv); }
.avatar {
  width: 54px;
  height: 70px;
  border-radius: 12px;
  background: #efe4d2;
  color: var(--navy);
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  flex: none;
}
.avatar.lg { width: 92px; height: 120px; font-size: 36px; border-radius: 16px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.news {
  border-style: dashed;
  background: #fffdf8;
}
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6a32;
  margin-bottom: 4px;
}
.skel {
  height: 86px;
  border-radius: 18px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #efe6d8, #f7f1e7, #efe6d8);
  background-size: 200% 100%;
  animation: shine 1.2s infinite;
}
@keyframes shine { to { background-position: -200% 0; } }
.err { color: #8d1d1d; }
.btn, .actions a, .actions button, .actions .off, .linkrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-decoration: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 750;
  border: 0;
  background: var(--navy);
  color: #fff;
  margin-top: 8px;
}
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.ghost, .linkrow {
  background: #fff;
  color: var(--navy);
  border: 1.5px solid #e0d3bf;
  justify-content: flex-start;
}
.linkrow { flex-direction: column; align-items: flex-start; gap: 2px; }
.linkrow small { display: block; font-weight: 500; color: var(--muted); }
.seg { display: flex; gap: 6px; background: #efe6d8; border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 10px 6px;
  font-weight: 750;
}
.seg button.on { background: #fff; color: var(--terra); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.calhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.calhead button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 22px;
}
.calhead .month { text-align: center; min-width: 0; }
.calhead strong { display: block; font-family: Georgia, serif; font-size: 20px; }
.calhead span { color: var(--muted); font-size: 13px; }
.week, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 750; text-align: center; }
.cell {
  min-height: 48px;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 10px;
  padding: 3px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.cell.empty { background: transparent; }
.cell.shab { background: #f7f0e2; }
.cell.today { box-shadow: inset 0 0 0 2px var(--gold); }
.cell.on { background: var(--navy); color: #fff; }
.cell.on .gem, .cell.on .dot { color: var(--gold-2); }
.cell .n { font-weight: 800; font-size: 15px; line-height: 1.1; }
.cell .gem { font-size: 10px; color: #8a6a32; line-height: 1; }
.dots { display: flex; gap: 2px; min-height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.bd { background: var(--rose); }
.dot.an { background: var(--anniv); }
.dot.yz { background: var(--yz); }
.dot.hol { background: var(--hol); }
.dot.sim { background: var(--gold); }
.daycard h3 { margin: 0 0 6px; font-size: 18px; }
.ev { padding: 6px 0; border-top: 1px solid var(--line); }
.ev:first-of-type { border-top: 0; }
.zgrid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 15px; }
.zgrid b { font-weight: 650; }
.list-day { margin-bottom: 12px; }
.list-day h3 { margin: 0; font-size: 16px; }
.search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid #e0d3bf;
  background: #fff;
  margin-bottom: 10px;
}
.hh { margin: 0 0 8px; }
.kids { margin: 4px 0 8px 12px; padding-left: 10px; border-left: 3px solid var(--gold-2); }
.prow {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  margin: 0 0 6px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 650;
}
.profile-top { display: flex; gap: 14px; align-items: center; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions a, .actions button { margin: 0; padding: 12px 8px; }
.actions .off { opacity: 0.45; pointer-events: none; background: #efe8dc; color: #6f6256; }
.back {
  border: 0;
  background: transparent;
  color: var(--terra);
  font-weight: 800;
  padding: 0 0 8px;
}
.list-day .back { display: block; width: 100%; text-align: left; font-size: 16px; line-height: 1.3; }
.nm bdi, .zl { unicode-bidi: isolate; }
.zl { font-size: 13px; color: #7a4a1c; }
nav {
  flex: none;
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  z-index: 5;
}
nav button {
  border: 0;
  background: transparent;
  color: #8a7b6a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 700;
  min-height: 52px;
}
nav button.on { color: var(--terra); }
nav svg { width: 22px; height: 22px; fill: currentColor; }
#sheet {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.45);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#sheet[hidden] { display: none; }
.sheet {
  width: min(520px, 100%);
  background: #fffdf9;
  border-radius: 22px 22px 0 0;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  max-height: min(80vh, 640px);
  overflow: auto;
}
.sheet h2 { margin-top: 4px; }
.pick {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  margin: 0 0 8px;
  font-weight: 750;
}
.pick.on { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.pick small { display: block; font-weight: 600; color: var(--muted); }
label { display: block; font-weight: 700; font-size: 14px; margin-top: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (min-width: 800px) {
  body { background: #e7dfd2; }
  #app { box-shadow: 0 0 0 1px #e0d3bf; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
}
