:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1d1f22;
  --muted: #6b6f76;
  --line: #e4e0da;
  --accent: #357776;      /* EverPal teal #4A9B9A, darkened for 5:1 contrast */
  --accent-text: #ffffff;
  --chip-on: #dcefee;
  --danger: #b3412f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --surface: #202327;
    --text: #ecebe8;
    --muted: #9a9ea5;
    --line: #33373c;
    --accent: #6cc3c1;
    --accent-text: #0f1a1a;
    --chip-on: #1f3d3c;
    --danger: #e0806f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181b; --surface: #202327; --text: #ecebe8; --muted: #9a9ea5; --line: #33373c;
  --accent: #6cc3c1; --accent-text: #0f1a1a; --chip-on: #1f3d3c; --danger: #e0806f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(80px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }

button, .button, select, input {
  font: inherit;
  color: inherit;
  border-radius: 10px;
}
button, .button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 10px 14px;
  text-decoration: none;
  display: inline-block;
}
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.ghost { color: var(--muted); }
.danger { color: var(--danger); }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.end { justify-content: flex-end; }
input, select {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  width: 100%;
}
select { width: auto; }

.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.top h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; color: var(--accent); }
.top h1 img { height: 22px; width: auto; }
#menu-btn { font-size: 24px; line-height: 1; padding: 4px 10px; }

/* The whole product: six big buttons */
.buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.log-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  aspect-ratio: 1 / 0.85;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.08s;
}
.log-btn span { font-size: 34px; line-height: 1; }
.log-btn:active { transform: scale(0.95); background: var(--chip-on); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-top: 12px;
  display: grid;
  gap: 12px;
}
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.detail-head input { width: auto; padding: 6px 8px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
}
.chip.on { background: var(--chip-on); border-color: var(--accent); font-weight: 600; }

.install p { margin: 0; }
.share-icon { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }

.unlock { margin: 4px 0 8px; }
.unlock .primary { width: 100%; padding: 12px; }
.unlock .small { font-size: 14px; }
.unlock a, .menu a { color: var(--accent); }
#report-back { white-space: nowrap; }
.unlock p { margin: 0; }
.print-locked { display: none; }

.timeline h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 24px 0 6px;
}
.timeline ul { list-style: none; margin: 0; padding: 0; }
.entry {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  padding: 10px 4px;
  border-radius: 8px;
  border-bottom: 1px solid var(--line);
}
.entry.open { background: var(--chip-on); }
.entry time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; min-width: 3.2em; }
.icon { font-size: 18px; }
.what { flex: 1; }
.empty { text-align: center; color: var(--muted); margin-top: 48px; }
.more { width: 100%; margin-top: 12px; }

dialog {
  border: 0;
  border-radius: 16px;
  padding: 8px;
  background: var(--surface);
  color: var(--text);
  width: min(320px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.menu { display: grid; }
.menu button { text-align: left; padding: 14px; }
.menu small { color: var(--muted); }
.menu p { margin: 6px 14px; font-size: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.toast button { color: var(--bg); font-weight: 700; padding: 6px 10px; }

/* Vet report */
#report h1 { font-size: 22px; margin: 16px 0 2px; }
#report h2 { font-size: 16px; margin: 24px 0 8px; }
#report table { width: 100%; border-collapse: collapse; font-size: 14px; }
#report th, #report td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
#report th { color: var(--muted); font-weight: 600; }
#report .num { text-align: right; }
#report .icon { margin-right: 6px; }
#report .summary td:first-child { white-space: nowrap; }
#report .entries td:first-child { white-space: nowrap; font-weight: 600; }
#report .entries td:nth-child(2) { color: var(--muted); font-variant-numeric: tabular-nums; }
#report .new-day td { border-top: 2px solid var(--line); }

@page { margin: 15mm; }
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #555; --line: #ccc; }
  .no-print, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  #report tr { break-inside: avoid; }
  /* Printing from the browser menu without a license prints a notice, not the report. */
  body:not(.paid) #report { display: none; }
  body:not(.paid) .print-locked { display: block; }
}
