/* TAG APA Paper Studio — scoped under .apa-module so these very-specific
   selectors (.tab, .panel, .card-box, .modal, etc.) never bleed into other
   routes. Colors are mapped onto the shared TAG design system; the
   module's own --ink/--paper/--gold already matched navy/cream/gold
   exactly, so this is close to a 1:1 port (Build Spec 3.1 / 5.3). */

.apa-module {
  --apa-ink-soft: #3B5170;
  --apa-gold-dark: #9C7E31;
  --apa-line: #E0D8C3;
  --apa-serif: 'IBM Plex Serif', Georgia, serif;
}

.apa-module .apa-app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 880px) {
  .apa-module .apa-app {
    grid-template-columns: 1fr;
  }
}

.apa-module input[type=text],
.apa-module input[type=number],
.apa-module select,
.apa-module textarea {
  width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 9px;
  border: 1px solid var(--apa-line);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
}
.apa-module textarea { resize: vertical; }
.apa-module input:focus, .apa-module select:focus, .apa-module textarea:focus {
  outline: 2px solid var(--gold); outline-offset: 1px;
}
.apa-module label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--apa-ink-soft); display: block; margin: 8px 0 3px;
}

.apa-module .apa-btn {
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 8px 12px;
  border-radius: 6px; border: 1px solid transparent; cursor: pointer;
}
.apa-module .apa-btn-gold { background: var(--gold); color: #fff; }
.apa-module .apa-btn-gold:hover { background: var(--apa-gold-dark); }
.apa-module .apa-btn-ghost { background: transparent; color: var(--apa-ink-soft); border: 1px solid var(--apa-line); }
.apa-module .apa-btn-ghost:hover { border-color: var(--apa-ink-soft); color: var(--navy); }
.apa-module .apa-btn-sm { font-size: 11px; padding: 5px 9px; }
.apa-module .apa-btn-xs { font-size: 10.5px; padding: 4px 8px; }
.apa-module .apa-btn-block { width: 100%; }

/* ---------- Reference library sidebar ---------- */
.apa-module .apa-sidebar {
  background: #fff; border: 1px solid var(--apa-line); border-radius: 10px;
  padding: 18px; display: flex; flex-direction: column; gap: 12px; max-height: 82vh;
}
.apa-module .apa-lib-header { display: flex; align-items: center; justify-content: space-between; }
.apa-module .apa-lib-header h2 { font-family: var(--apa-serif); font-size: 13.5px; margin: 0; }
.apa-module .apa-count-pill {
  font-size: 11px; background: var(--cream); border: 1px solid var(--apa-line);
  border-radius: 20px; padding: 2px 8px; color: var(--apa-ink-soft);
}
.apa-module .apa-ref-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.apa-module .apa-ref-card {
  background: var(--cream); border: 1px solid var(--apa-line); border-left: 3px solid var(--gold);
  border-radius: 4px; padding: 9px 10px; position: relative;
}
.apa-module .apa-ref-card .apa-tag {
  position: absolute; top: 8px; right: 9px; font-size: 9px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--apa-gold-dark); background: #fff; border: 1px solid var(--apa-line);
  border-radius: 3px; padding: 1px 5px;
}
.apa-module .apa-ref-card .apa-who { font-family: var(--apa-serif); font-size: 12.5px; font-weight: 600; margin: 0 40px 2px 0; }
.apa-module .apa-ref-card .apa-what { font-size: 11.5px; color: var(--apa-ink-soft); margin: 0 0 8px; font-style: italic; line-height: 1.35; }
.apa-module .apa-ref-card .apa-actions { display: flex; gap: 6px; }
.apa-module .apa-empty-hint { font-size: 12px; color: var(--apa-ink-soft); text-align: center; padding: 24px 6px; line-height: 1.5; }

/* ---------- Main / tabs ---------- */
.apa-module .apa-topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.apa-module .apa-paper-switch { display: flex; align-items: center; gap: 8px; }
.apa-module .apa-paper-switch select { width: auto; min-width: 200px; }
.apa-module .apa-save-state { font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 5px; }
.apa-module .apa-save-state .apa-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.apa-module .apa-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--apa-line); margin-bottom: 20px; }
.apa-module .apa-tab { font-family: var(--apa-serif); font-size: 13.5px; padding: 9px 16px; cursor: pointer; color: var(--apa-ink-soft); border-bottom: 2px solid transparent; }
.apa-module .apa-tab.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }
.apa-module .apa-panel { display: none; }
.apa-module .apa-panel.active { display: block; }

.apa-module .apa-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.apa-module .apa-card-box { background: #fff; border: 1px solid var(--apa-line); border-radius: 8px; padding: 18px 20px; margin-bottom: 18px; }
.apa-module .apa-card-box h3 { font-family: var(--apa-serif); font-size: 14.5px; margin: 0 0 4px; color: var(--navy); }
.apa-module .apa-card-box .apa-sub { font-size: 11.5px; color: var(--apa-ink-soft); margin: 0 0 12px; }

.apa-module .apa-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.apa-module .apa-word-count { font-size: 11px; color: var(--apa-ink-soft); }

.apa-module .apa-fmt-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; padding: 8px 10px; background: var(--cream); border: 1px solid var(--apa-line); border-radius: 6px; }
.apa-module .apa-fmt-toolbar .apa-grp-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--apa-ink-soft); margin-right: 2px; }
.apa-module .apa-fmt-toolbar .apa-sep { width: 1px; align-self: stretch; background: var(--apa-line); margin: 0 4px; }

.apa-module .apa-editor { background: #fff; border: 1px solid var(--apa-line); border-radius: 6px; padding: 1in; min-height: 520px; line-height: 2; color: #111; }
.apa-module .apa-editor:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.apa-module .apa-editor p { text-indent: 0.5in; margin: 0; }
.apa-module .apa-editor p.apa-heading { text-indent: 0; }
.apa-module .apa-editor table p { text-indent: 0; }

.apa-module .apa-insert-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; padding: 10px; background: var(--cream); border: 1px dashed var(--apa-line); border-radius: 6px; }
.apa-module .apa-insert-strip .apa-lbl { font-size: 11px; color: var(--apa-ink-soft); align-self: center; margin-right: 4px; }
.apa-module .apa-chip { font-size: 11.5px; background: #fff; border: 1px solid var(--apa-line); border-radius: 20px; padding: 4px 10px; cursor: pointer; font-family: inherit; }
.apa-module .apa-chip:hover { border-color: var(--gold); color: var(--apa-gold-dark); }

.apa-module .apa-page-divider { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; color: var(--apa-ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.apa-module .apa-page-divider::before, .apa-module .apa-page-divider::after { content: ''; flex: 1; height: 1px; background: var(--apa-line); }

.apa-module .apa-preview-page { background: #fff; border: 1px solid var(--apa-line); box-shadow: 0 2px 10px rgba(0,0,0,.05); padding: 1in; line-height: 2; color: #111; margin-bottom: 6px; min-height: 11in; }
.apa-module .apa-preview-page .apa-pagehead { display: flex; justify-content: flex-end; font-size: 12pt; margin-bottom: .4in; }
.apa-module .apa-titleblock { text-align: center; margin-top: 1.8in; }
.apa-module .apa-titleblock .apa-ptitle { font-weight: 700; margin-bottom: .4in; }
.apa-module .apa-abs-heading { font-weight: 700; text-align: center; margin: 0 0 .3in; }
.apa-module .apa-abs-body { margin: 0 0 .25in; }
.apa-module .apa-kw-line { margin: 0; }
.apa-module .apa-kw-line em { font-style: italic; }
.apa-module .apa-refs-heading { font-weight: 700; text-align: center; margin-bottom: 0; }
.apa-module .apa-refitem { padding-left: .5in; text-indent: -.5in; margin: 0; }
.apa-module .apa-body-content p { text-indent: 0.5in; margin: 0; }
.apa-module .apa-body-content p.apa-heading { text-indent: 0; }
.apa-module .apa-body-content table p { text-indent: 0; }

.apa-module .apa-checklist { display: flex; flex-direction: column; gap: 7px; }
.apa-module .apa-cl-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.apa-module .apa-cl-dot { width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.apa-module .apa-cl-ok { background: var(--green); }
.apa-module .apa-cl-no { background: #C9C2AE; color: var(--apa-ink-soft); }

.apa-module .apa-radio-row { display: flex; gap: 14px; font-size: 12.5px; margin-top: 4px; flex-wrap: wrap; }
.apa-module .apa-radio-row label { text-transform: none; letter-spacing: 0; font-size: 12.5px; display: flex; align-items: center; gap: 5px; color: var(--navy); margin: 0; }
.apa-module .apa-check-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin-top: 6px; }
.apa-module .apa-check-row label { text-transform: none; letter-spacing: 0; margin: 0; color: var(--navy); }

.apa-module .apa-modal-backdrop { position: fixed; inset: 0; background: rgba(10,34,64,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.apa-module .apa-modal { background: #fff; border-radius: 10px; padding: 22px 24px; max-width: 480px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.apa-module .apa-modal h3 { font-family: var(--apa-serif); margin: 0 0 14px; font-size: 16px; color: var(--navy); }
.apa-module .apa-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.apa-module .apa-author-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.apa-module .apa-author-row input { flex: 1; }
.apa-module .apa-rm-x { background: none; border: none; color: var(--red); cursor: pointer; font-size: 15px; padding: 0 4px; }

.apa-module .apa-lookup-row { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 2px; }
.apa-module .apa-lookup-row input { flex: 1; }
.apa-module .apa-lookup-status { font-size: 11px; margin-top: 5px; min-height: 14px; }
.apa-module .apa-lookup-status.ok { color: var(--green); }
.apa-module .apa-lookup-status.err { color: var(--red); }
.apa-module .apa-lookup-status.busy { color: var(--apa-gold-dark); }
