:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657089;
  --border: #dfe5ef;
  --accent: #2f5bea;
  --accent-soft: #eef2ff;
  --danger: #b42318;
  --shadow: 0 8px 28px rgba(20, 35, 70, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 60px;
}

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

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; }
h2 { margin-bottom: 5px; font-size: 20px; }
h3 { margin-bottom: 5px; font-size: 16px; }
p { color: var(--muted); margin-bottom: 0; line-height: 1.5; }

.progress-card {
  min-width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.progress-track {
  margin-top: 9px;
  height: 7px;
  border-radius: 999px;
  background: #e9edf5;
  overflow: hidden;
}
#progressBar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .25s ease;
}

.meta-grid {
  display: grid;
  grid-template-columns: 150px 180px 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.meta-box, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.meta-box {
  padding: 14px 16px;
}

.meta-box.wide strong {
  display: block;
  line-height: 1.35;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px;
}

.panel {
  padding: 18px;
  margin-bottom: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.abstract-box {
  min-height: 170px;
  max-height: 330px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.68;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  user-select: text;
}

.keywords-row {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #cfd7e6;
  border-radius: 10px;
  padding: 12px 13px;
  font: inherit;
  color: var(--text);
  background: #fff;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,91,234,.12);
}

.case-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.case-card:first-child { border-top: 0; padding-top: 0; }

.case-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.case-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.case-header p { font-size: 13px; }

.btn, .mini-btn {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .08s, opacity .15s;
}
.btn:active, .mini-btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }

.btn { padding: 11px 16px; }
.btn.primary { background: var(--accent); color: white; }
.btn.secondary { background: #edf1f7; color: var(--text); }

.mini-btn {
  padding: 7px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.footer-actions {
  position: sticky;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(20,35,70,.14);
}

.save-status {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 15px;
  border-radius: 10px;
  background: #173a2a;
  color: white;
  box-shadow: var(--shadow);
  z-index: 10;
}
.toast.error { background: var(--danger); }

.hidden { display: none !important; }

.done {
  text-align: center;
  padding: 42px 20px;
}

code {
  background: #eef1f5;
  padding: 2px 5px;
  border-radius: 5px;
}

@media (max-width: 820px) {
  .topbar { flex-direction: column; }
  .progress-card { width: 100%; min-width: 0; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .meta-box.wide { grid-column: 1 / -1; }
  .footer-actions { flex-wrap: wrap; }
  .save-status { order: -1; flex-basis: 100%; }
}
