:root {
  --bg: #fffaf3;
  --ink: #2b2420;
  --muted: #6b5f57;
  --accent: #c4553a;
  --accent-ink: #ffffff;
  --helper: #ffffff;
  --helper-line: #eaded1;
  --me: #2f6db5;
  --me-ink: #ffffff;
  --ok: #2e7d4f;
  --ok-bg: #e7f4ec;
  --warn-bg: #fff1d6;
  --line: #e4d8cb;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 20px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2 { line-height: 1.2; }

/* ---------- Simple pages (setup, sign-in) ---------- */
body.page { padding: 24px 16px; }
.card { max-width: 560px; margin: 0 auto; }
.card h1 { font-size: 30px; margin: 8px 0 16px; }
.card h2 { font-size: 24px; margin: 28px 0 8px; }
.big { font-size: 22px; }
.small { font-size: 17px; color: var(--muted); }
.steps { padding-left: 1.4em; }
.steps li { margin: 12px 0; }
.error { color: #a02a1a; font-weight: 600; }
label { display: block; margin: 16px 0 6px; }
input[type=password], input[type=text], select {
  width: 100%; padding: 12px; font-size: 18px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}

.button {
  display: block; width: 100%; text-align: center; text-decoration: none;
  min-height: 56px; padding: 14px 18px; margin: 12px 0 0;
  border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-size: 21px; font-weight: 600; cursor: pointer;
}
.button.secondary { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.link { background: none; border: 0; color: var(--accent); font-size: 18px; text-decoration: underline; padding: 10px; cursor: pointer; }

/* ---------- Chat ---------- */
body.chat { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 24px; margin: 0; }
.topbar p { margin: 0; font-size: 16px; color: var(--muted); }
.topbar .link { font-size: 17px; white-space: nowrap; }

.status { padding: 10px 16px; font-size: 18px; font-weight: 600; text-align: center; }
.status.urgent { background: var(--ok-bg); color: var(--ok); }
.status.sunday { background: var(--warn-bg); color: #7a5200; }
.status.offline { background: #fde8e4; color: #8a2414; }

.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.msg.assistant { align-self: flex-start; background: var(--helper); border: 1px solid var(--helper-line); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: var(--me); color: var(--me-ink); border-bottom-right-radius: 6px; }
.msg.note { align-self: center; background: none; box-shadow: none; color: var(--muted); font-size: 17px; text-align: center; }
.msg img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; margin-bottom: 8px; }
.msg .photo-tag { font-size: 16px; opacity: 0.85; }
.typing { color: var(--muted); font-style: italic; }

.composer {
  border-top: 1px solid var(--line); background: #fff;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
}
.family {
  width: 100%; min-height: 52px; margin-bottom: 10px; border-radius: 14px; cursor: pointer;
  background: #fff; color: var(--accent); border: 2px solid var(--accent); font-size: 20px; font-weight: 600;
}
.row { display: flex; align-items: flex-end; gap: 8px; }
.photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 64px; min-height: 56px; margin: 0; border-radius: 14px; background: #f3ebe2; cursor: pointer; font-size: 24px;
}
.photo-label { font-size: 14px; }
textarea {
  flex: 1; min-height: 56px; max-height: 160px; resize: none;
  padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
}
textarea:focus { outline: none; border-color: var(--me); }
.send {
  min-width: 80px; min-height: 56px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 20px;
}
button:disabled { opacity: 0.5; cursor: default; }
.preview { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.preview img { max-height: 90px; max-width: 140px; border-radius: 10px; border: 1px solid var(--line); }

.sheet { position: fixed; inset: 0; background: rgba(30, 20, 10, 0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 560px; background: #fff; border-radius: 22px 22px 0 0; padding: 22px 16px calc(env(safe-area-inset-bottom) + 16px); text-align: center; }
.sheet-card h2 { margin: 0 0 8px; font-size: 24px; }
.button.urgent { background: var(--accent); }

/* ---------- Admin ---------- */
body.admin { padding: 20px 16px 40px; font-size: 17px; }
.admin main { max-width: 860px; margin: 0 auto; }
.admin h1 { font-size: 28px; margin: 0 0 4px; }
.admin h2 { font-size: 21px; margin: 28px 0 8px; }
.admin .muted { color: var(--muted); }
.admin .panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 10px 0; }
.admin .item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin .item:last-child { border-bottom: 0; }
.admin .item .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin .pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.admin .pill.urgent { background: #fde3dc; color: #8a2414; }
.admin .pill.sunday { background: var(--warn-bg); color: #7a5200; }
.admin .pill.done { background: var(--ok-bg); color: var(--ok); }
.admin .small-btn { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; }
.admin .small-btn.danger { color: #a02a1a; border-color: #e5b5ab; }
.admin .linkbox { width: 100%; padding: 10px; font-size: 15px; border: 1px dashed var(--accent); border-radius: 10px; background: #fffaf3; word-break: break-all; }
.admin .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .admin .grid { grid-template-columns: 1fr; } }
.admin .sms { white-space: pre-wrap; }
.admin .row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin .row-inline input { width: 90px; }
