:root {
  --ink: #15161A;
  --paper: #F6F2E9;
  --surface: #FFFFFF;
  --accent: #1a44fd;
  --accent-tint: #ECE6FF;
  --verified: #B9FF3D;
  --flag: #FF5A5F;

  --ink-muted: color-mix(in srgb, var(--ink) 62%, transparent);
  --ink-faint: color-mix(in srgb, var(--ink) 46%, transparent);
  --hairline: color-mix(in srgb, var(--ink) 28%, transparent);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow-sm: 4px 4px 0 var(--ink);
  --shadow-md: 7px 7px 0 var(--ink);
  --shadow-accent: 7px 7px 0 var(--accent);

  --control-h: 44px;
  --control-h-sm: 36px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.2; }

a { color: var(--accent); }

.accent-word { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) clamp(var(--space-5), 5vw, 48px);
  background: var(--paper);
  border-bottom: 2.5px solid var(--ink);
}

.brand { display: flex; align-items: center; gap: var(--space-3); }

.brand__mark {
  width: 26px;
  height: 26px;
  background: var(--accent);
  border: 2.5px solid var(--ink);
  border-radius: 7px;
  transform: rotate(-8deg);
  flex-shrink: 0;
}

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand__flow {
  display: none;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

@media (min-width: 720px) {
  .brand__flow { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(var(--space-8), 6vw, 56px) clamp(var(--space-5), 5vw, 48px) var(--space-2);
}

.hero h1 {
  font-size: clamp(28px, 4.4vw, 40px);
  font-weight: 600;
  letter-spacing: -0.01em;
  max-width: 16ch;
}

.hero p {
  margin: var(--space-3) 0 0;
  max-width: 54ch;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink-muted);
}

/* ---------- Case file layout ---------- */
.case-file {
  max-width: 780px;
  margin: 0 auto;
  padding: var(--space-6) clamp(var(--space-5), 5vw, 48px) 80px;
  position: relative;
}

.case-file::before {
  content: '';
  position: absolute;
  top: var(--space-2);
  bottom: var(--space-10);
  left: clamp(var(--space-5), 5vw, 48px);
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--accent) 0 6px, transparent 6px 12px);
}

.exhibit {
  position: relative;
  padding-left: 34px;
  margin-bottom: var(--space-10);
}

.exhibit__tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.exhibit__tag::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--ink);
  flex-shrink: 0;
}

.exhibit h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.005em; margin-bottom: var(--space-4); }

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(var(--space-5), 3vw, 28px);
}

.panel > * + * { margin-top: var(--space-5); }

.panel--flat {
  box-shadow: none;
  border-style: dashed;
  background: var(--paper);
}

/* ---------- Field (label + control, jarak presisi) ---------- */
.field { display: block; }

.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: var(--space-2);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 560px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
  .field--wide { grid-column: 1 / -1; }
}

.subhead { font-size: 15px; font-weight: 600; margin: 0; }

/* ---------- Form elements ---------- */
textarea, input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}

input[type="text"] { min-height: var(--control-h); }
textarea { min-height: 140px; }

.char-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-align: right;
  margin-top: var(--space-2);
}

.dropzone {
  border: 2.5px dashed var(--ink);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface);
}

.dropzone__filename {
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: var(--space-2);
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

input[type="file"] { font-family: var(--font-body); font-size: 14px; color: var(--ink); }

input[type="file"]::file-selector-button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  margin-right: var(--space-3);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  padding: 0 var(--space-6);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:hover { transform: translate(2px, 2px); box-shadow: none; }
.btn:active { transform: translate(3px, 3px); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--ghost { background: var(--surface); color: var(--ink); }
.btn--sm { min-height: var(--control-h-sm); padding: 0 var(--space-4); font-size: 13px; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.query-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.query-row input[type="text"] { flex: 1; min-width: 180px; }

/* ---------- Result preview ---------- */
.result-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.result-head .copy-mini { margin-left: auto; }

.preview {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.65;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.preview:empty::before {
  content: 'Belum ada hasil.';
  color: var(--ink-faint);
  font-style: italic;
}

/* ---------- Copy button (mini) ---------- */
.copy-mini {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  padding: 0 var(--space-3);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  box-shadow: var(--shadow-sm);
}

.copy-mini:hover { transform: translate(2px, 2px); box-shadow: none; }

/* ---------- Stamps (mode badges) ---------- */
.stamp {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px var(--space-3);
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--surface);
  transform: rotate(-2.5deg);
}

.stamp:empty { display: none; }
.stamp--ai { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.stamp--crossref { background: var(--verified); border-color: var(--ink); color: var(--ink); }
.stamp--demo, .stamp--fallback-demo {
  background: #fff;
  border-color: var(--flag);
  color: var(--flag);
}

/* ---------- Keyword chips ---------- */
.keyword-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.keyword-chips:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0 var(--space-4);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
}

.chip:hover { background: var(--accent-tint); border-color: var(--accent); }

/* ---------- Index cards (kartu referensi) ---------- */
.index-card {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-top: 2px dashed var(--ink);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.index-card + .index-card { margin-top: var(--space-3); }

.index-card--saved { border-color: var(--accent); border-top-color: var(--accent); box-shadow: var(--shadow-accent); }

.index-card__meta {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}

.index-card__title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: var(--space-2);
  cursor: pointer;
}

.index-card__title input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.index-card__preview {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}

.index-card__doi {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.empty-note {
  font-size: 14px;
  color: var(--ink-faint);
  font-style: italic;
  margin: 0;
}

/* ---------- Saved reference ledger ---------- */
.ledger {
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-4);
}

.ledger-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: var(--space-3) 0;
  border-bottom: 1.5px dashed var(--hairline);
}

.ledger-item span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-item span:last-child { flex-shrink: 0; color: var(--ink-muted); }

.ledger-item:last-child { border-bottom: none; }

/* ---------- APA list ---------- */
.apa-item {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding: var(--space-3) 0;
  border-bottom: 1.5px dashed var(--hairline);
  overflow-wrap: anywhere;
}

.apa-item:last-child { border-bottom: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  box-shadow: 5px 5px 0 var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast--visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 780px;
  margin: 0 auto;
  padding: var(--space-5) clamp(var(--space-5), 5vw, 48px) var(--space-10);
  border-top: 2px dashed var(--hairline);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
}

/* ---------- Accessibility & motion ---------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .case-file::before { left: var(--space-5); }
  .exhibit { padding-left: var(--space-7); }

  .query-row { flex-direction: column; align-items: stretch; }
  .query-row .btn { width: 100%; }

  .btn-row .btn { width: 100%; }

  .btn--full-sm { width: 100%; }
}