@font-face {
  font-family: 'Caveat';
  src: url('/static/caveat.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #fff6f9;
  --bg2: #fdeef4;
  --card: #ffffff;
  --rose: #e8577e;
  --rose-dark: #c93d64;
  --rose-soft: #fde4ec;
  --plum: #5e3149;
  --muted: #9a7287;
  --line: #f4d7e2;
  --ok: #3fa877;
  --warn: #e3a33a;
  --bad: #d9534f;
  --shadow: 0 6px 24px rgba(201, 61, 100, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--plum);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
}

a { color: var(--rose-dark); }
code { background: var(--rose-soft); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--plum); }
.brand span { font-family: 'Caveat', cursive; font-size: 32px; font-weight: 700; line-height: 1; }
.logo { width: 40px; height: 40px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1; }
nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 500;
}
nav a:hover { color: var(--plum); background: var(--rose-soft); }
nav a.active { color: #fff; background: var(--rose); }
.logout { margin-left: auto; }
.logout button { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}
h1, h2, h3 { margin: 0 0 12px; }
h2 { font-size: 20px; }
.section-title { font-family: 'Caveat', cursive; font-size: 38px; margin: 12px 4px 4px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 8px; }
.grid .card { margin-bottom: 0; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.slot.done { border-style: solid; border-color: var(--rose); background: var(--rose-soft); }
.slot-icon { font-size: 26px; }
.slot-label { color: var(--muted); font-size: 14px; }

dl.status { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 12px; }
dl.status dt { color: var(--muted); }
dl.status dd { margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats div { display: flex; flex-direction: column; }
.stats strong { font-family: 'Caveat', cursive; font-size: 40px; line-height: 1; color: var(--rose); }
.stats span { color: var(--muted); font-size: 14px; }

button, .button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--plum);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
button:hover { border-color: var(--rose); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--rose); border-color: var(--rose); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--rose-dark); }
button.danger { color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.day { font-family: 'Caveat', cursive; font-size: 28px; margin: 28px 4px 10px; font-weight: 600; }
.moments { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; align-items: start; }
.moment {
  background: #fffdfb;
  padding: 12px 12px 14px;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(94, 49, 73, 0.12);
  transform: rotate(-0.6deg);
  transition: transform 0.2s;
}
.moment:nth-child(2n) { transform: rotate(0.7deg); }
.moment:hover { transform: rotate(0) scale(1.02); }
.moment.no-photo { background: linear-gradient(160deg, #fff 0%, #fff4f7 100%); }
.photos { display: grid; gap: 4px; margin-bottom: 10px; }
.photos.n2 { grid-template-columns: 1fr 1fr; }
.photos.n3 { grid-template-columns: 1fr 1fr; }
.photos.n3 img:first-child { grid-column: span 2; }
.photos img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; cursor: zoom-in; background: var(--rose-soft); }
.photos.n1 img { aspect-ratio: 4 / 3; }
.photos.n3 img:first-child { aspect-ratio: 2 / 1; }
.moment .text { font-family: 'Caveat', cursive; font-size: 24px; line-height: 1.2; margin: 4px 4px 8px; white-space: pre-wrap; word-break: break-word; }
.moment .meta { font-size: 13px; color: var(--muted); margin: 0 4px; }
.fav { color: var(--rose); }
.empty { text-align: center; }
.more { display: block; margin: 28px auto 0; }

#lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(40, 20, 30, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 16px;
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); }

.login { max-width: 400px; margin: 8vh auto; text-align: center; }
.login .logo { width: 72px; height: 72px; }
.login h1 { font-family: 'Caveat', cursive; font-size: 44px; margin-bottom: 0; }
form label { display: block; text-align: left; margin: 12px 0; font-weight: 500; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  font: inherit;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--plum);
}
input:focus, textarea:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
label.inline { display: block; margin: 12px 0; max-width: 460px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error { color: var(--bad); }
.form-msg { min-height: 1.5em; }
progress { width: 100%; height: 10px; accent-color: var(--rose); }

.steps { padding-left: 22px; }
.steps li { margin-bottom: 6px; }
#pair-result { margin-top: 18px; text-align: center; }
.qr { width: min(300px, 80vw); margin: 0 auto; padding: 12px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); }
.qr svg { width: 100%; height: auto; display: block; }
.code { font-size: 26px; letter-spacing: 3px; color: var(--rose-dark); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 14px; }

.sayings { list-style: none; padding: 0; margin: 12px 0; }
.sayings li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sayings li.inactive .txt { color: var(--muted); text-decoration: line-through; }
.sayings .txt { flex: 1; }
.sayings button { font-size: 13px; padding: 4px 12px; }
.src { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 8px; border-radius: 999px; background: var(--rose-soft); color: var(--rose-dark); }
.src.gemma { background: #ece6fb; color: #6a4fb3; }
details summary { cursor: pointer; color: var(--muted); margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--plum); color: #fff; padding: 10px 20px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 60; max-width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .top { padding: 10px 16px; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  nav a { white-space: nowrap; }
  .logout { margin-left: 0; }
  .row { grid-template-columns: 1fr; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}
