:root {
  --ink: #16202c;
  --muted: #5d6b7a;
  --line: #d8e0e8;
  --bg: #f4f7fa;
  --card: #ffffff;
  --accent: #1f6feb;
  --danger: #b4232c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

main { max-width: 960px; margin: 0 auto; padding: 24px 20px 64px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 28px 0 8px; }

#app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: -0.01em; }
.spacer { flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin: 16px 0;
}
.narrow { max-width: 360px; margin: 64px auto; }

label { display: block; margin: 12px 0 4px; font-size: 0.85rem; color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}
textarea { resize: vertical; }
input[type="file"] { padding: 6px; background: none; border: none; }

button {
  padding: 9px 14px;
  font: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.link {
  padding: 4px 2px;
  color: var(--accent);
  background: none;
  font-weight: 400;
}
button.primary { margin-top: 12px; }
#login-submit { width: 100%; margin-top: 20px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.row-start { display: flex; align-items: center; gap: 12px; }
.inline-form { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; margin: 10px 0 0; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.list li .grow { flex: 1; }

.tag {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 999px;
  background: #eaf1fb;
  color: var(--accent);
}

.tabs { display: flex; gap: 6px; margin: 8px 0 14px; }
.tab { background: #e7edf4; color: var(--muted); }
.tab.active { background: var(--accent); color: #fff; }

#pad {
  width: 100%;
  height: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;   /* let Pointer Events own the gesture, or the browser scrolls instead */
  cursor: crosshair;
}

/* --- records navigator --- */

.navigator {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-top: 8px;
}
/* The navigator takes focus so the arrow keys can drive it, so it has to be able to show
   that it has focus. */
.navigator:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.record-page { margin: 0; }
.record-caption { margin-bottom: 8px; font-size: 0.9rem; color: var(--muted); }
.record-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
.record-body img { max-width: 100%; max-height: 58vh; object-fit: contain; }
.record-text { margin: 0; align-self: flex-start; white-space: pre-wrap; }
.record-unavailable { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* The fullscreen backdrop is black by default, which frames a scanned page in the way that
   makes it hardest to read — the opposite of the reason to go fullscreen. */
#records-navigator:fullscreen,
#record-page:fullscreen {
  background: var(--card);
  padding: 20px;
  overflow: auto;
}
#record-page:fullscreen { display: flex; flex-direction: column; }
#record-page:fullscreen .record-body { flex: 1; }
#records-navigator:fullscreen .record-body img,
#record-page:fullscreen .record-body img { max-height: none; }

.navigator-controls { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
/* tabular-nums so the position label doesn't shift the buttons sideways as it counts up. */
.position { min-width: 70px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.thumbs img, .rx-image {
  max-width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rx-image { max-width: 100%; display: block; margin-top: 6px; }
/* fit-content so the row-end under the preview aligns to the picture's own right edge
   rather than the full panel width, which left the link stranded across the page. */
#photo-preview-wrap { width: fit-content; }
#photo-preview { max-height: 260px; width: auto; }
.rx-text { margin: 6px 0 0; white-space: pre-wrap; }
