:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #2a2420;
  --text-muted: #746b62;
  --accent: #0B132B;
  --accent-hover: #1C2541;
  --accent-fill: #334376;
  --accent-fill-hover: #3A506B;
  --border: #e4ddd4;
  --success-bg: #e8f3e6;
  --success-text: #2f6b2f;
  --warn-bg: #fbeee6;
  --warn-text: #8a4a1f;
  --cta-green: #16a34a;
  --cta-green-hover: #15803d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1815;
    --surface: #2a2420;
    --text: #f2ece5;
    --text-muted: #b3a89c;
    --accent: #3A506B;
    --accent-hover: #5BC0BE;
    --accent-fill: #3A506B;
    --accent-fill-hover: #5BC0BE;
    --border: #443b33;
    --success-bg: #1f3320;
    --success-text: #8fd18f;
    --warn-bg: #3a2a1c;
    --warn-text: #e0a877;
    --cta-green: #22c55e;
    --cta-green-hover: #16a34a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  padding: 1rem 1rem 0;
  max-width: 480px;
  margin: 0 auto;
}

.update-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid var(--warn-text);
  font-size: 0.9rem;
  text-align: center;
}

/* The browser's own [hidden] rule isn't !important in most engines, so the
   unconditional `display: flex` above would otherwise always win and make
   this banner visible regardless of the hidden attribute - this rule needs
   the higher specificity to actually let JS hide it again. */
.update-banner[hidden] {
  display: none;
}

.update-banner button {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--warn-text);
  border-radius: 6px;
  background: transparent;
  color: var(--warn-text);
  font-weight: 600;
  cursor: pointer;
}

.header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

h1 {
  display: flex;
  align-items: center;
  gap: 0.2em;
  font-size: 1.99rem;
  margin: 0 0 0.15rem;
}

.paw-icon {
  display: inline-block;
  font-size: 1.08em;
}

.app-subtitle {
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.logout-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.logout-link:hover {
  color: var(--accent);
}

nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.6rem 0.4rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.935rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

#site-footer {
  max-width: 480px;
  margin: 1rem auto 2rem;
  padding: 0 1rem;
  text-align: center;
}

#site-footer #show-master-login-link {
  margin: 0;
}

#site-footer #show-master-login-link a {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
  text-decoration: none;
}

#site-footer #show-master-login-link a:hover {
  opacity: 1;
}

#site-footer form,
#site-footer .status-text {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0;
}

#admin-account-label {
  font-size: 1rem;
  font-weight: 700;
}

.hint a {
  color: var(--accent);
}

.divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 1.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* The three section labels on the owner's own "My Dogs" profile page -
   bolded on request so they stand out more than the same .divider style
   used elsewhere (Master tab, How it Works), which stays as-is. */
#email-section-label,
#name-section-label,
#passcode-section-label {
  font-weight: 700;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

input[type="file"] {
  display: block;
  margin-top: 0.3rem;
  width: 100%;
  color: var(--text-muted);
}

input[type="file"][hidden] {
  display: none;
}

.chip-fields {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.chip-fields label {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
}

.chip-fields .label-text {
  display: block;
  line-height: 1.3;
  min-height: 2.6em;
}

.chip-fields input {
  margin-top: auto;
}

.photo-source-buttons {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.photo-source-buttons button {
  flex: 1;
  margin-top: 0;
  font-size: 0.9rem;
}

.secondary-btn {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.secondary-btn:hover {
  background: var(--warn-bg);
}

.danger-btn {
  background: var(--surface);
  color: #b3261e;
  border: 1px solid #b3261e;
}

.danger-btn:hover {
  background: #b3261e;
  color: #fff;
}

/* Create-account is the one conversion action on this screen worth calling
   out - a solid, high-contrast green (vs. the outline style other
   secondary buttons use) so it reads as "go" rather than blending in. */
#show-create-account-link {
  background: var(--cta-green);
  color: white;
  border: none;
}

#show-create-account-link:hover {
  background: var(--cta-green-hover);
}

button {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--accent-fill);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

button:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

button:not(:disabled):hover { background: var(--accent-fill-hover); }

#refresh-messages-btn { width: auto; padding: 0.4rem 0.9rem; font-size: 0.85rem; }

.preview {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  margin: 0.75rem 0;
  object-fit: cover;
}

.preview-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.preview-grid img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.preview-item {
  position: relative;
  cursor: pointer;
}

.preview-item.readonly {
  cursor: default;
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #b3261e;
  color: white;
  font-size: 0.8rem;
  line-height: 20px;
  text-align: center;
}

.no-preview-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.55rem;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.2rem;
}

.result-card {
  margin-top: 1rem;
  padding: 0.9rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.result-card.match { background: var(--success-bg); border-color: var(--success-text); }
.result-card.no-match { background: var(--warn-bg); border-color: var(--warn-text); }

.photo-progress {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.photo-progress.incomplete { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-text); }
.photo-progress.complete { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }

.result-title { font-weight: 700; margin-bottom: 0.25rem; }

.section-title { font-weight: 700; font-size: 1.05rem; margin: 0 0 0.5rem; }
.match .result-title { color: var(--success-text); }
.no-match .result-title { color: var(--warn-text); }

.candidate-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.15rem 0;
}

.result-card.shelter-candidates { background: var(--surface); border-color: var(--border); margin-top: 0.75rem; }
.shelter-candidate-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}
.shelter-candidate-row:first-of-type { border-top: none; }
.shelter-candidate-photo {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.notify-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.message-card {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}

.message-card .dog-name { font-weight: 700; }
.message-card .timestamp { color: var(--text-muted); font-size: 0.75rem; }
.message-card.error { border-color: #b3261e; border-left-width: 4px; }

.status-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }
.status-text.error { color: #b3261e; }
.hint.error { color: #b3261e; }

.found-message-quote {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border);
  background: var(--surface);
  font-style: italic;
  color: var(--text);
}
