/* Familie (Album and Betreuung): large type, high contrast, one column. No external fonts or requests. */

:root {
  color-scheme: light dark;
  --bg: #f7f2ea;
  --surface: #fffdf9;
  --ink: #1b1814;
  --muted: #4d443a;
  --line: #d8ccbd;
  --placeholder: #e7dccd;
  --accent: #9a3d17;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d6;
  --danger: #9e2418;
  --focus: #1d5fa8;
  --night: #233054;
  --night-ink: #f4f2ff;
  --night-muted: #ccd3ef;
  --day: #fbe9c8;
  --day-ink: #2a1e0c;
  --day-muted: #5a4526;
  --ok: #1e6b3a;
  --shadow: 0 10px 30px rgba(27, 24, 20, 0.22);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1f1b17;
    --ink: #f6f0e7;
    --muted: #d2c6b6;
    --line: #3d352d;
    --placeholder: #2c2620;
    --accent: #f2a676;
    --accent-ink: #1d120a;
    --accent-soft: #3a2619;
    --danger: #ff9c8f;
    --focus: #8cc4ff;
    --night: #1c2645;
    --night-ink: #f4f2ff;
    --night-muted: #c3cbea;
    --day: #3d2c12;
    --day-ink: #fff1d6;
    --day-muted: #e6cfa6;
    --ok: #8fdcaa;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 19px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

body.viewer-open {
  overflow: hidden;
}

img,
video {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Buttons ---------------------------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 52px;
  min-width: 52px;
  padding: 0.4em 1.2em;
  border-radius: 14px;
  border: 2px solid transparent;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

.btn svg {
  width: 1.3em;
  height: 1.3em;
  flex: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---- Full screens (loading, invitation, errors) ----------------------------------------------------------------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}

.screen-card {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.screen-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
}

.screen-title {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 16px;
}

.screen-text {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.screen-hint {
  color: var(--muted);
  margin: 0 0 24px;
}

.screen .row {
  justify-content: center;
}

/* ---- The album page --------------------------------------------------------------------------------------------- */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom));
}

.top {
  margin-bottom: 20px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 650;
}

.brand img {
  width: 36px;
  height: 36px;
}

/* Headings get the focus after a screen changes (for screen readers); a ring there would only confuse. */
[tabindex="-1"]:focus {
  outline: none;
}

.hello {
  font-family: var(--serif);
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}

.logout-confirm {
  margin: 16px 0 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.logout-confirm p {
  margin: 0 0 14px;
}

.notice {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 0 0 20px;
}

.notice-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.notice p {
  margin: 0 0 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.tab {
  min-height: 52px;
  padding: 0.4em 1.1em;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  font-weight: 650;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.feed-title {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 16px;
}

.posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 16px 16px;
  margin: 0 0 22px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.6em;
  margin: 0 0 8px;
}

.post-author {
  font-weight: 700;
  font-size: 1.1rem;
}

.post-date {
  color: var(--muted);
}

.post-text {
  margin: 0 0 12px;
  font-size: 1.1rem;
  white-space: pre-wrap;
}

.post-text:last-child {
  margin-bottom: 0;
}

/* ---- Photo grid ------------------------------------------------------------------------------------------------- */

.media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border-radius: 14px;
  overflow: hidden;
  margin: 4px 0 0;
}

.grid-1 {
  grid-template-columns: 1fr;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  margin: 0;
  border: 0;
  background: var(--placeholder);
  overflow: hidden;
  cursor: zoom-in;
}

.grid-1 .tile {
  aspect-ratio: 4 / 3;
  max-height: 80vh;
}

.grid-3 .tile:first-child {
  grid-column: span 2;
  aspect-ratio: 3 / 2;
}

.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.tile img.loaded {
  opacity: 1;
}

.tile:focus-visible {
  outline-offset: -4px;
  z-index: 1;
}

.tile-failed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 12px, rgba(0, 0, 0, 0.06) 12px 24px);
}

.badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 650;
}

.badge svg {
  width: 22px;
  height: 22px;
}

.play-mark {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  display: grid;
  place-items: center;
}

.play-mark svg {
  width: 34px;
  height: 34px;
  margin-left: 4px;
}

.more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
}

/* ---- States in the feed ----------------------------------------------------------------------------------------- */

.feed-state {
  text-align: center;
  color: var(--muted);
  padding: 28px 8px;
  margin: 0;
}

.feed-error {
  text-align: center;
  padding: 20px 8px;
}

.feed-error p {
  color: var(--danger);
  font-weight: 650;
  margin: 0 0 14px;
}

.feed-error .row,
.feed-more {
  justify-content: center;
}

.feed-more {
  display: flex;
  margin: 8px 0 0;
}

.sentinel {
  height: 1px;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Viewer ----------------------------------------------------------------------------------------------------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #000;
  color: #fff;
  --focus: #ffd27a;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
}

.viewer-bar-bottom {
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}

.viewer-position {
  font-weight: 650;
  font-size: 1.05rem;
  padding: 0 8px;
}

.viewer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-width: 56px;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.viewer-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

.viewer-btn svg {
  width: 28px;
  height: 28px;
  flex: none;
}

.viewer-btn-strong {
  background: #fff;
  color: #000;
}

.viewer-stage {
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.viewer-stage img,
.viewer-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
}

.viewer-stage img {
  -webkit-user-drag: none;
}

.viewer-stage.animating img {
  transition: transform 0.2s ease;
}

.viewer-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
}

.viewer-center p {
  margin: 0;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
}

.viewer progress {
  width: min(320px, 80vw);
  height: 14px;
  accent-color: #ffd27a;
}

.viewer-play {
  min-height: 72px;
  padding: 0 28px;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid #fff;
}

/* ---- Header actions, start screen ------------------------------------------------------------------------------- */

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.warning {
  color: var(--danger);
  font-weight: 650;
}

.areas {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.area {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 96px;
  padding: 16px 18px;
  border-radius: 22px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.area-care {
  border-color: var(--accent);
}

.area-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}

.area-icon svg {
  width: 34px;
  height: 34px;
}

.area-text {
  display: grid;
  gap: 2px;
}

.area-name {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.area-hint {
  color: var(--muted);
}

/* ---- Betreuung -------------------------------------------------------------------------------------------------- */

.care {
  display: grid;
  gap: 18px;
}

.child-tabs {
  margin: 0;
}

.status-card {
  border-radius: 24px;
  padding: 20px 20px 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  min-height: 120px;
}

.status-card.is-asleep {
  background: var(--night);
  color: var(--night-ink);
  border-color: var(--night);
}

.status-card.is-awake {
  background: var(--day);
  color: var(--day-ink);
  border-color: var(--day);
}

.status-card p {
  margin: 0;
}

.status-child {
  font-weight: 650;
  opacity: 0.9;
}

.status-main {
  font-size: 1.7rem;
  font-weight: 750;
  line-height: 1.2;
  margin: 4px 0 8px !important;
}

.status-next {
  font-size: 1.15rem;
  font-weight: 650;
}

.status-detail {
  margin-top: 6px !important;
}

.is-asleep .status-detail {
  color: var(--night-muted);
}

.is-awake .status-detail {
  color: var(--day-muted);
}

.care-waiting {
  margin: 0;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px dashed var(--line);
  font-weight: 650;
}

.care-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.care-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 84px;
  padding: 10px 8px;
  overflow-wrap: normal;
  hyphens: auto;
  border-radius: 18px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
}

.care-btn svg {
  width: 30px;
  height: 30px;
  flex: none;
}

.care-btn:active {
  transform: scale(0.98);
}

.care-sleep_start {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 12px;
  min-height: 84px;
  font-size: 1.3rem;
  background: var(--night);
  border-color: var(--night);
  color: var(--night-ink);
}

.care-sleep_start.is-asleep {
  background: var(--day);
  border-color: var(--day-ink);
  color: var(--day-ink);
}

.care-block .section-title {
  margin-bottom: 8px;
}

.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.today-list li {
  display: grid;
  grid-template-columns: 6.4em 1fr;
  gap: 0 14px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.today-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.today-label {
  font-weight: 600;
}

.today-by {
  grid-column: 2;
  color: var(--muted);
}

.today-list .is-pending .today-label {
  font-style: italic;
}

.today-list .today-empty {
  display: block;
  color: var(--muted);
}

.care-section {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 12px;
}

.care-section summary {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}

.care-section summary::-webkit-details-marker {
  margin-right: 8px;
}

.care-section-body {
  padding: 0 16px 14px;
}

.care-lines {
  margin: 0;
}

.care-line {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.care-line:first-child {
  border-top: 0;
}

.care-line dt {
  color: var(--muted);
  font-weight: 600;
}

.care-line dd {
  margin: 2px 0 0;
  font-size: 1.1rem;
  white-space: pre-wrap;
}

.call-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 18px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.35rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.call-link svg {
  width: 26px;
  height: 26px;
}

.care-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.care-updated {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

/* ---- Toast ------------------------------------------------------------------------------------------------------ */

body.has-toast .page {
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: min(560px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.toast-text {
  display: grid;
}

.toast-text strong {
  font-size: 1.15rem;
}

.toast-detail {
  opacity: 0.85;
}

.toast .toast-undo {
  flex: none;
  color: var(--bg);
  border-color: var(--bg);
}

/* ---- Sheets ----------------------------------------------------------------------------------------------------- */

.sheet {
  width: min(600px, 100vw);
  max-width: 100vw;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  color: var(--ink);
  overflow: auto;
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-radius: 24px;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 1.5rem;
  margin: 0;
}

.sheet-close {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.sheet-close svg {
  width: 26px;
  height: 26px;
}

.sheet-group {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.sheet-group legend,
.sheet-group label {
  font-weight: 700;
  padding: 0;
  margin: 0 0 8px;
}

.sheet-hint {
  margin: 0 0 10px;
  color: var(--muted);
}

.sheet-hint:empty {
  display: none;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr));
  gap: 10px;
}

.choices-3 {
  grid-template-columns: repeat(3, 1fr);
}

.choices-2 {
  grid-template-columns: repeat(2, 1fr);
}

.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: normal;
  hyphens: manual;
  cursor: pointer;
  touch-action: manipulation;
}

.choices-3 .choice {
  font-size: 1rem;
  padding: 8px 4px;
}

.choice svg {
  width: 26px;
  height: 26px;
  flex: none;
}

.choice[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.field {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
}

textarea.field {
  min-height: 7em;
  resize: vertical;
}

.inline-field {
  display: flex;
  gap: 10px;
}

.inline-field .field {
  flex: 1;
  min-width: 0;
}

.sheet-submit {
  width: 100%;
  min-height: 64px;
  font-size: 1.15rem;
}

.photo-grid {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-grid:empty {
  display: none;
}

.photo-grid li {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--placeholder);
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
}

.photo-remove svg {
  width: 22px;
  height: 22px;
}

@media (min-width: 760px) {
  html {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .tab[aria-selected="true"] {
    border-width: 4px;
  }
}
