/* ==========================================================================
   Priority Matrix Management
   A single stylesheet. No external fonts, no imports, no remote assets.
   ========================================================================== */

/* --------------------------------------------------------------- tokens -- */

:root {
  color-scheme: light dark;

  --bg: #e9eef3;
  --surface: #fefefe;
  --surface-2: #f1f6fd;
  --surface-3: #e8eef7;
  --border: #cbd5e6;
  --border-strong: #b0bdd2;
  --text: #172029;
  --muted: #55636f;
  --accent: #174a74;
  --accent-strong: #2a6aa0;
  --accent-text: #ffffff;
  --focus: #0b62d0;

  --p1: #b3261e;
  --p2: #8a4b00;
  --p3: #1a5fb4;
  --p4: #4b5563;
  --p1-tint: #fdeceb;
  --p2-tint: #fdf1e3;
  --p3-tint: #eaf1fb;
  --p4-tint: #eef0f3;

  --up: #8a4b00;
  --down: #256d4a;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(16, 26, 38, 0.08), 0 1px 0 rgba(16, 26, 38, 0.04);
  --shadow-strong: 0 8px 24px rgba(16, 26, 38, 0.12), 0 1px 0 rgba(16, 26, 38, 0.06);
  --max-width: 1200px;
  --max-read: 65ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131b26;
    --surface: #1e2d42;
    --surface-2: #2a3d56;
    --surface-3: #324a68;
    --border: #344862;
    --border-strong: #4a6380;
    --text: #e8edf3;
    --muted: #c2d0e0;
    --accent: #7fb2e5;
    --accent-strong: #6ab0f3;
    --accent-text: #0d1319;
    --focus: #7fb2e5;

    --p1: #ff9a90;
    --p2: #f0b072;
    --p3: #93c2f5;
    --p4: #b3bec9;
    --p1-tint: #3a2523;
    --p2-tint: #3a2e1e;
    --p3-tint: #1e324a;
    --p4-tint: #262d36;

    --up: #f0b072;
    --down: #7fd3aa;

    --shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.05);
    --shadow-strong: 0 16px 40px rgba(0, 0, 0, 0.48), 0 1px 0 rgba(255, 255, 255, 0.06);
  }
}

/* Manual override via data-theme — duplicates tokens for explicit switch */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #e9eef3;
  --surface: #fefefe;
  --surface-2: #f1f6fd;
  --surface-3: #e8eef7;
  --border: #cbd5e6;
  --border-strong: #b0bdd2;
  --text: #172029;
  --muted: #55636f;
  --accent: #174a74;
  --accent-strong: #2a6aa0;
  --accent-text: #ffffff;
  --focus: #0b62d0;
  --p1: #b3261e;
  --p2: #8a4b00;
  --p3: #1a5fb4;
  --p4: #4b5563;
  --p1-tint: #fdeceb;
  --p2-tint: #fdf1e3;
  --p3-tint: #eaf1fb;
  --p4-tint: #eef0f3;
  --up: #8a4b00;
  --down: #256d4a;
  --shadow: 0 4px 16px rgba(16, 26, 38, 0.08), 0 1px 0 rgba(16, 26, 38, 0.04);
  --shadow-strong: 0 8px 24px rgba(16, 26, 38, 0.12), 0 1px 0 rgba(16, 26, 38, 0.06);
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #131b26;
  --surface: #1e2d42;
  --surface-2: #2a3d56;
  --surface-3: #324a68;
  --border: #344862;
  --border-strong: #4a6380;
  --text: #e8edf3;
  --muted: #c2d0e0;
  --accent: #7fb2e5;
  --accent-strong: #6ab0f3;
  --accent-text: #0d1319;
  --focus: #7fb2e5;
  --p1: #ff9a90;
  --p2: #f0b072;
  --p3: #93c2f5;
  --p4: #b3bec9;
  --p1-tint: #3a2523;
  --p2-tint: #3a2e1e;
  --p3-tint: #1e324a;
  --p4-tint: #262d36;
  --up: #f0b072;
  --down: #7fd3aa;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-strong: 0 16px 40px rgba(0, 0, 0, 0.48), 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ----------------------------------------------------------------- base -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
  font-weight: 650;
}
h1 {
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem);
  letter-spacing: -0.01em;
}
h2 {
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.3rem);
}
h3 {
  font-size: 1rem;
}
h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
p {
  margin: 0 0 0.75rem;
}
p:last-child {
  margin-bottom: 0;
}
ul {
  margin: 0 0 0.75rem;
  padding-left: 1.15rem;
}
li {
  margin-bottom: 0.3rem;
}
code,
kbd {
  font-family: 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  font-size: 0.875em;
  background: var(--surface-3);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}
kbd {
  border: 1px solid var(--border);
}
a {
  color: var(--focus);
}

.wrap {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

.muted {
  color: var(--muted);
}
.hint {
  font-size: 0.875rem;
  color: var(--muted);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.75rem 1rem;
  z-index: 10;
}
.skip-link:focus {
  left: 0;
}

:where(a, button, select, textarea, input, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- header -- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  padding-block: clamp(1.1rem, 2vw, 1.6rem) 0;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 1.25rem;
}

.header-title {
  min-width: min(100%, 22rem);
  max-width: var(--max-read);
}
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.4;
}
.header-privacy {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.7rem 0.9rem;
  min-width: min(100%, 18rem);
  box-shadow: var(--shadow);
}

.theme-switcher {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  margin-left: auto;
}
.theme-select {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.theme-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
}

.privacy-badge {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.privacy-line {
  margin: 0.2rem 0 0.15rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.link-button {
  background: none;
  border: 0;
  padding: 0.25rem 0;
  color: var(--focus);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  min-height: 32px;
}

.privacy-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.privacy-detail ul {
  margin-bottom: 0.75rem;
}

/* ----------------------------------------------------------------- card -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-block: 1.4rem;
}

.section-heading {
  margin: 1.75rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------------------------------------------------------------- input -- */

.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.field-label.inline {
  display: inline-block;
  margin-right: 0.4rem;
  margin-bottom: 0;
}
.field-hint {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  width: 100%;
  max-width: 100%;
}
textarea {
  resize: vertical;
  min-height: 11rem;
  line-height: 1.6;
}
textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}
textarea:hover {
  border-color: var(--accent);
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  outline: none;
}
select {
  min-height: 44px;
}
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  outline: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1rem;
}
.actions--primary {
  margin-top: 1rem;
}

.example-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.85rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}
.example-row-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.example-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.example-picker select {
  width: auto;
  max-width: min(100%, 20rem);
  font-size: 0.92rem;
  min-width: 14rem;
}
@media (max-width: 560px) {
  .example-picker {
    width: 100%;
  }
  .example-picker select {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
  }
}

.example-note-wrap {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.example-note-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.example-note {
  margin: 0;
}
.kbd-hint {
  margin-top: 0.65rem;
}

.btn {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  min-height: 46px;
  padding: 0.6rem 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(16, 26, 38, 0.08);
}
.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(26, 77, 122, 0.22);
}
.btn-primary:active {
  transform: translateY(1px);
  box-shadow: none;
}
.btn-quiet {
  min-height: 38px;
  font-weight: 500;
  font-size: 0.9rem;
}
.btn-copy {
  font-size: 0.82rem;
  min-height: 36px;
  padding: 0.4rem 0.7rem;
}

@media (prefers-color-scheme: dark) {
  .btn-primary:hover {
    background: #8bc4ff;
    border-color: #8bc4ff;
    color: #08131f;
    box-shadow: 0 4px 16px rgba(127, 178, 229, 0.28);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .btn {
    transition:
      background-color 120ms ease,
      border-color 120ms ease,
      box-shadow 120ms ease,
      transform 80ms ease;
  }
}

/* --------------------------------------------------------------- result -- */

.empty-state {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 4vw, 2.5rem);
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
}
.empty-copy {
  flex: 1 1 22rem;
  min-width: 0;
}
.empty-matrix {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.empty-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0.85rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.empty-steps li {
  position: relative;
  padding-left: 1.9rem;
  margin-bottom: 0.45rem;
}
.empty-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
}
.mini-cell.is-legend {
  color: var(--p-color);
  background: var(--p-tint);
  opacity: 0.75;
}

.result {
  margin-block: 0.5rem 1.25rem;
  scroll-margin-top: 1rem;
}
@media (prefers-reduced-motion: no-preference) {
  .result {
    animation: resultEnter 360ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .banner {
    animation: resultEnter 320ms cubic-bezier(0.22, 1, 0.36, 1) 40ms both;
  }
  .panel-chain,
  .result-grid > *,
  .justification-line,
  .unassessed {
    animation: resultEnter 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .panel-chain {
    animation-delay: 80ms;
  }
  .result-grid > *:nth-child(1) {
    animation-delay: 120ms;
  }
  .result-grid > *:nth-child(2) {
    animation-delay: 160ms;
  }
}
@keyframes resultEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.banner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background: var(--p-tint, var(--surface-2));
  border: 1px solid var(--border);
  border-left: 8px solid var(--p-color, var(--accent));
  border-radius: var(--radius);
  padding: clamp(0.9rem, 2vw, 1.25rem);
}

.banner-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.banner-priority {
  margin: 0.15rem 0 0.2rem;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.banner-code {
  color: var(--p-color);
}
.banner-name {
  font-size: 0.5em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 650;
}
.banner-headline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: var(--max-read);
}
.banner-side {
  text-align: right;
}
.refined-tag {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
}

/* --- verdict block ------------------------------------------------- */

.banner {
  align-items: stretch;
  gap: clamp(1rem, 3vw, 2rem);
}
.banner-main {
  flex: 1 1 20rem;
  min-width: 0;
}
.banner-side {
  display: flex;
  align-items: center;
  text-align: left;
}

.banner-eyebrow {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.refined-tag {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}
.banner-sep {
  font-size: 0.45em;
  color: var(--muted);
  vertical-align: middle;
}
.banner-name {
  font-size: 0.5em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The three values that produced the answer. */
.hero-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0.9rem 0 0.75rem;
}
.hero-levels li {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  min-width: 7rem;
}
.level-key {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.level-value {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}
.level-high .level-value {
  color: var(--p1);
}
.level-medium .level-value {
  color: var(--p2);
}
.level-low .level-value {
  color: var(--muted);
}
.band-low .level-value {
  color: var(--p2);
}

/* The matrix, small, beside the verdict. */
.mini-matrix {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 2.85rem);
  grid-auto-rows: 2.85rem;
  gap: 1px;
  padding: 1px;
  background: var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.mini-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
  color: transparent;
}
.mini-cell.is-current {
  background: var(--p-color);
  color: var(--surface);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--p-color) 30%, transparent);
}
.mini-caption {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* The pasteable one-liner, directly under the verdict. */
.justification-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.75rem 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--p-color, var(--accent));
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}
.justification-text {
  flex: 1 1 auto;
  user-select: all;
}
.justification-copy {
  flex: 0 0 auto;
}

.unassessed {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-left: 6px solid var(--p2);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 1rem;
}
.unassessed h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--p2);
}

/* Classification detail as chips rather than a ten-row table. */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (min-width: 700px) {
  .chips {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.chip {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}
.chip-key {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  line-height: 1.2;
}
.chip-value {
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.25;
}

.blocks {
  display: inline-flex;
  gap: 4px;
}
.blocks-item {
  width: 14px;
  height: 26px;
  border: 2px solid var(--p-color, var(--muted));
  border-radius: 3px;
  background: transparent;
}
.blocks-item.is-filled {
  background: var(--p-color, var(--muted));
}

.priority-P1 {
  --p-color: var(--p1);
  --p-tint: var(--p1-tint);
}
.priority-P2 {
  --p-color: var(--p2);
  --p-tint: var(--p2-tint);
}
.priority-P3 {
  --p-color: var(--p3);
  --p-tint: var(--p3-tint);
}
.priority-P4 {
  --p-color: var(--p4);
  --p-tint: var(--p4-tint);
}
.priority-unassessed {
  --p-color: var(--muted);
  --p-tint: var(--surface-2);
}

.priority-inline {
  color: var(--p-color);
  font-weight: 700;
  border-bottom: 3px solid var(--p-color);
  padding-bottom: 1px;
}

.result-grid {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1.1rem;
}
.result-col {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}

@media (max-width: 900px) {
  .result-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.panel-chain {
  border-left: 4px solid var(--accent);
  margin-top: 1rem;
}
.panel-next-action {
  border-left: 4px solid var(--down);
  margin-top: 1rem;
}
.panel-next-action h3 {
  color: var(--down);
}
.next-action-name {
  font-size: 1.25rem;
  font-weight: 750;
  margin-bottom: 0.35rem;
}
.panel-next-action h4 {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.78rem;
}
.next-action-diagnostic {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.next-action-diagnostic code {
  display: inline-block;
  margin-top: 0.35rem;
}
.panel-chain .chain-split {
  gap: clamp(1rem, 4vw, 3rem);
}
.panel h3 {
  margin: 0 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.advisory {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* ------------------------------------------------------------- evidence -- */

.evidence,
.drivers,
.reasoning,
.missing,
.questions,
.risk-flags,
.conflicts {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.92rem;
}
.evidence li,
.drivers li,
.risk-flags li {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}
.evidence li {
  margin-bottom: 0.35rem;
}

.tick {
  color: var(--down);
  font-weight: 700;
}
.quote {
  quotes: '"' '"';
  font-style: italic;
  background: var(--surface-3);
  border-radius: 4px;
  padding: 0 0.25rem;
}
.arrow {
  color: var(--muted);
}
.meaning {
  color: var(--muted);
}

.drivers li {
  margin-bottom: 0.25rem;
}
.weight {
  flex: 0 0 3.1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.85rem;
}
.weight-up {
  color: var(--up);
}
.weight-down {
  color: var(--down);
}

.reasoning li,
.missing li,
.questions li {
  margin-bottom: 0.45rem;
  padding-left: 1rem;
  position: relative;
  line-height: 1.5;
  font-size: 0.9rem;
}
.reasoning li::before,
.missing li::before,
.questions li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}
.questions li::before {
  background: var(--accent);
}

.panel-missing h4 {
  margin-top: 0.85rem;
}

.risk-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.risk-flag {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--p2);
  display: inline-block;
  align-self: center;
}

.conflicts {
  margin-top: 0.6rem;
}
.conflicts li {
  border-left: 3px solid var(--p2);
  padding-left: 0.6rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
}

.confidence-line {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
}
.meter {
  height: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* ---------------------------------------------------------------- chain -- */

.chain {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chain-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.7rem 0.85rem;
}
.chain-step h4 {
  margin-bottom: 0.4rem;
}
.chain-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.chain-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}
@media (max-width: 560px) {
  .chain-split {
    grid-template-columns: minmax(0, 1fr);
  }
}
.chain-modifiers ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}
.chain-modifiers li {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}
.pill {
  flex: 0 0 auto;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 0.3rem;
  border: 1px solid var(--border-strong);
}
.pill-raise {
  color: var(--p1);
}
.pill-lower {
  color: var(--down);
}
.chain-result {
  text-align: center;
  background: var(--surface-3);
  font-size: 1.05rem;
}

/* --------------------------------------------------------------- refine -- */

details {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}
summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.35rem 0;
  min-height: 32px;
}
/* A heading inside <summary> keeps the document outline intact without
   turning the disclosure control into a block-level element. */
summary > .summary-title {
  display: inline;
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0;
}
summary::marker {
  color: var(--muted);
}
.summary-hint {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}

.refine-panel {
  padding-top: 0.9rem;
}
.refine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.9rem;
}
.refine-field label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.risk-fieldset {
  margin: 1rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 1rem;
}
.risk-fieldset legend {
  font-weight: 650;
  font-size: 0.875rem;
  padding-inline: 0.35rem;
}
.risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.4rem 1rem;
}
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 34px;
  font-size: 0.925rem;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* --------------------------------------------------------------- matrix -- */

.matrix-wrap {
  overflow-x: auto;
}
.matrix {
  border-collapse: separate;
  border-spacing: 6px;
  width: 100%;
  min-width: 32rem;
}
.matrix th {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
  padding: 0.35rem 0.5rem;
  font-weight: 600;
}
.matrix thead th {
  text-align: center;
}
.matrix td {
  padding: 0;
}

.matrix-cell {
  width: 100%;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--p-color);
  padding: 0.5rem;
}
.matrix-cell:hover {
  background: var(--p-tint);
}
.matrix-cell.is-current {
  background: var(--p-tint);
  border-color: var(--p-color);
  border-width: 3px;
  box-shadow: inset 0 0 0 1px var(--p-color);
}
.matrix-code {
  font-size: 1.15rem;
}
.matrix-current {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  font-weight: 700;
}

.matrix-explain {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
}
.cell-examples {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.current-tag {
  margin-left: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  color: var(--muted);
}

.definitions-details {
  margin-top: 1rem;
}
.definitions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  padding-top: 0.75rem;
}
.definition {
  border: 1px solid var(--border);
  border-top: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.9rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.definition h4 {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  color: var(--text);
}
.definition ul {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.definition.priority-P1 {
  border-top-color: var(--p1);
}
.definition.priority-P2 {
  border-top-color: var(--p2);
}
.definition.priority-P3 {
  border-top-color: var(--p3);
}
.definition.priority-P4 {
  border-top-color: var(--p4);
}

/* --------------------------------------------------------------- footer -- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 2rem;
  padding-block: 1.25rem 2rem;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- print -- */

/* ------------------------------------------------------------ eight-questions -- */
.eight-questions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.1rem 1.5rem;
  align-items: start;
}
.eight-col h4 {
  margin: 0 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.facet-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.facet-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
}
@media (min-width: 701px) {
  .eight-questions {
    grid-template-rows: auto auto auto auto auto;
  }
  .eight-col {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: 1 / 6;
    row-gap: 0.5rem;
  }
  .eight-col h4 {
    margin: 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
  }
  .facet-list {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: 2 / 6;
    gap: 0.5rem;
  }
  .facet-row {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    margin-bottom: 0;
  }
}
@media (max-width: 700px) {
  .eight-questions {
    grid-template-columns: minmax(0, 1fr);
  }
}
.facet-row.facet--unknown {
  border-left: 3px solid var(--p2);
}
.facet-row.facet--inferred {
  border-left: 3px solid var(--accent);
}
.facet-row.facet--answered {
  border-left: 3px solid var(--down);
}
.facet-row.facet--key {
  border-left-color: var(--p1);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--p1) 35%, transparent);
}
.facet-badge--key {
  background: var(--p1-tint);
  color: var(--p1);
  border-color: var(--p1);
}
.facet-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.facet-num {
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.facet-title {
  font-weight: 700;
  font-size: 0.88rem;
  flex: 1 1 auto;
}
.facet-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}
.facet-badge--ok {
  background: var(--surface);
  color: var(--down);
  border-color: var(--down);
}
.facet-badge--mid {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.facet-badge--unknown {
  background: var(--p2-tint);
  color: var(--p2);
  border-color: var(--p2);
}
.facet-value {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 0.25rem;
}
.facet-quote {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
  margin-top: 0.15rem;
  background: var(--surface-3);
  border-radius: 4px;
  padding: 0 0.25rem;
  display: inline-block;
}
.facet-hint {
  font-size: 0.78rem;
  margin-top: 0.2rem;
  line-height: 1.4;
}
.panel-eight h3 {
  color: var(--accent);
}
.panel-handoff {
  border-left: 4px solid var(--accent);
  margin-top: 1rem;
}
.panel-handoff h3 {
  color: var(--accent);
}

.q-tag {
  display: inline-block;
  margin-right: 0.45rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  vertical-align: 0.1em;
}
.q-tag--diagnostic {
  color: var(--accent);
  border-color: var(--accent);
}
.q-tag--priority {
  color: var(--p1);
  border-color: var(--p1);
  background: var(--p1-tint);
}
.q-tag--confidence {
  color: var(--muted);
}

.reply-box {
  font-family: 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin: 0 0 0.6rem;
  user-select: all;
}
.handoff-box {
  font-family: 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin: 0 0 0.6rem;
  user-select: all;
}
.panel-handoff .actions {
  margin-top: 0.15rem;
}
.panel-reply h3 {
  color: var(--down);
}

.refined-line {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px dashed var(--border-strong);
  padding-top: 0.35rem;
}

.relevance-hint {
  margin-top: 0.6rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--p2);
  border-radius: var(--radius-sm);
  background: var(--p2-tint);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}

/* ------------------------------------------------ v0.13.0 usability ------ */

/* A sticky index of the result panels. */
.jump-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.82rem;
}
.jump-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}
.jump-nav a:hover {
  text-decoration: underline;
}

/* The single place to see and copy what to ask the requester. */
.panel-ask {
  border-left: 4px solid var(--accent);
}
.ask-list {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.4rem;
}
.ask-list li {
  line-height: 1.5;
}

.featured-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.featured-example {
  font-size: 0.82rem;
  min-height: 34px;
  text-align: left;
}

/* Refine summary: the live verdict and the open-question count. */
.refine-verdict {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--p-color);
  background: var(--p-tint);
}
.refine-count {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Refine grouping into Impact and Urgency. */
.refine-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.9rem;
}
.refine-group legend {
  padding: 0 0.4rem;
  font-weight: 700;
  font-size: 0.85rem;
}

/* The matrix scroll container is keyboard focusable on small screens. */
.matrix-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .btn-copy {
    min-height: 40px;
    padding: 0.5rem 0.8rem;
  }
}

@media print {
  .site-header .header-privacy,
  .actions,
  .site-footer,
  #refine-details,
  .matrix-explain,
  .jump-nav {
    display: none;
  }
  body {
    background: #fff;
  }
  .card,
  .panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
