/* PetHome — mobile-first, works at 360px, 44px touch targets */
:root {
  --bg: #FAF8F4;
  --card: #FFFFFF;
  --ink: #24313B;
  --muted: #6B7A86;
  --line: #E7E2D9;
  --accent: #2F7E6D;
  --accent-dark: #256557;
  --accent-soft: #E7F2EF;
  --amber: #E0A458;
  --danger: #C0504A;
  --danger-soft: #FBEDEC;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(36, 49, 59, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  font-size: 16px;
}
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.danger { color: var(--danger); }

.page { max-width: 860px; margin: 0 auto; padding: 16px 16px 64px; }
.page-title { margin-top: 12px; }
.crumbs { margin: 8px 0 0; font-size: .9rem; }
.crumbs a { text-decoration: none; color: var(--muted); }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 700; font-size: 1.1rem; color: var(--ink);
  text-decoration: none; letter-spacing: -0.01em;
}
.brand-mark { color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav a { text-decoration: none; color: var(--muted); padding: 10px 4px; min-height: 44px; display: inline-flex; align-items: center; }
.topnav a.on { color: var(--ink); font-weight: 600; }
.logout-form { display: inline; }

/* cards & forms */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 14px 0;
}
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%;
  margin-top: 4px; padding: 11px 12px;
  font-size: 1rem; font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff;
  min-height: 44px;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.grid-form .form-error, .grid-form button, .grid-form .manual-note-field { grid-column: 1 / -1; }
@media (max-width: 480px) { .grid-form { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: 4px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  font-size: 1rem; font-weight: 600; font-family: inherit;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger-outline { border-color: var(--danger); color: var(--danger); background: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.linklike {
  background: none; border: none; padding: 10px 6px;
  color: var(--accent); font: inherit; cursor: pointer; min-height: 44px;
}
.linklike.danger { color: var(--danger); }

/* auth */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 48px 8px; }
.auth-hero { text-align: center; margin-bottom: 20px; }
.brand-big { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { color: var(--muted); margin: 6px 0 0; }
.auth-card h1 { font-size: 1.2rem; }
.auth-switch { text-align: center; font-size: .9rem; color: var(--muted); }

/* pets grid */
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 14px 0; }
.pet-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; text-decoration: none; color: var(--ink);
}
.pet-card:hover { border-color: var(--accent); }
.pet-avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: 0 0 64px;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; overflow: hidden;
}
.pet-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pet-card h3 { margin: 0; font-size: 1.05rem; }
.pet-card p { margin: 2px 0 0; font-size: .85rem; color: var(--muted); }

/* pet header */
.pet-header { display: flex; gap: 16px; align-items: center; }
.pet-photo {
  width: 84px; height: 84px; border-radius: 50%; flex: 0 0 84px;
  background: var(--accent-soft); overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
}
.pet-photo img { width: 100%; height: 100%; object-fit: cover; }
.pet-meta { min-width: 0; }
.pet-meta p { margin: 0; }
.pet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
@media (max-width: 480px) {
  .pet-header { flex-direction: column; text-align: center; }
  .pet-actions { justify-content: center; }
}

/* upload */
.upload-zone { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
#doc-status-list { margin-top: 8px; }
.doc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
  font-size: .92rem; min-height: 44px;
}
.doc-row a { text-decoration: none; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .03em; flex: 0 0 auto;
}
.chip-pending { background: #F3EEE3; color: #8a7a4d; }
.chip-processing { background: #FDF3E3; color: #a5762a; }
.chip-done { background: var(--accent-soft); color: var(--accent-dark); }
.chip-failed, .chip-rejected { background: var(--danger-soft); color: var(--danger); }
.manual-entry { margin-top: 12px; }
.manual-entry summary { cursor: pointer; color: var(--accent); min-height: 44px; display: flex; align-items: center; }

/* timeline */
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.timeline-head select { width: auto; min-width: 140px; }
.timeline { margin: 12px 0; }
.tl-group-date {
  font-size: .8rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 6px;
}
.tl-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin: 8px 0;
  display: flex; gap: 12px; align-items: flex-start;
}
.tl-icon { font-size: 1.2rem; flex: 0 0 auto; margin-top: 1px; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; }
.tl-sub { font-size: .88rem; color: var(--muted); }
.tl-sub a { color: var(--muted); }
.tl-edited { font-size: .72rem; color: var(--amber); font-weight: 700; text-transform: uppercase; }
.tl-actions { flex: 0 0 auto; display: flex; gap: 2px; }
.tl-actions button { background: none; border: none; cursor: pointer; font-size: .95rem; padding: 8px; min-width: 36px; min-height: 36px; color: var(--muted); }
.lab-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .88rem; }
.lab-table td, .lab-table th { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); }
.lab-flag-high, .lab-flag-low, .lab-flag-abnormal { color: var(--danger); font-weight: 700; }

/* document page */
.doc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .doc-split { grid-template-columns: 1fr; } }
.doc-viewer iframe { width: 100%; height: 70vh; border: none; border-radius: 8px; }
.doc-viewer img { max-width: 100%; border-radius: 8px; }
.extract-section { margin-bottom: 14px; }
.extract-section h3 { margin: 0 0 4px; font-size: .95rem; }
.extract-kv { font-size: .9rem; margin: 2px 0; }
.extract-kv .k { color: var(--muted); }

/* chat */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 420px; padding: 0; overflow: hidden; }
.chat-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.chat-head h1 { font-size: 1.15rem; margin: 0; }
.chat-head p { margin: 2px 0 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 16px; }
.msg { max-width: 85%; margin: 8px 0; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: break-word; }
.msg-user { background: var(--accent); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg-assistant { background: var(--accent-soft); border-bottom-left-radius: 4px; }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.chat-suggestions { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.suggestion {
  text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font: inherit; font-size: .92rem; color: var(--accent-dark);
  cursor: pointer; min-height: 44px;
}
.suggestion:hover { border-color: var(--accent); }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input textarea { flex: 1; margin: 0; max-height: 120px; }
.disclaimer {
  margin: 0; padding: 8px 14px 12px; font-size: .75rem; color: var(--muted); text-align: center;
}
.typing { color: var(--muted); font-style: italic; }

/* emergency management */
.em-link-box {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0;
}
.em-link-box input { flex: 1; min-width: 200px; font-size: .85rem; }

/* emergency public page */
.em-body { background: #fff; }
.em-page { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.em-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.em-brand { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 0; }
.em-header h1 { font-size: 1.7rem; margin: 2px 0; }
.em-allergy {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 10px;
  padding: 12px 14px; font-size: 1.05rem; margin: 14px 0;
}
.em-allergy.none { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }
.em-section { margin: 20px 0; }
.em-section h2 { border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.em-section table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.em-section td, .em-section th { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.em-section tr.flagged td { color: var(--danger); }
.em-section .none { color: var(--muted); }
.em-recent { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.em-recent li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.em-date { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.em-type { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--accent-dark); margin-right: 6px; }
.em-footer { font-size: .78rem; margin-top: 28px; }

/* landing page */
.landing { background: var(--bg); }
.land-nav {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1020px; margin: 0 auto; padding: 14px 20px;
}
.land-hero {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center;
  max-width: 1020px; margin: 0 auto; padding: 28px 20px 40px;
}
.land-hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 16px;
}
.land-hero h1 em { color: var(--accent); font-style: normal; }
.land-sub { font-size: 1.08rem; color: var(--muted); max-width: 34rem; }
.land-cta { margin-top: 22px; }
.land-cta.center { text-align: center; margin-top: 28px; }
.btn-big { font-size: 1.08rem; padding: 14px 26px; }
.land-hero-photo img {
  width: 100%; border-radius: 22px; box-shadow: 0 12px 32px rgba(36,49,59,.18);
  transform: rotate(1.5deg);
}
.photo-cap { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 10px; }
.land-story {
  background: var(--card); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.land-story {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 36px; align-items: center;
  padding: 48px 20px;
}
.land-story > div { max-width: 520px; }
.land-story-photo { justify-self: end; }
.land-story-photo img {
  width: 100%; border-radius: 18px; box-shadow: 0 8px 24px rgba(36,49,59,.15);
  transform: rotate(-1.5deg);
}
.land-story-copy h2 { font-size: 1.6rem; margin-bottom: 12px; }
.land-story-copy p { margin: 0 0 14px; font-size: 1.02rem; }
.land-features { max-width: 1020px; margin: 0 auto; padding: 48px 20px 8px; }
.land-features h2, .land-steps h2 { text-align: center; font-size: 1.5rem; margin-bottom: 24px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { margin: 0; }
.feature-icon { font-size: 1.8rem; margin-bottom: 8px; }
.feature h3 { margin: 0 0 8px; font-size: 1.05rem; }
.feature h3 em { color: var(--accent); font-style: normal; }
.feature p { margin: 0; font-size: .95rem; color: var(--muted); }
.land-steps { max-width: 720px; margin: 0 auto; padding: 40px 20px 56px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-n {
  flex: 0 0 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.land-footer {
  border-top: 1px solid var(--line); text-align: center;
  padding: 28px 20px 40px; color: var(--muted);
}
@media (max-width: 760px) {
  .land-hero { grid-template-columns: 1fr; padding-top: 12px; }
  .land-hero-photo { order: -1; max-width: 420px; margin: 0 auto; }
  .land-story { grid-template-columns: 1fr; }
  .land-story-photo { justify-self: center; max-width: 420px; }
  .feature-grid { grid-template-columns: 1fr; }
}

@media print {
  .noprint { display: none !important; }
  .em-page { padding: 0; max-width: none; }
  body { font-size: 12px; }
}

.story-allpets { color: var(--accent-dark); font-weight: 600; }

/* insurance band on landing */
.land-insurance { max-width: 1020px; margin: 0 auto; padding: 8px 20px 8px; }
.ins-band { display: flex; gap: 20px; align-items: flex-start; background: var(--accent-soft); border-color: var(--accent); padding: 24px; }
.ins-band-icon { font-size: 2.2rem; line-height: 1; }
.ins-band h2 { margin: 0 0 8px; font-size: 1.3rem; }
.ins-band p { margin: 0 0 10px; }
@media (max-width: 600px) { .ins-band { flex-direction: column; gap: 8px; } }

/* vet visit prep */
.vp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.vp-head h2 { margin: 0; }
.vp-content {
  white-space: pre-wrap; font-family: inherit; font-size: .97rem;
  background: var(--accent-soft); border-radius: 10px; padding: 16px; margin-top: 12px;
  overflow-wrap: break-word;
}

/* pet greeting card — the pet says hi, grounded in the record */
.greeting-card { display: flex; gap: 14px; align-items: flex-start; background: var(--accent-soft); }
.greeting-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px;
  background: #fff; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.greeting-avatar img { width: 100%; height: 100%; object-fit: cover; }
.greeting-text { white-space: pre-wrap; font-size: 1.02rem; line-height: 1.6; }
