/*
 * Equine Imaging - phone first, dark, gold, very large targets.
 *
 * The owner likes the current look, so these tokens and layout rules are the
 * existing ones, carried over deliberately rather than redesigned. New screens
 * are built in the same language.
 */

:root {
  color-scheme: dark;
  --bg:    #0b0b0d;
  --fg:    #f4f1ea;
  --muted: #b8b3a8;
  --acc:   #e8c36a;   /* gold - primary action, headings, active state */
  --btn:   #1c1c22;   /* raised surface */
  --ok:    #3dd68c;
  --bad:   #ff6b6b;
  --line:  #2a2a32;
  --inset: #121216;
  --sheet: #16161c;
  --accpanel: #2a2414;
  --danger-bg: #3a1c1c;
  --danger-fg: #ffb4b4;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0 auto;
  max-width: 520px;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select { font-family: inherit; }

button {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

a { color: var(--acc); }

/* ---- top bar ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -16px;
  padding: 10px 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .home {
  background: none;
  border: none;
  color: var(--acc);
  font-weight: 800;
  font-size: 16px;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand img {
  /* The customer's logo, as large as the bar allows and never cropped. */
  height: 52px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: 8px;
}

.brand .name {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 22px;
  display: grid;
  place-items: center;
}

/* ---- blocks ------------------------------------------------------------ */

h1 { font-size: 26px; margin: 18px 0 6px; }
h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 17px; margin: 0 0 6px; }

.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.card {
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin: 12px 0;
}

.card.inset { background: var(--inset); }
.card.accent { background: var(--accpanel); border-color: #4a3f20; }
.card.danger { background: var(--danger-bg); border-color: #522; color: var(--danger-fg); }

.lead { color: var(--acc); font-weight: 800; margin: 0 0 8px; }

.btn {
  display: block;
  width: 100%;
  background: var(--acc);
  color: #111;
  font-weight: 800;
  font-size: 20px;
  border: none;
  border-radius: 18px;
  padding: 18px;
  margin: 12px 0 0;
}

.btn.secondary {
  background: transparent;
  border: 2px solid var(--acc);
  color: var(--acc);
}

.btn.quiet {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 17px;
  font-weight: 600;
  padding: 14px;
}

.btn.danger {
  background: transparent;
  border: 2px solid var(--bad);
  color: var(--bad);
}

.btn.small { font-size: 16px; padding: 12px 14px; width: auto; display: inline-block; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

input[type="text"], input[type="search"], input[type="email"] {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--fg);
  font-size: 18px;
  padding: 14px 16px;
  min-height: 44px;
}

input.big { font-size: 22px; padding: 16px; }

label.field, .field { display: block; margin: 14px 0 0; }
.field input { font-size: 18px; padding: 14px 16px; }
label.field span, .field > span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 6px; }

.status { color: var(--acc); font-size: 15px; margin: 12px 0 0; min-height: 20px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.tiny { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- home ------------------------------------------------------------- */

.mic-wrap { display: grid; place-items: center; margin: 18px 0 8px; }

.mic {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: var(--acc);
  color: #111;
  border: none;
  font-size: 54px;
  box-shadow: 0 10px 30px rgba(232, 195, 106, 0.35);
  display: grid;
  place-items: center;
}

.mic.listening { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 30px rgba(232, 195, 106, 0.35); }
  50% { transform: scale(1.04); box-shadow: 0 14px 44px rgba(232, 195, 106, 0.55); }
}

.mic-hint { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.mic-diag { text-align: center; color: #6f6a60; font-size: 11px; margin: -8px 0 12px; word-break: break-word; }

/* ---- progress --------------------------------------------------------- */

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--inset);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 10px 0 8px;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--acc);
  transition: width 0.4s ease;
}

.totals { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.totals div { font-size: 14px; color: var(--muted); }
.totals b { color: var(--fg); font-size: 16px; display: block; }

.pill {
  display: inline-block;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
}

.pill.attention { background: var(--accpanel); color: var(--acc); border-color: #4a3f20; }

/* ---- lists ------------------------------------------------------------ */

.list { display: grid; gap: 10px; margin: 12px 0; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--fg);
  font-size: 19px;
  font-weight: 700;
}

.list-item .meta { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 500; text-align: right; }
.list-item .barn { color: var(--muted); font-size: 14px; font-weight: 500; }
.list-item.needs { border-color: #4a3f20; }

/* ---- film grid and viewer --------------------------------------------- */

.study { margin: 18px 0 6px; }
.study-head { margin: 0; color: var(--acc); }
.study .grid { margin-top: 6px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

.film {
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  padding: 0;
  display: block;
}

.film img { width: 100%; display: block; }
.film .cap { padding: 8px 10px; font-size: 13px; color: var(--muted); text-align: left; }

.viewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }

.viewer .toolbar {
  position: sticky;
  top: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: calc(26px + env(safe-area-inset-top)) 12px 12px;
  background: rgba(11, 11, 13, 0.94);
  border-bottom: 1px solid var(--line);
}

.viewer .toolbar button {
  background: none;
  border: 1px solid var(--acc);
  color: var(--acc);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
}

.viewer .stage { flex: 1; display: grid; place-items: center; overflow: auto; padding: 10px; touch-action: pan-y pinch-zoom; }
.viewer .stage img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.viewer .stage img { max-width: 100%; height: auto; }
.viewer .cap { text-align: center; color: var(--muted); font-size: 14px; padding: 4px 12px; }

.viewer .nav {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}

.viewer .nav button {
  flex: 1;
  background: var(--btn);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  font-weight: 700;
}

.viewer .nav .pos { color: var(--muted); font-size: 15px; min-width: 76px; text-align: center; }

/* ---- sheets ----------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow: auto;
  background: var(--sheet);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}

.sheet h2 { margin-top: 0; }

.logo-preview {
  width: 112px;
  height: 112px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--inset);
  border: 1px solid var(--line);
}

/* ---- review queue ----------------------------------------------------- */

.review { background: var(--btn); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.review + .review { margin-top: 10px; }
.review .why { color: var(--acc); font-weight: 800; margin-bottom: 4px; }
.review .ctx { color: var(--muted); font-size: 14px; margin-bottom: 10px; word-break: break-word; }
.review img.thumb { width: 100%; max-height: 220px; object-fit: contain; background: #000; border-radius: 12px; margin-bottom: 10px; }

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

.chip {
  background: var(--inset);
  border: 1px solid var(--acc);
  color: var(--acc);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 700;
}

.chip.plain { border-color: var(--line); color: var(--fg); }

footer { margin: 26px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
footer a { color: var(--muted); text-decoration: none; }

.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--sheet);
  border: 1px solid var(--acc);
  color: var(--fg);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  z-index: 80;
  max-width: 92vw;
}

/* Settings: tap-to-open sections. */
.sheet-head {
  position: sticky;
  top: -18px;
  background: var(--sheet, #16161c);
  padding: 4px 0 8px;
  z-index: 2;
}
.sheet-head h2 { margin: 0; }
details.sect {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--inset, #121216);
  margin: 10px 0;
}
details.sect > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  min-height: 44px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}
details.sect > summary::-webkit-details-marker { display: none; }
details.sect > summary::after { content: '▸'; color: var(--acc); transition: transform 0.15s; }
details.sect[open] > summary::after { transform: rotate(90deg); }
details.sect .sect-body { padding: 0 16px 14px; }

/* A horse's films: a labelled line between each date. */
.date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 4px;
  color: var(--acc);
  font-weight: 800;
  font-size: 17px;
}
.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--acc);
  opacity: 0.45;
}
.date-divider::before { flex: 0 0 14px; }

/* Home-screen steps */
.steps { margin: 6px 0 12px 20px; padding: 0; }
.steps li { margin: 5px 0; line-height: 1.4; }

/* Which fits you best */
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.role-choice { display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; font-weight: 700; cursor: pointer; background: var(--inset); }
.role-choice input { position: absolute; opacity: 0; pointer-events: none; }
.role-choice.on { border-color: var(--acc); color: var(--acc); }

/* Top bar: their business name, with ours small underneath */
.brand .titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand .name.biz { font-size: 16px; font-weight: 800; letter-spacing: 0.02em; text-transform: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.brand .app-name { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }

/* ---- deleting: press-and-hold or swipe left, then confirm --------------- */

.list-item, .film {
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.18s ease;
}
.film img { -webkit-user-drag: none; pointer-events: none; }
.list-item.swiping, .film.swiping {
  transition: none;
  box-shadow: inset -6px 0 0 var(--bad);
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.confirm-box {
  width: 100%;
  max-width: 480px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px 12px;
  margin-bottom: env(safe-area-inset-bottom);
}
.confirm-box h3 { margin: 0 0 6px; }
.confirm-box p { margin: 0 0 14px; }
.confirm-box .btn { margin-top: 8px; }

/* Clear space under the last button on a horse's page, so it sits above the
   bottom edge of the screen and the phone's home bar. */
.bottom-room { height: calc(56px + env(safe-area-inset-bottom)); }

/* "N new x-rays - which horse?" at the top of the home screen */
.btn.waiting { margin: 4px 0 14px; }
/* "Find a horse" on a Which horse? card */
.find-horse { width: 100%; margin: 10px 0 2px; padding: 10px 12px; font-size: 16px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--fg); box-sizing: border-box; }

/* First page: "Already set up? Sign in" is a real button, same gold as Sign in with Google */
.btn.already { margin-top: 14px; }
/* First page: no box picked for a new account */
.role-picker.need .role-choice { border: 2px solid var(--acc); }
.need-role { color: var(--acc); font-weight: 800; font-size: 18px; line-height: 1.35; margin: 14px 0 10px; }
