:root {
  --blue: #1e3a8a;
  --blue2: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --light: #f1f5f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Source Serif 4", Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, textarea { font: inherit; }
input { font: inherit; }
.screen { display: none; padding: 40px 20px 80px; max-width: 780px; margin: 0 auto; }
.screen.active { display: block; }
[hidden] { display: none !important; }

h1 { font-family: "Playfair Display", Georgia, serif; font-size: 38px; line-height: 1.15; margin-bottom: 12px; }
h2 { font-family: "Playfair Display", Georgia, serif; font-size: 26px; margin-bottom: 24px; }
h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.logo { display: flex; align-items: center; gap: 14px; margin-bottom: 44px; }
.logo-icon {
  width: 52px; height: 52px; background: var(--blue); color: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  font-family: "Playfair Display", Georgia, serif; font-weight: 800; flex-shrink: 0;
}
.logo-name { font-family: "Playfair Display", Georgia, serif; font-size: 22px; font-weight: 700; color: var(--blue); }
.logo-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.accent { color: var(--blue2); }
.hero-desc { color: var(--muted); font-size: 16px; margin-bottom: 44px; }

.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 40px; }
.type-card {
  text-align: left; background: var(--card); border: 2px solid var(--border); border-radius: 8px;
  padding: 28px 22px; cursor: pointer; transition: transform .2s, box-shadow .2s;
  color: inherit; display: flex; flex-direction: column;
}
.type-card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,.1); }
.type-card.blue { border-color: var(--blue2); }
.type-card.green { border-color: var(--green); }
.card-icon { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--light); margin-bottom: 12px; font-weight: 800; color: var(--blue); }
.card-title { font-family: "Playfair Display", Georgia, serif; font-size: 20px; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.card-badge { font-size: 11px; color: #64748b; border-top: 1px solid var(--border); padding-top: 10px; }

.btn-primary {
  display: block; width: 100%; padding: 14px; background: var(--blue2); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover { background: var(--blue); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  display: block; width: 100%; padding: 14px; background: var(--green); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-secondary:hover { background: #047857; }
.btn-ghost, .btn-back {
  background: none; border: 1px solid var(--border); border-radius: 8px; padding: 7px 15px;
  font-size: 13px; cursor: pointer; color: var(--muted);
}
.btn-back { margin-bottom: 20px; }
.btn-dl, .btn-add {
  background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 9px 18px;
  font-size: 13px; cursor: pointer;
}
.btn-add { background: var(--blue2); padding: 7px 14px; font-size: 12px; }
.btn-grp { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-opt {
  padding: 10px 20px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
  font-size: 13px; font-weight: 600; background: var(--light); color: #374151;
}
.btn-opt.sel { background: var(--blue2); color: #fff; border-color: var(--blue2); }
.btn-opt.sel-g { background: var(--green); color: #fff; border-color: var(--green); }

.form-group { margin-bottom: 24px; }
label { display: block; font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 10px; }
textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  font-size: 14px; resize: vertical; outline: none; line-height: 1.7;
}
textarea:focus { border-color: var(--blue2); }
.text-input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 13px 14px;
  font-size: 14px; outline: none; background: #fff;
}
.text-input:focus { border-color: var(--blue2); }
.space-top { margin-top: 14px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.user-bar {
  position: sticky; top: 0; z-index: 50; display: flex; justify-content: flex-end; align-items: center;
  gap: 10px; padding: 10px 20px; background: rgba(248,250,252,.92); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px); font-size: 13px; color: var(--muted);
}

.badge { font-size: 11px; background: var(--light); color: #475569; border-radius: 6px; padding: 3px 9px; font-weight: 700; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-grn { background: #d1fae5; color: #065f46; }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.sec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px,1fr)); gap: 12px; margin-bottom: 28px; }
.sec-card {
  background: var(--card); border: 2px solid var(--border); border-radius: 8px;
  padding: 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.sec-card:hover { border-color: var(--blue2); }
.sec-card.active { border-color: var(--blue2); background: #eff6ff; }
.sec-label { font-size: 13px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.sec-pts { font-size: 12px; color: var(--blue2); font-weight: 700; }
.sec-ver { font-size: 11px; color: var(--green); margin-top: 6px; }

.input-card, .doss-wrap, .hist-wrap {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.input-card { padding: 22px; }
.file-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.file-name { font-size: 12px; color: #64748b; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; white-space: pre-line; }
.hist-wrap { margin-top: 28px; }
.hist-head, .doss-head {
  padding: 12px 16px; font-weight: 700; font-size: 13px; background: var(--light);
  border-bottom: 1px solid var(--border); color: #374151;
}
.doss-head { display: flex; align-items: center; justify-content: space-between; }
.doss-title { font-weight: 700; color: #1e293b; font-size: 14px; }
.hist-item, .doss-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 13px; color: #334155;
}
.hist-item:hover, .doss-item:hover { background: #f8fafc; }
.doss-count { font-size: 11px; color: #64748b; }
.empty-msg { padding: 28px; text-align: center; color: #64748b; font-size: 13px; }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.admin-list { display: grid; gap: 10px; margin-top: 14px; }
.admin-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.admin-row-title { font-weight: 700; font-size: 13px; color: #1e293b; }
.admin-row-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions .btn-ghost { padding: 6px 10px; }

.result-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.result-top .btn-back { margin-bottom: 0; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.score-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 32px 24px; text-align: center; margin-bottom: 24px; }
.score-big { font-family: "Playfair Display", Georgia, serif; font-size: 64px; font-weight: 800; line-height: 1; }
.score-max { font-size: 30px; color: #64748b; }
.score-bar { width: 100%; height: 10px; background: var(--light); border-radius: 5px; margin: 18px 0 10px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 5px; transition: width .7s ease; }
.score-pct { font-size: 14px; color: var(--muted); }

.pf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.pf-box { background: var(--card); border: 1px solid #bbf7d0; border-radius: 8px; padding: 16px; }
.pf-box.bad { border-color: #fca5a5; }
.pf-title { font-weight: 700; font-size: 13px; color: #065f46; margin-bottom: 10px; }
.pf-box.bad .pf-title { color: var(--red); }
.pf-item { font-size: 13px; color: #374151; margin-bottom: 7px; line-height: 1.5; }
.pf-box.bad .pf-item { color: #7f1d1d; }

.ref-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 16px; margin-bottom: 20px; }
.ref-title { font-weight: 700; font-size: 13px; color: #1e40af; margin-bottom: 10px; }
.ref-item { font-size: 13px; color: #1e3a8a; margin-bottom: 6px; }
.comm-title { font-weight: 700; font-size: 15px; color: #0f172a; margin-bottom: 14px; }
.comm-card { border-radius: 8px; padding: 15px 17px; margin-bottom: 10px; border-left: 4px solid; }
.comm-top { display: flex; justify-content: space-between; margin-bottom: 7px; gap: 10px; }
.comm-type { font-size: 12px; font-weight: 700; color: #374151; }
.comm-sev { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.comm-passage { font-size: 13px; color: #1e293b; font-style: italic; margin-bottom: 7px; background: rgba(255,255,255,.75); padding: 5px 9px; border-radius: 5px; }
.comm-text { font-size: 13px; color: #374151; line-height: 1.65; }
.syn-box { background: #1e293b; border-radius: 8px; padding: 26px; margin-top: 24px; }
.syn-title { color: #94a3b8; font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 12px; }
.syn-text { color: #f8fafc; font-size: 14px; line-height: 1.8; }
.syn-author { color: #94a3b8; font-size: 11px; margin-top: 16px; text-align: right; }
.footer { margin-top: 52px; text-align: center; font-size: 12px; color: #64748b; }

.loading-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.6);
  z-index: 999; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
}
.loading-overlay.active { display: flex; }
.spinner {
  width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #fff; font-size: 15px; }

@media (max-width: 560px) {
  .card-row, .pf-row, .action-row { grid-template-columns: 1fr; }
  .result-top { align-items: stretch; flex-direction: column; }
  .result-actions { justify-content: stretch; }
  .result-actions .btn-dl { width: 100%; }
  h1 { font-size: 28px; }
  .score-big { font-size: 48px; }
}
