/* IPSRM Field: visual design (SPEC.md Section 11). Light appearance only in version 1.
   Designed for iPad first; works from phone to desktop. */

/* ---------------------------------------------------------------------------
   Fonts, packaged with the app (app/fonts). Latin Extended loads only when needed.
   --------------------------------------------------------------------------- */

@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/fraunces-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------------------------------------------------------------------------
   Brand tokens. Contrast on white checked against WCAG 2.2 AA:
   navy 15.4:1, steel 10.5:1, muted 7.6:1, dark gold 5.3:1.
   Brand gold (#A97C34, 3.7:1) is used only for borders, rules and large text.
   --------------------------------------------------------------------------- */

:root {
  --navy: #0B2545;
  --steel: #17416B;
  --gold: #A97C34;
  --gold-on-navy: #D4AF6A;
  --gold-text: #8A6424;       /* for small gold text on white */
  --pale: #F3F4F6;            /* alternate panels */
  --line: #D1D5DB;
  --text: #1A1F2B;
  --muted: #4B5563;
  --white: #FFFFFF;

  --tier1: #B42318;           /* red */
  --tier2: #8A6424;           /* gold */
  --tier3: #1E7B45;           /* green */

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --gutter: 24px;
  --measure: 880px;           /* comfortable reading width on iPad */
  --touch: 44px;              /* minimum touch target */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Keep the focused control clear of the sticky top bar (at most 64 px, more under an iPhone's notch) and the
   Capture button (56 px, 16 px from the edge, more above the home indicator). WCAG 2.2, 2.4.11 (SPEC 1.39). */
html { scroll-padding-top: calc(72px + env(safe-area-inset-top, 0px)); scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--navy); line-height: 1.2; margin: 0; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 12px; }
a { color: var(--steel); }

.label, .meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.label { text-transform: uppercase; letter-spacing: 0.06em; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   Buttons: outline, sharp corners, Fraunces. Never filled, never pill-shaped.
   --------------------------------------------------------------------------- */

.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 8px 18px;
  background: transparent; color: var(--navy);
  border: 1.5px solid var(--navy); border-radius: 0;
  font: 600 1rem/1.2 var(--serif); text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.button:hover, button:hover { background: var(--pale); }
.button:active, button:active { background: #E5E7EB; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
/* Back and Next at the foot of each engagement step (SPEC.md 1.73): the existing buttons, together, on the right. */
.step-nav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 40px; }
.button.quiet, button.quiet { border-color: var(--line); color: var(--steel); }
.button.danger, button.danger { border-color: var(--tier1); color: var(--tier1); }
.button.small, button.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px; padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--navy); color: var(--white);
}
.topbar .back {
  color: var(--gold-on-navy); border-color: var(--gold-on-navy);
  min-height: var(--touch);
}
.topbar .back:hover { background: rgba(255, 255, 255, 0.08); }
.topbar .where { flex: 1; min-width: 0; }
.topbar .where .app-name { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--white); }
.topbar .where .context { display: block; font-family: var(--mono); font-size: 0.8rem; color: var(--gold-on-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The protective marking of a marked engagement (SPEC.md Section 9.1, point 2) */
.marking-bar {
  padding: 6px var(--gutter); padding-top: max(6px, env(safe-area-inset-top));
  background: var(--white); color: var(--navy); border-bottom: 2px solid var(--navy);
  font-family: var(--mono); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.08em; text-align: center; text-transform: uppercase;
}
.marking-bar[hidden] { display: none; }
.marking-bar:not([hidden]) + .topbar { padding-top: 8px; }
.marking-label { margin: 4px 0 0; font-family: var(--mono); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy); }
.save-status { font-family: var(--mono); font-size: 0.8rem; color: var(--gold-on-navy); white-space: nowrap; }
.save-status.problem { color: #FFB4AB; }

main.view { max-width: var(--measure); margin: 0 auto; padding: 24px var(--gutter) 96px; padding-bottom: calc(56px + max(16px, env(safe-area-inset-bottom)) + 32px); } /* clear of the Capture button */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 24px; }
.page-head p { margin: 4px 0 0; }

/* ---------------------------------------------------------------------------
   Start screen
   --------------------------------------------------------------------------- */

.start {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 48px var(--gutter);
  background: var(--navy); color: var(--white);
}
.start .rule { width: 72px; height: 2px; background: var(--gold); margin: 24px auto; }
.start h1 { color: var(--white); font-size: 3rem; font-weight: 600; letter-spacing: 0.01em; }
.start .credit { font-family: var(--mono); color: var(--gold-on-navy); font-size: 0.95rem; letter-spacing: 0.08em; margin-top: 8px; }
.start .tagline { max-width: 32em; color: #D8DEE9; margin: 0 auto 32px; }
.start .button { color: var(--gold-on-navy); border-color: var(--gold-on-navy); min-width: 220px; }
.start .button:hover { background: rgba(255, 255, 255, 0.08); }
/* A real <button> on the navy start screen (the Ardmore demo's): iPhones keep the hover look after a tap, which the general button:hover and :active turned pale grey behind white text (SPEC 1.38). */
.start button:hover, .start button:active { background: rgba(255, 255, 255, 0.08); }
.start .methodology { font-family: var(--mono); font-size: 0.75rem; color: #AAB4C4; margin-top: 48px; }
/* SPEC 1.65: the message when the storage is slow to answer, beneath the title on the navy start screen. */
.start .storage-slow { max-width: 32em; color: #D8DEE9; margin: 32px auto 0; }
.start .storage-slow a { color: inherit; }

/* ---------------------------------------------------------------------------
   Lists and cards
   --------------------------------------------------------------------------- */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start;
  padding: 18px 20px; border: 1px solid var(--line); border-left: 3px solid var(--gold); background: var(--white);
}
.cards > .card:nth-child(even) { background: var(--pale); }
.card h3 { font-size: 1.15rem; }
.card .open { text-decoration: none; color: inherit; }
.card .open:hover h3 { text-decoration: underline; }
.card .facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.card.archived { border-left-color: var(--line); }

.badge {
  display: inline-block; padding: 2px 8px; border: 1px solid currentColor;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.badge.demo { color: var(--steel); }
.badge.copy { color: var(--steel); }
.badge.warn { color: var(--tier1); }

.empty { padding: 32px; text-align: center; border: 1px dashed var(--line); color: var(--muted); }

details.section-toggle { margin-top: 32px; }
details.section-toggle > summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; font-family: var(--serif); font-weight: 600; color: var(--navy); }

/* Engagement home: the sections of an engagement */
.sections { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); list-style: none; margin: 0; padding: 0; }
.section-link {
  display: block; min-height: 110px; padding: 18px 20px; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-top: 3px solid var(--navy);
}
.section-link:hover { background: var(--pale); }
.section-link.later { border-top-color: var(--line); color: var(--muted); pointer-events: none; }
.section-link.later h3 { color: var(--muted); }

/* ---------------------------------------------------------------------------
   Forms: large, touch-friendly, dictation-friendly
   --------------------------------------------------------------------------- */

.form-group { margin: 0 0 40px; }
.form-group > h2 { padding-bottom: 8px; border-bottom: 2px solid var(--gold); margin-bottom: 20px; }
.form-group > .group-note { color: var(--muted); margin: -8px 0 20px; }

.field { margin: 0 0 22px; }
.field label, .field .field-label { display: block; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.field .hint { display: block; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
/* The firm's logo in Settings › Practitioner and firm: a small preview, and its buttons. */
.logo-preview { margin: 0 0 8px; }
.logo-preview img { display: block; max-width: 200px; max-height: 80px; border: 1px solid var(--line); background: #FFFFFF; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.field .logo-actions label.button { display: inline-flex; margin-bottom: 0; color: var(--steel); }

input[type="text"], input[type="password"], input[type="date"], textarea, select {
  width: 100%; min-height: var(--touch); padding: 10px 12px;
  font: 400 1rem/1.5 var(--sans); color: var(--text);
  background: var(--white); border: 1px solid #9CA3AF; border-radius: 0;
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 120px; resize: vertical; overflow: hidden; }
textarea.short { min-height: 72px; }
input:focus, textarea:focus, select:focus { border-color: var(--navy); outline: 3px solid var(--gold); outline-offset: 0; }

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

/* Document control rows */
.rows { display: grid; gap: 12px; margin-bottom: 12px; }
.row-item { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: end; padding: 12px; background: var(--pale); }
.row-item .remove { grid-column: 1 / -1; justify-self: end; }
.row-item label { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); display: block; margin-bottom: 2px; }

/* ---------------------------------------------------------------------------
   Dialogs
   --------------------------------------------------------------------------- */

dialog {
  max-width: min(520px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--navy); border-top: 4px solid var(--gold);
  color: var(--text); background: var(--white);
}
dialog::backdrop { background: rgba(11, 37, 69, 0.55); }
dialog h2 { margin-bottom: 12px; }
dialog .dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 24px; }

.notice { padding: 12px 16px; border-left: 4px solid var(--steel); background: var(--pale); margin: 0 0 20px; }
.notice.problem { border-left-color: var(--tier1); }

/* ---------------------------------------------------------------------------
   Tiers: always shown by label as well as colour (SPEC.md Section 12)
   --------------------------------------------------------------------------- */

.tier { display: inline-block; padding: 2px 10px; color: var(--white); font-family: var(--mono); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.04em; }
.tier-1 { background: var(--tier1); }
.tier-2 { background: var(--tier2); }
.tier-3 { background: var(--tier3); }

/* ---------------------------------------------------------------------------
   Smaller screens
   --------------------------------------------------------------------------- */

@media (max-width: 700px) {
  :root { --gutter: 16px; }
  h1 { font-size: 1.6rem; }
  .start h1 { font-size: 2.3rem; }
  .two-up { grid-template-columns: 1fr; }
  .row-item { grid-template-columns: 1fr; }
  .row-item .remove { justify-self: start; }
  .card { grid-template-columns: 1fr; }
  .card .actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

main.view:focus { outline: none; }

/* ---------------------------------------------------------------------------
   Guidance text, domains and findings (Session B)
   --------------------------------------------------------------------------- */

select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%230B2545' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}

.guidance { padding: 16px 20px; margin: 0 0 32px; background: var(--pale); border-left: 3px solid var(--gold); }
.guidance p:last-child { margin-bottom: 0; }
.core-question { font-family: var(--serif); font-style: normal; font-weight: 600; color: var(--navy); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }

.tier-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }

.domain-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.domain-card { display: block; height: 100%; padding: 18px 20px; text-decoration: none; color: inherit; border: 1px solid var(--line); border-top: 3px solid var(--navy); }
.domain-card:hover { background: var(--pale); }
.domain-card h3 { font-size: 1.2rem; margin: 2px 0 4px; }
.status.attention { color: var(--tier1); }

.finding-list { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--line); }
.finding-row {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: center;
  min-height: 60px; padding: 12px 8px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line);
}
.finding-row:hover { background: var(--pale); }
.finding-row .ref, .evidence-list .ref { font-family: var(--mono); font-weight: 500; color: var(--navy); }
.finding-row .summary { min-width: 0; overflow-wrap: anywhere; } /* long unbroken text wraps, never widens the page */
.finding-row.context { background: #FAF7F0; }
.state { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; white-space: nowrap; }
.state.attention { color: var(--tier1); border-color: var(--tier1); }
.state.context { color: var(--gold-text); border-color: var(--gold); }

/* Finding card */
.finding-card .page-head h1 { font-family: var(--mono); font-weight: 500; font-size: 2rem; letter-spacing: 0.02em; }
.context-flag { display: inline-block; margin-top: 8px; padding: 4px 10px; border: 1.5px solid var(--gold); color: var(--gold-text); font-family: var(--mono); font-size: 0.85rem; }

.rating-area { margin: 0 0 24px; }
.rating-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating-option {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 72px; padding: 8px 4px; border: 1.5px solid var(--line); color: var(--navy); background: var(--white);
}
.rating-option .value { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1; }
.rating-option .rating-label { font-family: var(--sans); font-weight: 500; font-size: 0.82rem; text-align: center; }
.rating-option.selected { border: 3px solid var(--navy); background: #E8EDF4; }
.rating-option.selected .value::after { content: " \2713"; font-size: 0.9rem; }

.score-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 32px; margin: 8px 0 28px; padding: 18px 20px; border: 1px solid var(--line); border-left: 6px solid var(--line); background: var(--pale); }
.score-panel.tier-edge-1 { border-left-color: var(--tier1); }
.score-panel.tier-edge-2 { border-left-color: var(--tier2); }
.score-panel.tier-edge-3 { border-left-color: var(--tier3); }
.score { display: flex; flex-direction: column; }
.score-value { font-family: var(--serif); font-weight: 600; font-size: 3rem; line-height: 1; color: var(--navy); }
.score-tier { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.tier-large { font-size: 1rem; padding: 4px 14px; }
.tier-name { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--navy); }
.score-waiting { margin: 0; color: var(--muted); }
.score-tier .notice { margin: 4px 0 0; }

.history { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.history h3 { margin-bottom: 8px; }
.history-list { margin: 0 0 8px; padding-left: 24px; }
.history-list li { margin-bottom: 12px; }
.history-list p { margin: 0 0 2px; }

.chips { list-style: none; margin: -8px 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--steel); font-family: var(--mono); }
.chip a { padding: 6px 10px; text-decoration: none; color: var(--steel); min-height: 36px; display: inline-flex; align-items: center; }
.chip-remove { min-height: 36px; min-width: 36px; padding: 0; border: 0; border-left: 1px solid var(--steel); color: var(--steel); font-size: 1.1rem; }
.link-add select { max-width: 100%; }

.field.include { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.field.include input { width: 28px; height: 28px; margin: 0; accent-color: var(--navy); }
.field.include label { margin: 0; }
.field.include .hint { grid-column: 2; margin: 0; }

.evidence-list { list-style: none; margin: 0 0 8px; padding: 0; }
/* Linked evidence on the finding card: the reference and its type on the first line, the description
   across the full width beneath, Unlink on the right below that; a photo's thumbnail in a column of its
   own on the left. Text never sits in a narrow column, and nothing scrolls sideways. */
.evidence-list li { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.evidence-list li.has-photo { grid-template-columns: 64px minmax(0, 1fr); }
.evidence-list .ev-thumb { display: block; line-height: 0; }
.evidence-list .ev-thumb .mini-thumb { width: 64px; height: 48px; object-fit: cover; border: 1px solid var(--line); }
.evidence-list .ev-body { min-width: 0; }
.evidence-list .ev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; margin: 0; }
.evidence-list .ev-head .ref { display: inline-flex; align-items: center; min-height: var(--touch); text-decoration: none; }
.evidence-list .ev-text { margin: 2px 0 0; overflow-wrap: anywhere; }
.evidence-list .ev-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.evidence-list .unlink { min-height: var(--touch); }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 2px solid var(--gold); }
.domain-picker { display: flex; flex-wrap: wrap; gap: 8px; }

/* Definitions and Recording Discipline dialogs */
dialog.wide { max-width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; }
.scale-list { list-style: none; margin: 0; padding: 0; }
.scale-list li { padding: 14px 0; border-top: 1px solid var(--line); }
.scale-list li.current { background: #E8EDF4; padding-left: 12px; padding-right: 12px; }
.scale-list h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.scale-list p { margin: 0 0 4px; }
.scale-list .note { color: var(--muted); }
.principles li { margin-bottom: 10px; }

@media (max-width: 700px) {
  .rating { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .rating-option { min-height: 64px; }
  .rating-option .rating-label { font-size: 0.7rem; }
  .finding-row { grid-template-columns: 64px 1fr; }
  .finding-row > :last-child { grid-column: 2; justify-self: start; }
  .evidence-list li.has-photo { grid-template-columns: 56px minmax(0, 1fr); }
  .evidence-list .ev-thumb .mini-thumb { width: 56px; height: 42px; }
}
.tier.zero { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------------------------------------------------------------------------
   Dashboard
   --------------------------------------------------------------------------- */

.dash-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 0 0 20px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 12px; border: 1px solid var(--line); border-top: 3px solid var(--navy); background: var(--white); }
.stat-value { font-family: var(--serif); font-weight: 600; font-size: 2.2rem; line-height: 1.1; color: var(--navy); }
.tier-stat.tier-edge-1 { border-top-color: var(--tier1); }
.tier-stat.tier-edge-2 { border-top-color: var(--tier2); }
.tier-stat.tier-edge-3 { border-top-color: var(--tier3); }
.tier-stat .meta { font-size: 0.72rem; }

.heatmap { display: grid; grid-template-columns: 28px 1fr; grid-template-rows: 1fr auto; gap: 6px; max-width: 560px; }
.axis-y { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.axis-x { grid-column: 2; text-align: center; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.grid { display: grid; grid-template-columns: 24px repeat(5, 1fr); gap: 4px; }
.row-label, .col-label { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-weight: 500; color: var(--navy); }
.cell { position: relative; aspect-ratio: 1; min-height: 52px; padding: 0; border: 0; display: flex; align-items: center; justify-content: center; }
.cell.tier-cell-1 { background: #FBEAE8; color: var(--tier1); }
.cell.tier-cell-2 { background: #F8F2E6; color: var(--tier2); }
.cell.tier-cell-3 { background: #E9F5ED; color: var(--tier3); }
.cell.has.tier-cell-1 { background: var(--tier1); color: var(--white); }
.cell.has.tier-cell-2 { background: var(--tier2); color: var(--white); }
.cell.has.tier-cell-3 { background: var(--tier3); color: var(--white); }
.cell:hover { filter: brightness(0.95); }
.cell.selected { outline: 3px solid var(--navy); outline-offset: 2px; }
.cell .count { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; }
.cell .cell-tier { position: absolute; right: 5px; bottom: 3px; font-family: var(--mono); font-size: 0.62rem; }
.legend { margin: 12px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cell-list { margin-top: 12px; }
.cell-list h3 { margin-bottom: 8px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-family: var(--mono); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 2px solid var(--navy); }
table.data tbody tr:nth-child(even) { background: var(--pale); }
table.data tfoot th, table.data tfoot td { font-weight: 600; border-top: 2px solid var(--navy); border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .ref { font-family: var(--mono); white-space: nowrap; }
table.data th[scope="row"] { font-weight: 500; }
.tie-note { margin-top: 8px; }

.position-suggested, .position-chosen { display: inline-block; vertical-align: top; min-width: 240px; max-width: 100%; margin: 0 16px 16px 0; padding: 14px 18px; border: 1px solid var(--line); }
.position-suggested { border-top: 3px solid var(--gold); }
.position-chosen { border-top: 3px solid var(--navy); }
.position-chosen.suggestion-changed, .position-chosen.missing-reason, .position-chosen.unconfirmed { border-top-color: var(--tier1); }
.position-value { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; color: var(--navy); margin: 2px 0 6px; letter-spacing: 0.04em; }
.position-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 16px; }
.position-form { padding: 16px; border: 1.5px solid var(--gold); margin-bottom: 16px; }
.position-form fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.position-form legend { font-weight: 600; color: var(--navy); margin-bottom: 8px; }
/* D1-01's Site context (SPEC.md 1.47): the verified choice, as the position form's. */
.site-context fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.site-context legend { font-weight: 600; color: var(--navy); margin-bottom: 8px; }
.radio { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); margin-right: 24px; font-family: var(--serif); font-weight: 600; color: var(--navy); }
.radio input { width: 22px; height: 22px; accent-color: var(--navy); }

@media (max-width: 700px) {
  .dash-summary { grid-template-columns: repeat(2, 1fr); }
  .dash-summary .stat:first-child { grid-column: 1 / -1; }
  .cell { min-height: 44px; }
  .position-suggested, .position-chosen { display: block; margin-right: 0; }
}

/* ---------------------------------------------------------------------------
   Evidence Register
   --------------------------------------------------------------------------- */

.location-switch { padding: 14px 18px; margin: 0 0 28px; border: 1px solid var(--line); border-left: 3px solid var(--gold); background: var(--pale); }
.location-switch .field { margin: 0; }
.location-switch .meta { grid-column: 2; }

.evidence-register { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.evidence-row {
  display: grid; grid-template-columns: 64px 64px 1fr; gap: 12px; align-items: center;
  min-height: 72px; padding: 10px 8px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line);
}
.evidence-row:hover { background: var(--pale); }
.evidence-row .ref { font-family: var(--mono); font-weight: 500; color: var(--navy); }
.thumb { width: 64px; height: 48px; object-fit: cover; border: 1px solid var(--line); background: var(--pale); }
.thumb.none { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.ev-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-type { color: var(--steel); }
.ev-desc { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }

.evidence-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.evidence-actions select { max-width: 100%; flex: 1 1 260px; }

.evidence-photo { display: block; max-width: 100%; max-height: 70vh; margin: 0 0 16px; border: 1px solid var(--line); }
.photo-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.photo-facts dt { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.photo-facts dd { margin: 0; }

@media (max-width: 700px) {
  .evidence-row { grid-template-columns: 56px 1fr; }
  .evidence-row .ref { grid-row: 1; grid-column: 2; }
  .evidence-row .thumb { grid-row: 1 / span 2; }
  .evidence-row .ev-main { grid-column: 2; }
  .photo-facts { grid-template-columns: 1fr; gap: 0 0; }
  .photo-facts dd { margin-bottom: 8px; }
}

/* ---------------------------------------------------------------------------
   Photo capture
   --------------------------------------------------------------------------- */

.photo-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.photo-buttons .button { margin: 0; }
.busy { pointer-events: none; opacity: 0.55; }
.photo-status { margin: 8px 0 0; }
.size-summary { margin: -8px 0 20px; }
.size-summary.over { color: var(--tier1); }
.evidence-photo { cursor: zoom-in; }
.viewer img { display: block; max-width: 100%; max-height: calc(100vh - 200px); margin: 0 auto; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.photo-open { display: block; min-height: 0; padding: 0; margin: 0 0 16px; border: 0; background: none; cursor: zoom-in; }
.photo-open:hover { background: none; }
.photo-open .evidence-photo { margin: 0; }

/* Backups (Session 7c) */
.backup-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 12px 0; }
.backup-choice { padding: 14px 16px; border: 1px solid var(--line); border-top: 3px solid var(--navy); }
.backup-choice .meta { margin: 8px 0 0; }
.fingerprint-code { font-family: var(--mono); font-weight: 500; color: var(--navy); letter-spacing: 0.06em; }
@media (max-width: 700px) { .backup-buttons { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------------
   App lock (SPEC.md Section 9.1, point 3): the unlock screen and switching progress
   --------------------------------------------------------------------------- */

main.unlock {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px var(--gutter); background: var(--navy);
}
main.unlock .panel, .lock-progress .panel {
  width: 100%; max-width: 480px; padding: 28px; background: var(--white); border-top: 4px solid var(--gold);
}
main.unlock h1 { margin: 4px 0 12px; }
main.unlock form button { width: 100%; }
main.unlock details.forgotten { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }
main.unlock details.forgotten summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; color: var(--navy); font-weight: 600; }

.lock-progress {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: var(--gutter); background: rgba(11, 37, 69, 0.85);
}
.lock-progress h2 { margin-bottom: 16px; }
.lock-progress progress { width: 100%; height: 16px; accent-color: var(--navy); }
.lock-progress .notice { margin: 16px 0 0; }

/* The cover (while hidden with the lock on, and the privacy screen), and the Lock button (Session 8c).
   The cover is a dialog, so it sits above everything, including any open dialog. */
dialog.privacy-cover {
  position: fixed; inset: 0; margin: 0; padding: 0; border: 0;
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  background: var(--navy); cursor: pointer;
}
dialog.privacy-cover[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
dialog.privacy-cover::backdrop { background: var(--navy); }
.privacy-cover .app-name { font-family: var(--serif); font-weight: 600; font-size: 2rem; color: var(--white); margin: 0; }
.privacy-cover .tap-hint { font-family: var(--mono); font-size: 0.85rem; color: var(--gold-on-navy); margin: 0; }
.topbar .lock-button { color: var(--gold-on-navy); border-color: var(--gold-on-navy); min-height: var(--touch); }
.topbar .lock-button:hover { background: rgba(255, 255, 255, 0.08); }

/* "Update available" (SPEC.md Section 10) */
.update-notice {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  width: min(560px, calc(100vw - 32px)); padding: 14px 16px;
  background: var(--white); border: 1px solid var(--navy); border-top: 4px solid var(--gold); box-shadow: 0 6px 24px rgba(11, 37, 69, 0.25);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
}
.update-notice p { margin: 0; flex: 1 1 260px; }
.update-notice .actions { display: flex; gap: 8px; }

/* A photo this browser cannot show (for example HEIC in Chrome or Edge on Windows) */
.picture-unavailable {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  padding: 8px; background: var(--pale); border: 1px dashed var(--line);
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
}
.picture-unavailable.thumb, .picture-unavailable.mini-thumb { font-size: 0.6rem; padding: 2px; line-height: 1.1; }

/* Executive Summary (SPEC.md Section 4.5) */
.es-facts { margin: 0 0 8px; padding: 6px 10px; background: var(--pale); font-family: var(--mono); font-size: 0.8rem; color: var(--navy); }
.badge.empty-badge { color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.empty-badge[hidden] { display: none; }
.es-field .ref-check { margin: 8px 0 0; }

/* Pre-report check (SPEC.md Section 4.6) */
.check-summary { font-weight: 600; color: var(--navy); }
.check-summary.attention { color: var(--tier1); }
.check-line { margin: 0 0 20px; }
.check-group { border: 1px solid var(--line); border-left: 4px solid var(--steel); margin: 0 0 12px; background: var(--white); }
.check-group.attention { border-left-color: var(--tier1); }
.check-group > summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-weight: 600; color: var(--navy); }
.check-items { margin: 0; padding: 0 14px 12px 34px; }
.check-items li { margin: 6px 0; }
.field-target { outline: 3px solid var(--gold); outline-offset: 6px; transition: outline-color 0.4s; }

/* ---------------------------------------------------------------------------
   Quick Capture (SPEC.md Section 4.2, and version 1.22)
   --------------------------------------------------------------------------- */

/* The Capture button: on every engagement screen, within thumb reach. Outline style, like every button. */
.capture-button {
  position: fixed; z-index: 20;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 56px; padding: 10px 22px;
  background: var(--white); border-width: 2px; font-size: 1.1rem;
  box-shadow: 0 2px 10px rgba(11, 37, 69, 0.25);
}
.capture-button:hover { background: var(--pale); }
.domain-picker button[aria-pressed="true"] { background: var(--pale); color: var(--navy); border: 2px solid var(--gold); font-weight: 700; }
.capture-domain-line { margin: 0 0 8px; }
.capture-photos { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.capture-photos li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.capture-photos img { width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--line); }
.capture-done .actions { flex-wrap: wrap; }
.captured-list { list-style: none; margin: 16px 0 0; padding: 0; }
.finding-row.captured { grid-template-columns: 64px 88px 1fr; align-items: center; }
.finding-row .thumb { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--line); background: var(--pale); display: block; }
.finding-row .thumb.none { display: flex; align-items: center; justify-content: center; text-align: center; }
.badge.captured { color: var(--gold-text); }
@media (max-width: 560px) {
  .finding-row.captured { grid-template-columns: 56px 1fr; }
  .finding-row.captured .summary { grid-column: 1 / -1; }
  .finding-row .thumb { width: 56px; height: 56px; }
}

/* Settings (Session 15): the contents list and plain lists. */
.settings-contents ul { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.settings-contents a { font-family: var(--mono); font-size: 0.85rem; }
.plain-list { margin: 0 0 12px; padding-left: 1.2em; }
.plain-list li { margin: 4px 0; }

/* Demo mode (SPEC.md 8.1 and 1.26): the band on every screen, the start-screen panel and the licensing link. */
.demo-band { margin: 0; padding: 6px var(--gutter); background: var(--pale); color: var(--navy); border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 0.8rem; text-align: center; }
.start .demo-panel { max-width: 34rem; margin: 8px auto 0; padding: 16px 20px; border: 1.5px solid var(--gold-on-navy); text-align: left; }
.start .demo-panel h2 { color: var(--white); font-size: 1.2rem; margin: 0 0 8px; }
.start .demo-panel p { margin: 0 0 12px; }
.start .demo-panel .demo-photos-note { font-style: italic; }
.start .demo-panel .button, .start .demo-panel button { color: var(--white); border-color: var(--gold-on-navy); }
.start .licensing-link a, .demo-blocked a { color: inherit; }
.start .licensing-link { margin: 12px 0 0; }
/* Each link stays whole: on a phone, "Have a licence key? Enter it here" moves onto its own line (SPEC 1.44). */
.start .licensing-link a { white-space: nowrap; }

/* Settings › Security and data (SPEC.md 1.31) */
.security-statement h3 { font-size: 1rem; margin: 18px 0 6px; }
.security-statement .statement-list { margin: 0 0 8px; padding-left: 1.2rem; }
.security-statement .statement-list li { margin-bottom: 6px; }

/* Framework references on the finding card (SPEC.md 1.48) */
.framework-ref-list { list-style: none; margin: 0 0 12px; padding: 0; }
.framework-ref { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.framework-ref .relates { font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--steel); }
.framework-ref .meta { flex-basis: 100%; margin: 0; }
.framework-add { margin: 12px 0; padding: 12px 16px; border-left: 3px solid var(--gold); background: var(--pale); }
.clause-results { list-style: none; margin: 8px 0 12px; padding: 0; max-height: 24rem; overflow-y: auto; }
.clause-results li + li { margin-top: 6px; }
.clause-option { width: 100%; justify-content: flex-start; text-align: left; font-family: var(--sans); font-size: 0.95rem; min-height: 44px; }
.framework-choices { border: 0; margin: 0; padding: 0; }

/* The Estate view (SPEC.md 1.66). On iPad the table fits as it is; on a phone each row reads as a short
   list, each value under its column's name. The table keeps its roles, so it is still read as a table. */
.estate-view .block { display: block; }
.estate-view .estate-summary { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; color: var(--navy); margin: 0 0 16px; padding: 12px 16px; border-left: 3px solid var(--gold); background: var(--pale); }
.estate-table .num .tier { min-width: 2.2em; text-align: center; }
.estate-table tr.unavailable th, .estate-table tr.unavailable td { color: var(--muted); }
.estate-table .unavailable-note p { margin: 0 0 6px; }
.estate-view .members { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
@media (max-width: 700px) {
  .estate-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  .estate-table, .estate-table tbody, .estate-table tr, .estate-table th, .estate-table td { display: block; width: 100%; }
  .estate-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .estate-table th, .estate-table td { border-bottom: 0; padding: 4px 8px; }
  .estate-table td[data-label] { display: grid; grid-template-columns: minmax(8.5rem, 40%) 1fr; gap: 8px; text-align: left; }
  .estate-table td[data-label]::before { content: attr(data-label); font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  .estate-table th[scope="row"] { font-size: 1.05rem; }
}
