:root {
  --bg: #0f1220;
  --bg-soft: #171b2e;
  --panel: #1c2138;
  --panel-2: #232845;
  --text: #e8eaf2;
  --muted: #9aa3c0;
  --accent: #6c8cff;
  --accent-2: #51d1b6;
  --danger: #ff6b6b;
  --border: #2b3258;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1d2347 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

main { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: transform .05s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { background: #2a3157; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #7b5cff); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: #5a2b3a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel h2 { margin-top: 0; font-size: 18px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
  background: var(--bg-soft);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: #1a2240; }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.dropzone p { margin: 4px 0; }

.or-divider {
  text-align: center;
  margin: 18px 0;
  position: relative;
  color: var(--muted);
  font-size: 13px;
}
.or-divider::before, .or-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.or-divider::before { left: 0; }
.or-divider::after { right: 0; }

textarea, input, select {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.status { color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.status.success { color: var(--accent-2); }

/* Results */
.results { margin-top: 26px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: 22px; margin: 0; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.metric .value { font-size: 26px; font-weight: 700; color: var(--accent-2); }
.metric .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 16px; }
.card-body { font-size: 14px; }

/* Structure list */
.struct-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.struct-item:last-child { border-bottom: none; }
.struct-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.found { background: var(--accent-2); }
.dot.missing { background: #4a4f72; }
.struct-item .name { font-weight: 600; }
.struct-item .meta { margin-left: auto; color: var(--muted); font-size: 12px; }

/* Keywords */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}
.chip .count { color: var(--accent); font-weight: 700; margin-left: 6px; }

/* Readability bars */
.bar-row { margin: 12px 0; }
.bar-row .bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar { height: 9px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }

/* Sentences / references */
.sentence-list, .ref-list { margin: 0; padding-left: 18px; }
.sentence-list li, .ref-list li { margin-bottom: 10px; }
.ref-list { list-style: decimal; }
.ref-list.collapsed li:nth-child(n+11) { display: none; }
.show-more { margin-top: 10px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* AI summary markdown-ish */
.ai-content h4 { margin: 14px 0 6px; font-size: 14px; color: var(--accent-2); }
.ai-content ul { margin: 6px 0; padding-left: 20px; }
.ai-content p { margin: 6px 0; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 460px; box-shadow: var(--shadow);
}
.modal-card h3 { margin-top: 0; }
.modal-card label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* Footer */
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 20px 50px; }

@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .card.wide { grid-column: auto; }
}
