:root {
  --tool-ok: #166534;
  --tool-deny: #991b1b;
  --tool-warn: #92400e;
  --tool-panel: #faf9f7;
  --tool-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rp-accent: #1f4b7a;
  --rp-border: #e5e2dc;
  --rp-muted: #5c5c5c;
  --rp-bg: #f7f6f3;
}

.tool-page {
  background: var(--rp-bg);
  color: #1a1a1a;
  font-family: Inter, sans-serif;
  overflow-x: clip;
}

.tool-page .tool-layout,
.tool-page .tool-card,
.tool-page .tool-aside,
.tool-page .tool-source-card,
.tool-page .tool-result,
.tool-page .evidence-wrap,
.tool-page .status-grid,
.tool-page .status-panel,
.tool-page .source-grid,
.tool-page .form-row,
.tool-page .tool-links,
.tool-page .evidence-actions {
  min-width: 0;
}

.tool-page .page-hero {
  padding-top: 32px;
  padding-bottom: 24px;
}

@media (min-width: 768px) {
  .tool-page .page-hero {
    padding-top: var(--space-7);
    padding-bottom: var(--space-5);
  }
}

.tool-lede,
.tool-prose p,
.tool-card > p,
.tool-note,
.tool-source {
  color: var(--rp-muted);
  line-height: 1.6;
}

.tool-lede {
  max-width: 64ch;
  margin: 0;
  font-size: 1.0625rem;
}

@media (min-width: 700px) {
  .tool-lede {
    font-size: 1.125rem;
  }
}

.tool-layout {
  display: grid;
  gap: 24px;
}

@media (min-width: 880px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
    gap: 32px;
    align-items: start;
  }
}

.tool-card,
.tool-aside,
.tool-source-card {
  background: #fff;
  border: 1px solid var(--rp-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.06);
}

@media (min-width: 700px) {
  .tool-card,
  .tool-aside,
  .tool-source-card {
    padding: 32px;
  }
}

.tool-card h2,
.tool-aside h2,
.tool-source-card h3,
.evidence-wrap h3 {
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tool-card > p,
.tool-aside > p,
.tool-source-card p,
.evidence-wrap > p {
  margin: 0 0 16px;
  color: var(--rp-muted);
  line-height: 1.6;
}

.privacy-callout {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--rp-border);
  background: var(--tool-panel);
  color: var(--rp-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.tool-form {
  display: grid;
  gap: 14px;
}

.tool-form label {
  font-weight: 500;
  font-size: 0.875rem;
}

.tool-form input[type="text"],
.tool-form input[type="date"],
.tool-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--rp-border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  color: inherit;
  appearance: none;
}

.tool-form select {
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%231F4B7A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.tool-form input:focus,
.tool-form select:focus {
  outline: 2px solid rgba(31, 75, 122, 0.4);
  outline-offset: 1px;
  border-color: var(--rp-accent);
}

.form-row {
  display: grid;
  gap: 14px;
}

@media (min-width: 720px) {
  .form-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.form-row > div {
  min-width: 0;
}

.tool-form .btn-primary {
  width: 100%;
  justify-content: center;
}

@media (min-width: 480px) {
  .tool-form .btn-primary {
    width: auto;
    justify-self: start;
    min-width: 200px;
  }
}

.tool-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  color: var(--rp-muted);
}

.tool-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--rp-border);
  border-top-color: var(--rp-accent);
  border-radius: 50%;
  animation: rp-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

@keyframes rp-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-spinner,
  .tool-result.is-reveal {
    animation: none;
  }
}

.tool-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--rp-border);
  background: var(--tool-panel);
  opacity: 0;
  transform: translateY(6px);
  overflow-x: hidden;
}

@media (min-width: 560px) {
  .tool-result {
    padding: 20px;
  }
}

.tool-result.is-reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.3s var(--tool-ease), transform 0.3s var(--tool-ease);
}

.tool-result.is-ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.tool-result.is-deny {
  border-color: #fecaca;
  background: #fef2f2;
}

.tool-result h3 {
  margin: 0 0 8px;
  font-size: 1.125rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tool-result > p {
  margin: 0 0 14px;
  color: var(--rp-muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.decision-banner {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.decision-banner.is-drive {
  background: #166534;
  color: #fff;
}

.decision-banner.is-stop {
  background: #991b1b;
  color: #fff;
}

.status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 14px;
}

@media (min-width: 620px) {
  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.status-panel {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--rp-border);
  overflow-wrap: anywhere;
}

.status-panel span {
  font-size: 0.8125rem;
  color: var(--rp-muted);
}

.status-panel strong {
  font-weight: 600;
  font-size: 0.975rem;
}

.status-panel.is-ok {
  border-color: #86efac;
}

.status-panel.is-deny {
  border-color: #fca5a5;
}

.status-panel.is-warn {
  border-color: #fcd34d;
}

.remediation-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.remediation-list li {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  overflow-wrap: anywhere;
}

.remediation-list strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.remediation-list span {
  color: var(--rp-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.tool-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.tool-links .btn {
  width: auto;
  max-width: 100%;
  white-space: normal;
}

@media (max-width: 479px) {
  .tool-links {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .tool-links .btn {
    width: 100%;
    justify-content: center;
  }
}

.proof-line {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--rp-border);
  font-size: 0.8125rem;
  color: var(--rp-muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tool-aside ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--rp-muted);
  line-height: 1.6;
}

.tool-aside li + li {
  margin-top: 8px;
}

.policy-meta {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: var(--rp-muted);
  overflow-wrap: anywhere;
}

.subject-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  word-break: break-all;
}

.source-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 700px) {
  .source-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.evidence-wrap {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--rp-border);
  background: #fff;
  overflow-x: hidden;
}

.evidence-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.evidence-actions .btn {
  width: auto;
  max-width: 100%;
  white-space: normal;
}

@media (max-width: 479px) {
  .evidence-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .evidence-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

.evidence-details {
  margin: 0;
  overflow-x: hidden;
}

.evidence-details summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--rp-accent);
  padding: 8px 0;
}

.evidence-details[open] summary {
  margin-bottom: 8px;
}

.evidence-pre {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: #1a1a1a;
  color: #f7f6f3;
  font-size: 0.7rem;
  line-height: 1.45;
  max-width: 100%;
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}
