/* ==============================
   DETECTIVE FIELD APP — STYLES
   Mobile-first, iPad optimized
   ============================== */

:root {
  --navy: #0a1628;
  --navy-mid: #112240;
  --navy-light: #1e3a5f;
  --blue: #1a6eb5;
  --blue-light: #2d8de0;
  --accent: #f0a500;
  --accent-red: #d93025;
  --accent-green: #1e8c45;
  --text: #e8edf3;
  --text-primary: #e8edf3;
  --text-muted: #8da4bf;
  --border: #1e3a5f;
  --card: #112240;
  --input-bg: #0d1f38;
  --white: #ffffff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;

  /* Responsive layout tokens */
  --header-h: 56px;
  --cat-strip-h: 44px;
  --sidebar-w: 220px;
  --dash-side-pad: 12px;
  --dash-tile-gap: 10px;
  --dash-tile-radius: 12px;
  --dash-tile-min: 130px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  position: fixed; /* prevents WKWebView from scrolling window when keyboard appears */
  font-family: var(--font);
  background: var(--navy);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ---- LAYOUT ---- */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.view.active {
  display: flex;
}

/* ---- TOP BAR ---- */

.topbar {
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-title .badge-icon {
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 1;
  min-width: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.topbar-actions::-webkit-scrollbar { display: none; }

.btn-icon {
  background: none;
  border: none;
  color: var(--blue-light);
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active { background: rgba(255,255,255,0.08); }

/* ---- ICR ACCORDION ---- */

.icr-accordion {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.icr-acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.icr-acc-header:active { background: rgba(255,255,255,0.04); }
.icr-acc-chevron {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s;
  line-height: 1;
}
.icr-acc-chevron.open { transform: rotate(90deg); }
.icr-acc-body { padding: 4px 16px 16px; }

/* ICR Person Cards */
.icr-person-card {
  background: var(--navy-mid); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.icr-person-header {
  display: flex; align-items: flex-start; gap: 8px;
}
.icr-person-header strong { font-size: 14px; display: block; }
.icr-person-descriptor {
  font-size: 12px; color: var(--accent); font-weight: 600;
  background: rgba(240,165,0,0.12); padding: 2px 8px; border-radius: 10px;
}
.icr-person-summary {
  font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Quick-fill chips on ICR person form */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.chip-quick {
  background: var(--navy-mid); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 20px;
  padding: 5px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip-quick.active,
.chip-quick:active {
  background: var(--blue); border-color: var(--blue-light);
  color: #fff;
}

/* CAD Scratch Pad */
.cad-pad-toolbar { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.cad-pad-hint { font-size:12px; color:var(--text-muted); }
.cad-entry {
  background: var(--navy-mid); border-radius: 6px;
  padding: 8px 12px; margin-bottom:6px; font-size:13px;
}
.cad-entry-time { font-size:11px; color:var(--accent); font-weight:700; margin-bottom:3px; font-family:monospace; }
.cad-entry-text { color:var(--text); line-height:1.5; }

/* Small button variant */
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---- SCROLL BODY ---- */

.scroll-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ---- SECTION HEADERS ---- */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- CARDS ---- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.card:active {
  background: var(--navy-light);
  border-color: var(--blue);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
}

.card-chevron {
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
}

/* ---- BADGES / PILLS ---- */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.pill-suspect   { background: rgba(217,48,37,0.18); color: #ff7066; border: 1px solid rgba(217,48,37,0.35); }
.pill-victim    { background: rgba(240,165,0,0.15); color: #fbc02d; border: 1px solid rgba(240,165,0,0.3); }
.pill-witness   { background: rgba(45,141,224,0.15); color: #5ab3f5; border: 1px solid rgba(45,141,224,0.3); }
.pill-vehicle   { background: rgba(100,80,200,0.18); color: #b39dff; border: 1px solid rgba(100,80,200,0.3); }
.pill-property  { background: rgba(30,140,69,0.18); color: #5dd08a; border: 1px solid rgba(30,140,69,0.3); }
.pill-location  { background: rgba(0,150,136,0.18); color: #4dd0c4; border: 1px solid rgba(0,150,136,0.3); }
.pill-cctv      { background: rgba(123,97,255,0.18); color: #c5b8ff; border: 1px solid rgba(123,97,255,0.3); }
.pill-statement { background: rgba(240,165,0,0.12); color: #ffd54f; border: 1px solid rgba(240,165,0,0.25); }
.pill-open      { background: rgba(45,141,224,0.15); color: #5ab3f5; border: 1px solid rgba(45,141,224,0.3); }
.pill-closed    { background: rgba(30,140,69,0.15); color: #5dd08a; border: 1px solid rgba(30,140,69,0.3); }

/* ---- ENTITY TYPE GRID ---- */

.entity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.entity-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.entity-btn:active {
  background: var(--navy-light);
  border-color: var(--blue);
}
.entity-btn .icon {
  font-size: 28px;
  line-height: 1;
}
.entity-btn .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ---- FORMS ---- */

.form-section {
  margin-bottom: 24px;
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-label .required {
  color: var(--accent-red);
  margin-left: 2px;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue-light);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238da4bf' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
select option { background: var(--navy-mid); color: var(--text); }

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- BUTTONS ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { opacity: 0.85; transform: scale(0.98); }

.btn-primary {
  background: var(--blue);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--blue-light); }

.btn-danger {
  background: rgba(217,48,37,0.18);
  color: #ff7066;
  border: 1px solid rgba(217,48,37,0.35);
  width: 100%;
}

.btn-secondary {
  background: var(--navy-light);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-accent {
  background: var(--accent);
  color: var(--navy);
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--blue);
  color: var(--white);
  font-size: 28px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(26,110,181,0.5);
  cursor: pointer;
  z-index: 50;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.94); }

/* ---- EMPTY STATE ---- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 52px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.empty-state .hint {
  font-size: 13px;
  opacity: 0.6;
}

/* ---- CASE HEADER (in detail view) ---- */

.case-header {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.case-number {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.case-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.case-info-item {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- ENTITY COUNT CHIPS ---- */

.count-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.count-chip {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.count-chip .num {
  font-weight: 700;
  color: var(--text);
}

/* ---- MODAL / SHEET ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  align-items: flex-end;
}
.modal-overlay.active { display: flex; }

.modal-sheet {
  background: var(--navy-mid);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 32px;
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

/* ---- CONFIRM DIALOG ---- */

.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: calc(100% - 40px);
  max-width: 340px;
  text-align: center;
}
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* ---- TOAST ---- */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- SEARCH BAR ---- */

.search-bar {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  width: 100%;
  font-family: var(--font);
  outline: none;
  margin-bottom: 14px;
}
.search-bar:focus { border-color: var(--blue-light); }
.search-bar::placeholder { color: var(--text-muted); opacity: 0.6; }

/* ---- DIVIDER ---- */

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---- DETAIL FIELD (view mode) ---- */

.detail-field {
  margin-bottom: 14px;
}
.detail-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.detail-value {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}
.detail-value.empty { color: var(--text-muted); font-style: italic; font-size: 13px; }

/* ---- BACK BUTTON ---- */

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--blue-light);
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

/* ---- EXPORT BAR ---- */

.export-bar {
  padding: 10px 16px;
  background: var(--navy-mid);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---- RESPONSIVE: iPad split layout ---- */

@media (min-width: 768px) {
  .entity-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .scroll-body {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
  }
  .fab {
    right: calc(50% - 340px + 20px);
  }
  .toast {
    bottom: 30px;
  }
}

@media (min-width: 1024px) {
  .entity-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---- VOICE MIC FAB ---- */
#voice-fab {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--navy-light);
  border: 2px solid var(--blue);
  color: #fff;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
#voice-fab.recording {
  background: #8b0000;
  border-color: #ff4444;
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 16px rgba(255,68,68,0.4); }
  50% { transform: scale(1.1); box-shadow: 0 4px 24px rgba(255,68,68,0.7); }
}

/* ---- NOTE BUILDER BLOCK CARDS ---- */
.nb-block-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px;
  background: var(--navy-mid); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
  min-height: 90px;
}
.nb-block-card.selected {
  border-color: var(--blue-light);
  background: rgba(45,141,224,0.12);
}
.nb-block-icon { font-size: 26px; line-height: 1; }
.nb-block-label { font-size: 12px; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.nb-block-cat { font-size: 10px; color: var(--text-muted); line-height: 1.2; }
.nb-block-num {
  position: absolute; top: 6px; right: 8px;
  background: var(--blue); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: 10px;
  padding: 1px 6px; line-height: 1.4;
}

/* ---- NOTE CHOICE CARDS ---- */
.nb-choice-card {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px; padding: 20px 18px;
  background: var(--navy-mid); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; text-align: left;
  width: 100%; margin-bottom: 14px;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
}
.nb-choice-card:active { border-color: var(--blue-light); background: rgba(45,141,224,0.10); }
.nb-choice-icon { font-size: 32px; line-height: 1; margin-bottom: 4px; }
.nb-choice-label { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.nb-choice-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ---- FOLLOW-UP TASK TRACKER ---- */
.task-add-row {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.task-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--navy-mid); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 12px 12px 10px;
  margin-bottom: 8px; transition: opacity 0.15s;
}
.task-item.task-done { opacity: 0.55; }
.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); background: none;
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
  color: white; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.task-check.checked { background: var(--success, #2E7D52); border-color: var(--success, #2E7D52); }
.task-body { flex: 1; min-width: 0; }
.task-text { font-size: 14px; color: var(--text-primary); line-height: 1.4; }
.task-done .task-text { text-decoration: line-through; color: var(--text-muted); }
.task-meta { display: flex; gap: 10px; margin-top: 5px; flex-wrap: wrap; align-items: center; }
.task-prio { font-size: 11px; color: var(--text-muted); }
.task-due { font-size: 11px; color: var(--text-muted); }
.task-due.overdue { color: var(--danger, #8B2020); font-weight: 700; }
.task-del {
  background: none; border: none; color: var(--text-muted);
  font-size: 14px; cursor: pointer; padding: 0 2px;
  flex-shrink: 0; line-height: 1; margin-top: 2px;
}

/* ---- CASE TIMELINE ---- */
.tl-item {
  display: grid;
  grid-template-columns: 110px 20px 1fr;
  gap: 0 10px;
  margin-bottom: 0;
  min-height: 48px;
}
.tl-time {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding-top: 3px;
  line-height: 1.4;
}
.tl-track {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: var(--blue-light);
}
.tl-dot--incident  { background: var(--danger, #8B2020); }
.tl-dot--case      { background: var(--blue-light); }
.tl-dot--cad       { background: var(--warning, #B8860B); }
.tl-dot--person    { background: var(--blue); }
.tl-dot--vehicle   { background: #6B7A8D; }
.tl-dot--property  { background: #6B7A8D; }
.tl-dot--location  { background: var(--success, #2E7D52); }
.tl-dot--cctv      { background: #8B6914; }
.tl-dot--statement { background: var(--blue-light); }
.tl-dot--supplement{ background: var(--success, #2E7D52); }
.tl-line {
  width: 1px;
  flex: 1;
  background: var(--border);
  margin-top: 4px;
}
.tl-item:last-child .tl-line { display: none; }
.tl-body { padding: 0 0 20px 0; }
.tl-label { font-size: 13px; font-weight: 700; color: var(--text-primary); line-height: 1.4; padding-top: 1px; }
.tl-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

/* ---- PROSECUTION TRACKING ITEMS ---- */
.track-add-form {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.track-item {
  position: relative;
  background: var(--navy-mid);
  border-radius: 8px;
  padding: 10px 36px 10px 12px;
  margin-bottom: 8px;
}
.track-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.track-item-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.track-item-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.track-item-pill {
  font-size: 10px;
  font-weight: 700;
  background: var(--blue);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.3px;
}
.track-item-notes {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.track-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.track-item-del {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.track-item-del:active { color: var(--red, #e53e3e); }

/* ---- RESOURCES LIBRARY ---- */
.res-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.res-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.res-card-header:active { background: rgba(255,255,255,0.04); }
.res-card-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.res-card-info { flex: 1; min-width: 0; }
.res-card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.res-card-summary { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.res-card-cat {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--blue-light);
  margin-bottom: 3px;
}
.res-card-chevron { font-size: 18px; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; }
.res-card-chevron.open { transform: rotate(90deg); }
.res-card-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.res-card-body.open { display: block; }
.res-steps { margin: 12px 0 0; padding-left: 0; list-style: none; counter-reset: step-counter; }
.res-steps li {
  counter-increment: step-counter;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; color: var(--text); line-height: 1.5;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.res-steps li:last-child { border-bottom: none; }
.res-steps li::before {
  content: counter(step-counter);
  min-width: 22px; height: 22px;
  background: var(--blue); color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.res-notes { margin-top: 12px; }
.res-notes-title { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.res-note-item { font-size: 12px; color: var(--text-muted); line-height: 1.5; padding: 4px 0 4px 14px; position: relative; }
.res-note-item::before { content: '⚠'; position: absolute; left: 0; font-size: 10px; }
.res-template-block {
  margin-top: 12px; background: var(--navy); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px;
}
.res-template-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--blue-light); margin-bottom: 6px; }
.res-template-text { font-size: 11px; color: var(--text-muted); line-height: 1.6; white-space: pre-wrap; font-family: monospace; }
.res-copy-btn {
  margin-top: 8px; width: 100%;
  background: var(--navy-light); border: 1px solid var(--border);
  color: var(--blue-light); font-size: 12px; font-weight: 700;
  padding: 8px; border-radius: 6px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.res-copy-btn:active { background: var(--blue); color: #fff; }

/* ---- RESOURCES LIBRARY ---- */
.res-category-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-muted);
  margin: 16px 0 8px;
}
.res-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.res-card-header {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.res-card-header:active { background: rgba(255,255,255,0.04); }
.res-card-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.res-card-title-wrap { flex: 1; min-width: 0; }
.res-card-title { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.res-card-summary { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.res-chevron { font-size: 18px; color: var(--text-muted); transition: transform 0.2s; flex-shrink: 0; margin-top: 2px; }
.res-chevron.open { transform: rotate(90deg); }
.res-card-body { padding: 0 14px 14px; }
.res-steps { padding-left: 18px; margin: 0 0 12px; }
.res-steps li { font-size: 13px; color: var(--text-primary); line-height: 1.6; margin-bottom: 8px; }
.res-notes-label { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--blue-light); margin-bottom: 6px; }
.res-notes { padding-left: 16px; margin: 0 0 12px; }
.res-notes li { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 4px; }
.res-template-label { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.res-template {
  background: var(--navy); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 11px; color: var(--text-muted);
  white-space: pre-wrap; line-height: 1.5; font-family: monospace;
}

/* ============================================================
   ABBREVIATION BUILDER
   ============================================================ */
.abbrev-group-label {
  font-size: 10px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-muted);
  padding: 10px 0 4px;
}
.abbrev-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 8px;
}
.abbrev-info { flex: 1; min-width: 0; }
.abbrev-acronym {
  font-size: 14px; font-weight: 800; color: var(--blue-light);
  letter-spacing: 1px; margin-right: 8px;
}
.abbrev-full {
  font-size: 12px; color: var(--text-secondary);
  display: block; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.abbrev-scope {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  display: inline-block; margin-top: 3px;
}
.abbrev-scope.global { color: var(--accent); }
.abbrev-del-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px;
  padding: 4px 8px; border-radius: 4px; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.abbrev-del-btn:hover { background: rgba(255,80,80,0.12); color: #ff5050; }
.abbrev-output-block {
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 12px 14px;
  font-size: 13px; line-height: 1.6; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
}

/* ---- STATUS BAR SAFE AREA ---- */
@supports (padding-top: env(safe-area-inset-top)) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .export-bar { padding-bottom: env(safe-area-inset-bottom); }
  .fab { bottom: calc(24px + env(safe-area-inset-bottom)); }
}
