/* Mobile-first — AI Legal Risk Analyzer */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e7ecf3;
  --muted: #9aa8b8;
  --accent: #3d8bfd;
  --accent-dim: #2563c9;
  --danger: #f87171;
  --ok: #4ade80;
  --border: #2d3a4f;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.logo {
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
}
.nav-main {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.nav-main a {
  color: var(--muted);
  font-size: 0.95rem;
}
.nav-main a.active {
  color: var(--text);
  font-weight: 600;
}

.nav-main .nav-logout-btn {
  color: var(--muted);
  font-size: 0.95rem;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.nav-main .nav-logout-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Mobile hamburger — nav collapses under 768px */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.nav-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-nav-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

@media (max-width: 767px) {
  .header-inner {
    align-items: center;
  }
  .logo {
    margin-right: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }
  .header-nav-cluster {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex: 1 1 100%;
    width: 100%;
    order: 3;
    padding: 0.5rem 0 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    gap: 0;
  }
  .header-nav-cluster.is-open {
    display: flex;
  }
  .nav-main {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
  }
  .nav-main > a,
  .nav-main .nav-logout-btn {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
  }
  .nav-main > *:last-child {
    border-bottom: none;
  }
  .nav-main .nav-logout-btn {
    width: 100%;
  }
  .lang-toggle {
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border);
    width: 100%;
  }
  .lang-toggle .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (min-width: 768px) {
  .header-nav-cluster {
    display: flex !important;
  }
  .nav-toggle {
    display: none !important;
  }
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 2.5rem;
}
.site-terms-link {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.page-terms .terms-main {
  padding-bottom: 2rem;
}
.terms-section-title {
  font-size: 1.1rem;
  margin: 1.35rem 0 0.5rem;
  font-weight: 600;
  color: var(--text);
}
.terms-card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}
.terms-meta {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* M6-02 — prominent legal-information notice (not footer-only) */
.legal-notice-banner {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent-dim);
  background: rgba(61, 139, 253, 0.1);
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}

.clause-confidence {
  font-size: 0.88rem;
  font-weight: 500;
}

h1 {
  font-size: 1.65rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a26;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 200px;
  resize: vertical;
}

.page-input .paste-panel textarea {
  min-height: 280px;
  font-size: 1.05rem;
  line-height: 1.45;
}

.section-title {
  font-size: 1rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.char-line {
  margin-top: 0.35rem;
}

.small-print {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.page-input.is-loading .btn {
  opacity: 0.85;
  pointer-events: none;
}

.loading-hint {
  margin-top: 0.5rem;
}

.ai-callout {
  font-size: 1.15rem;
  margin-top: 0;
}

.confidence {
  color: var(--muted);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dim);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
}

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

.legal-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-unknown {
  background: #374151;
  color: #e5e7eb;
}
.badge-high {
  background: rgba(248, 113, 113, 0.2);
  color: #fecaca;
}
.badge-medium {
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
}
.badge-low {
  background: rgba(74, 222, 128, 0.15);
  color: #bbf7d0;
}

.clause-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.clause-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #121a26;
}
.clause-item h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.clause-item .clause-snippet {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.ref-links {
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}
.ref-links li {
  margin-bottom: 0.25rem;
}

.clause-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.clause-feedback .feedback-prompt {
  font-size: 0.85rem;
  color: var(--muted);
  width: 100%;
  margin: 0 0 0.25rem;
}
.btn-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a26;
  color: var(--text);
  cursor: pointer;
}
.btn-thumb:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface);
}
.btn-thumb:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-thumb.is-selected {
  border-color: var(--accent);
  background: rgba(61, 139, 253, 0.15);
}
.clause-feedback .feedback-status {
  font-size: 0.85rem;
  margin: 0;
  width: 100%;
}
.clause-feedback .feedback-err {
  font-size: 0.85rem;
  color: var(--danger);
  margin: 0;
  width: 100%;
}

.resources-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.resources-list li {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.resources-list a {
  font-weight: 600;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.consent {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 1rem 0;
}
.consent input {
  width: auto;
  margin-top: 0.25rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Response writer — Screen 6 */
.recipient-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}
.recipient-fieldset legend {
  margin-bottom: 0.5rem;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.radio-row input {
  width: auto;
  margin: 0;
}
.word-count-line.word-count-over {
  color: var(--danger);
}

/* Response draft — print/PDF: only letter + citations + disclaimers (see response-draft.html) */
.print-root {
  display: none;
}
.print-inner {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #111;
  max-width: 7in;
  margin: 0 auto;
}
.print-doc-title {
  font-size: 1.25rem;
  margin: 0 0 1rem;
  font-weight: 700;
}
.print-letter-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 11pt;
  line-height: 1.45;
  margin: 0 0 1.25rem;
  padding: 0;
  border: none;
  background: transparent;
}
.print-cites-section {
  margin-top: 1rem;
  font-size: 10pt;
}
.print-cites-heading {
  font-size: 11pt;
  margin: 0 0 0.5rem;
}
.print-cites-section ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
}
.print-cites-section a {
  color: #000;
  word-break: break-all;
}
.print-disclaimer,
.print-ai-note {
  font-size: 9pt;
  color: #333;
  margin: 1rem 0 0;
  line-height: 1.4;
}

@media print {
  body.page-response-draft {
    background: #fff !important;
    color: #111 !important;
  }
  body.page-response-draft .no-print,
  body.page-response-draft .draft-ui {
    display: none !important;
  }
  body.page-response-draft .print-root {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  body.page-response-draft main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
}

@media screen {
  body.page-response-draft .print-root {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
}
