:root {
  color-scheme: light;
  --ink: #0f0f0f;
  --muted: #686866;
  --subtle: #8b8b87;
  --line: #deded9;
  --line-strong: #cecec8;
  --surface: #f7f7f5;
  --surface-strong: #f0f0ee;
  --white: #ffffff;
  --accent: #1a3a5c;
  --accent-hover: #102f50;
  --accent-soft: #eaf0f5;
  --danger: #8b1a1a;
  --danger-soft: #fde8e8;
  --warning: #7a5000;
  --warning-soft: #fff4e0;
  --success: #2a5c2a;
  --success-soft: #e6f0e6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--white);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(to bottom, #fbfbfa 0, #fff 260px) no-repeat,
    var(--white);
  line-height: 1.6;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(100% - 40px, 1040px);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  border-bottom: 1px solid rgba(222, 222, 217, 0.8);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: var(--white);
}

.brand-mark svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.privacy-label {
  color: var(--muted);
  font-size: 12px;
}

.language-toggle {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.language-option {
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.language-option.is-active {
  background: var(--accent);
  color: var(--white);
}

.main-content {
  padding-block: 66px 32px;
}

.intro {
  max-width: 710px;
  margin: 0 auto 34px;
  text-align: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(31px, 4.2vw, 46px);
  line-height: 1.16;
}

h2 {
  font-size: 20px;
  line-height: 1.3;
}

.intro-copy {
  max-width: 620px;
  margin: 15px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.drop-zone {
  position: relative;
  display: flex;
  min-height: 294px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 42px 30px 31px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  outline: none;
  background: rgba(247, 247, 245, 0.56);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #f4f7f9;
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.08);
}

.upload-icon {
  display: grid;
  width: 50px;
  height: 50px;
  margin-bottom: 17px;
  place-items: center;
  border: 1px solid #d9e2e9;
  border-radius: 12px;
  background: var(--white);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.upload-icon svg {
  width: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.drop-title {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}

.drop-copy {
  margin: 4px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.button:focus-visible,
.text-button:focus-visible,
.suggestion-chip:focus-visible,
.language-option:focus-visible {
  outline: 3px solid rgba(26, 58, 92, 0.18);
  outline-offset: 2px;
}

.button-secondary {
  border: 1px solid var(--accent);
  background: var(--white);
  color: var(--accent);
}

.button-secondary:hover {
  background: var(--accent-soft);
}

.button-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 25px 0 0;
  color: var(--subtle);
  font-size: 11px;
}

.privacy-note svg {
  width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.processing-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.processing-heading {
  display: grid;
  align-items: center;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
}

.spinner,
.button-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(26, 58, 92, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.processing-status,
.processing-file {
  margin: 0;
}

.processing-status {
  font-weight: 500;
}

.processing-file {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.progress-value {
  color: var(--accent);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.progress-track {
  height: 5px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 5px;
  background: #dfdfdb;
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

.inline-error {
  margin-top: 12px;
  padding: 11px 13px;
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  background: #fff6f6;
  color: var(--danger);
  font-size: 13px;
}

.document-section {
  margin-top: 26px;
  animation: fade-in 200ms ease both;
}

.file-strip {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.file-type {
  display: grid;
  min-width: 42px;
  height: 36px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-name,
.file-details {
  margin: 0;
}

.file-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-details {
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  padding: 4px 5px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.summary-card,
.answer-section {
  padding: 27px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.complete-badge,
.reference-note {
  margin-top: 2px;
  white-space: nowrap;
}

.complete-badge {
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 10px;
  font-weight: 500;
}

.reference-note {
  color: var(--muted);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
  border: 0.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}

.result-table th,
.result-table td {
  padding: 11px 13px;
  border-right: 0.5px solid var(--line);
  border-bottom: 0.5px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.result-table th:last-child,
.result-table td:last-child {
  border-right: 0;
}

.result-table tr:last-child td {
  border-bottom: 0;
}

.result-table th {
  background: var(--surface-strong);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.result-table tbody tr:nth-child(even) td {
  background: #fafaf8;
}

.result-table td:first-child {
  width: 18%;
  font-weight: 500;
}

.result-table td:nth-child(2) {
  width: 50%;
  white-space: pre-line;
}

.result-table td:nth-child(3) {
  width: 17%;
  color: var(--muted);
}

.reference-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  text-underline-offset: 2px;
}

.reference-link:hover {
  text-decoration: underline;
}

.reference-link:focus-visible {
  border-radius: 3px;
  outline: 3px solid rgba(26, 58, 92, 0.18);
  outline-offset: 2px;
}

.reference-link svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.confidence-badge {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.confidence-high {
  background: var(--success-soft);
  color: var(--success);
}

.confidence-medium {
  background: var(--warning-soft);
  color: var(--warning);
}

.confidence-low {
  background: var(--danger-soft);
  color: var(--danger);
}

.confidence-warning {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid #f1cccc;
  border-radius: 6px;
  background: #fff8f8;
  color: var(--danger);
  font-size: 12px;
}

.questions-section {
  margin-top: 42px;
}

.suggestions-wrap {
  margin-bottom: 15px;
}

.suggestions-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-chip {
  max-width: 100%;
  padding: 8px 13px;
  border: 1px solid #cbd6df;
  border-radius: 20px;
  background: var(--white);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.suggestion-chip:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.suggestion-chip:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.question-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

#question-input {
  min-height: 68px;
  max-height: 180px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#question-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.09);
}

#question-input:disabled {
  cursor: not-allowed;
  background: var(--surface);
  opacity: 0.55;
}

#question-input::placeholder {
  color: #999995;
}

#ask-button {
  min-width: 126px;
  align-self: stretch;
}

#ask-button svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.button-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-color: rgba(255, 255, 255, 0.34);
  border-top-color: var(--white);
}

#ask-button.is-loading .button-spinner {
  display: inline-block;
}

#ask-button.is-loading svg {
  display: none;
}

.answer-section {
  margin-top: 26px;
  background: var(--white);
  animation: fade-in 200ms ease both;
}

.app-footer {
  margin-top: 54px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: 11px;
  text-align: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] {
  display: none !important;
}

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

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 28px, 1040px);
  }

  .main-content {
    padding-top: 46px;
  }

  .privacy-label {
    display: none;
  }

  .drop-zone {
    min-height: 270px;
    padding-inline: 18px;
  }

  .processing-card,
  .summary-card,
  .answer-section {
    padding: 21px 17px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .complete-badge,
  .reference-note {
    white-space: normal;
  }

  .question-form {
    grid-template-columns: 1fr;
  }

  #ask-button {
    min-height: 46px;
  }

  .result-table th,
  .result-table td {
    min-width: 110px;
    padding: 10px;
  }

  .result-table td:nth-child(2) {
    min-width: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
