/* =====================================================
   INDONESIA LAW AI — STYLESHEET
   Refined legal-professional aesthetic
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ─── Variables ─── */
:root {
  --bg: #f7f5f0;
  --bg2: #efecea;
  --surface: #ffffff;
  --surface2: #f2efeb;
  --border: #ddd9d2;
  --border2: #ccc8c0;
  --text: #1a1714;
  --text2: #5a5550;
  --text3: #8a847c;
  --accent: #b5490a;
  --accent-hover: #9c3d08;
  --accent-light: #fef3ec;
  --user-bg: #1a1714;
  --user-text: #f7f5f0;
  --sidebar-w: 260px;
  --topbar-h: 52px;
  --radius: 10px;
  --radius-sm: 6px;
  --font-body: 'DM Sans', sans-serif;
  --font-serif: 'Libre Baskerville', serif;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

body.dark {
  --bg: #141210;
  --bg2: #1c1a17;
  --surface: #201e1b;
  --surface2: #272420;
  --border: #2e2b27;
  --border2: #3a3730;
  --text: #f0ece6;
  --text2: #a09890;
  --text3: #6a6460;
  --accent: #e05a12;
  --accent-hover: #c94e0e;
  --accent-light: #2a1a10;
  --user-bg: #2a2520;
  --user-text: #f0ece6;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Layout ─── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.logo svg { color: var(--accent); flex-shrink: 0; }

.sidebar-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text2); cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* Language bar */
.lang-bar {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.lang-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover { border-color: var(--border2); color: var(--text2); }
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Conversations */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-track { background: transparent; }
.conversations-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  group: true;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: var(--accent-light); }
.conv-item.active .conv-item-title { color: var(--accent); font-weight: 500; }

.conv-item-title {
  flex: 1;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.delete-btn {
  width: 24px; height: 24px;
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.conv-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { background: #fee2e2; color: #dc2626; }
body.dark .delete-btn:hover { background: #3f1515; color: #f87171; }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.theme-btn:hover { background: var(--surface2); color: var(--text); }

/* ─── Main ─── */
.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Two-column body: chat + right panel */
.main-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Right panel (desktop permanent graph) ─── */
.right-panel {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
}

.right-panel-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.right-panel-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.right-panel-subtitle {
  font-size: 11px;
  color: var(--text3);
}

.right-panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 12px;
  color: var(--text3);
  text-align: center;
}

.right-panel-empty-icon {
  font-size: 28px;
  opacity: 0.3;
}

.right-panel-empty-text {
  font-size: 12px;
  line-height: 1.6;
  max-width: 200px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sidebar-toggle { display: none; }

/* ─── Messages container ─── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.messages-container::-webkit-scrollbar { width: 5px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─── Welcome screen ─── */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 20px;
}

.welcome-inner {
  text-align: center;
  max-width: 560px;
  width: 100%;
}

.welcome-icon {
  font-size: 44px;
  margin-bottom: 16px;
  display: block;
}

.welcome-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 9px 16px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  font-size: 13px;
  font-family: var(--font-body);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ─── Messages ─── */
.messages {
  padding: 24px 0 16px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 12px;
  padding: 8px 20px;
  margin-bottom: 4px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.message.user .message-avatar {
  background: var(--user-bg);
  color: var(--user-text);
}

.message.assistant .message-avatar {
  background: var(--accent);
  color: #fff;
}

.message-content { flex: 1; min-width: 0; }

.message-role {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 5px;
}

.message-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  word-wrap: break-word;
}

.message-text h1, .message-text h2 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.message-text h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--text);
}

.message-text p { margin-bottom: 10px; }
.message-text p:last-child { margin-bottom: 0; }

.message-text ul, .message-text ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.message-text li { margin-bottom: 4px; }

.message-text strong { font-weight: 600; color: var(--text); }

.message-text code {
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 13px;
  background: var(--surface2);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.message-text pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.message-text pre code { background: none; border: none; padding: 0; }

.message-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text2);
  font-style: italic;
  margin: 10px 0;
}

/* Loading dots */
.message-text.loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  background: var(--text3);
  border-radius: 50%;
  animation: pulse 1s infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.streaming-cursor::after {
  content: '▍';
  display: inline;
  color: var(--accent);
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Sources */
.message-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.sources-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 12px;
  font-size: 11.5px;
  color: var(--text2);
  max-width: 240px;
}

.source-chip svg { flex-shrink: 0; color: var(--accent); }

.source-chip-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-chip-status {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  flex-shrink: 0;
}
.source-chip-status.active { background: #d1fae5; color: #065f46; }
.source-chip-status.amended { background: #fef3c7; color: #92400e; }
.source-chip-status.revoked { background: #fee2e2; color: #991b1b; }
body.dark .source-chip-status.active { background: #064e3b; color: #6ee7b7; }
body.dark .source-chip-status.amended { background: #451a03; color: #fcd34d; }
body.dark .source-chip-status.revoked { background: #450a0a; color: #fca5a5; }

/* ─── Input area ─── */
.input-area {
  padding: 12px 20px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.attached-files-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 0;
}

.attached-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text2);
  max-width: 220px;
}

.attached-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attached-file-remove {
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  padding: 0; display: flex; align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.attached-file-remove:hover { color: #dc2626; }

/* Upload progress */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.upload-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.upload-progress-text {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}

/* Form */
.input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px 8px;
  box-shadow: var(--shadow);
  max-width: 760px;
  margin: 0 auto;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 73, 10, 0.1);
}

.attach-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.attach-btn:hover { background: var(--surface2); color: var(--text2); }

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  resize: none;
  outline: none;
  max-height: 150px;
  line-height: 1.5;
  padding: 4px 0;
}
.message-input::placeholder { color: var(--text3); }
.message-input::-webkit-scrollbar { width: 3px; }
.message-input::-webkit-scrollbar-thumb { background: var(--border2); }

.send-btn {
  width: 32px; height: 32px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 8px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Sidebar overlay (mobile) ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Admin styles ─── */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.admin-login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.admin-login-box h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text);
}

.admin-login-box p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 24px;
}

.admin-login-form { display: flex; flex-direction: column; gap: 10px; }

.admin-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.admin-input:focus { border-color: var(--accent); }

select.admin-input { cursor: pointer; }

.admin-textarea { resize: vertical; }

.admin-login-btn {
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.admin-login-btn:hover { background: var(--accent-hover); }

.admin-error {
  font-size: 13px;
  color: #dc2626;
  margin-top: 4px;
}

/* Admin page */
.admin-page { min-height: 100vh; background: var(--bg); }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header .logo {
  font-size: 15px;
}

.admin-header-actions { display: flex; align-items: center; gap: 10px; }

.admin-link-btn {
  padding: 7px 14px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s;
}
.admin-link-btn:hover { border-color: var(--text2); color: var(--text); }

.admin-logout-btn {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.admin-logout-btn:hover { border-color: #dc2626; color: #dc2626; }

.admin-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.admin-card h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.admin-card-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 18px;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-card-header h2 { margin-bottom: 0; }

.admin-doc-count {
  font-size: 12px;
  color: var(--text3);
  background: var(--surface2);
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.admin-upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text3);
}
.admin-upload-zone:hover, .admin-upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.admin-upload-zone svg { margin-bottom: 10px; }
.admin-upload-zone p { font-size: 14px; }
.upload-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.admin-form-group { display: flex; flex-direction: column; gap: 5px; }
.admin-form-group label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.03em; }

.admin-preview-info {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
}

.admin-upload-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.admin-cancel-btn {
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.admin-cancel-btn:hover { border-color: var(--text2); color: var(--text); }

.admin-upload-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.admin-upload-btn:hover { background: var(--accent-hover); }
.admin-upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-upload-status {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
.admin-upload-status.success { color: #059669; }
.admin-upload-status.error { color: #dc2626; }

/* Docs list */
.admin-docs-list { display: flex; flex-direction: column; gap: 8px; }

.admin-doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.admin-doc-row:hover { border-color: var(--border2); }

.admin-doc-info { flex: 1; min-width: 0; }

.admin-doc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-doc-meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-doc-badge {
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-berlaku { background: #d1fae5; color: #065f46; }
.badge-diubah { background: #fef3c7; color: #92400e; }
.badge-dicabut { background: #fee2e2; color: #991b1b; }
body.dark .badge-berlaku { background: #064e3b; color: #6ee7b7; }
body.dark .badge-diubah { background: #451a03; color: #fcd34d; }
body.dark .badge-dicabut { background: #450a0a; color: #fca5a5; }

.admin-doc-delete {
  width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.admin-doc-delete:hover { background: #fee2e2; color: #dc2626; }
body.dark .admin-doc-delete:hover { background: #3f1515; color: #f87171; }

.admin-empty {
  text-align: center;
  padding: 32px;
  color: var(--text3);
  font-size: 14px;
}

/* ─── Responsive ─── */
/* Mobile responsive styles at end of file */

/* ─── Demo Controls ─── */
.demo-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .demo-controls-grid { grid-template-columns: 1fr; }
}

.demo-control-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.demo-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface2);
  gap: 12px;
}

.demo-control-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.demo-control-desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
}

.demo-control-body {
  padding: 14px 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.demo-control-body.visible { display: flex; }

.demo-control-hint {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.password-input-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.password-input-row .admin-input { flex: 1; }
.password-input-row .admin-upload-btn { white-space: nowrap; flex-shrink: 0; }

.demo-save-status {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  min-height: 20px;
}
.demo-save-status.success { color: #059669; }
.demo-save-status.error { color: #dc2626; }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 22px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Message counter in chat */
.message-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text2);
  margin: 0 auto 8px;
  width: fit-content;
}

.message-counter.warning { color: #b45309; border-color: #fcd34d; background: #fef3c7; }
.message-counter.critical { color: #dc2626; border-color: #fca5a5; background: #fee2e2; }
body.dark .message-counter.warning { color: #fcd34d; border-color: #92400e; background: #451a03; }
body.dark .message-counter.critical { color: #f87171; border-color: #991b1b; background: #450a0a; }

.counter-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Embed button + status ─────────────────────────────── */
.admin-doc-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-doc-row:last-child { border-bottom: none; }
.admin-doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
}
.admin-embed-btn {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.admin-embed-btn:hover { background: #dcfce7; border-color: #86efac; }
.admin-embed-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.embed-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.embed-badge-done    { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.embed-badge-pending { background: #fafafa; color: #888;    border: 1px solid #e5e7eb; }
.embed-progress {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text2);
}

/* ── Chunk Browser ─────────────────────────────────────── */
#admin-chunk-browser {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chunk-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.chunk-count-label { font-weight: 400; color: var(--text2); font-size: 12px; }
.chunk-method-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
.chunk-method-pasal     { background: #dcfce7; color: #166534; }
.chunk-method-paragraph { background: #fef9c3; color: #854d0e; }
.chunk-browser-list { max-height: 300px; overflow-y: auto; }
.chunk-row {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.chunk-row:last-child { border-bottom: none; }
.chunk-row-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.chunk-pasal-ref { font-weight: 600; color: var(--accent); font-size: 11.5px; }
.chunk-pasal-none { color: var(--text2); font-weight: 400; }
.chunk-section-header {
  font-size: 10.5px; color: var(--text2);
  background: var(--surface2); padding: 1px 6px; border-radius: 3px;
}
.chunk-row-preview {
  color: var(--text2); line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chunk-browser-more {
  padding: 7px 14px; font-size: 12px; color: var(--text2);
  background: var(--surface2); border-top: 1px solid var(--border); text-align: center;
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {

  html, body { height: 100%; overflow: hidden; }

  .app {
    height: 100dvh;
    overflow: hidden;
  }

  /* Hide right panel on mobile — graph accessible via ⬡ button slide-in */
  .right-panel { display: none; }

  /* main-body is now just the chat column */
  .main-body { flex-direction: column; }
  .chat-column { flex: 1; }

  /* Sidebar: slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-md);
    width: min(280px, 85vw);
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay: display block but pointer-events none until visible */
  .sidebar-overlay { display: block; }
  .sidebar-toggle { display: flex; }

  .main {
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar { padding: 0 12px; flex-shrink: 0; }
  .topbar-title { font-size: 13px; }

  .messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .welcome-screen {
    padding: 32px 16px 24px;
    min-height: unset;
    align-items: flex-start;
  }
  .welcome-inner { max-width: 100%; }
  .welcome-icon { font-size: 32px; margin-bottom: 10px; }
  .welcome-title { font-size: 22px; }
  .welcome-subtitle { font-size: 14px; margin-bottom: 20px; }

  .chips { gap: 6px; }
  .chip {
    font-size: 12px;
    padding: 8px 14px;
    white-space: normal;
    text-align: left;
  }

  .messages { padding: 16px 0 8px; width: 100%; }
  .message-row { padding: 6px 12px; }
  .message-bubble { max-width: 88%; font-size: 14px; line-height: 1.6; }

  .input-area {
    padding: 8px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    flex-shrink: 0;
  }

  .input-form { max-width: 100%; margin: 0; padding: 5px 6px; }

  /* 16px prevents iOS auto-zoom on input focus */
  .message-input { font-size: 16px; max-height: 120px; }

  .attach-btn, .send-btn { width: 36px; height: 36px; flex-shrink: 0; }
  .input-disclaimer { font-size: 10px; margin-top: 6px; max-width: 100%; }
  .admin-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .welcome-title { font-size: 19px; }
  .chip { font-size: 11px; padding: 7px 12px; }
  .message-bubble { max-width: 94%; font-size: 13px; }
  .sidebar { width: 90vw; }
}

/* ─── Citation Side Panel ────────────────────────────────────────────────── */
.inline-citation {
  cursor: pointer;
  color: #8B1A00;
  border-bottom: 1px dashed #8B1A00;
  border-radius: 2px;
  padding: 0 1px;
  transition: background 0.15s;
}
.inline-citation:hover { background: #FDF0EB; }
.citation-icon {
  font-size: 0.72em;
  margin-left: 3px;
  opacity: 0.6;
  font-style: normal;
}
.general-knowledge-tag {
  background: #FFF8E6;
  color: #7A5A00;
  font-size: 0.82em;
  border-radius: 3px;
  padding: 1px 5px;
  border: 1px solid #E8D8A0;
  font-style: italic;
}

/* Overlay */
.citation-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 1000;
  backdrop-filter: blur(1px);
}
.citation-overlay.open { display: block; }

/* Panel */
.citation-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 440px;
  max-width: 92vw;
  height: 100vh;
  background: #FFFFFF;
  box-shadow: -4px 0 32px rgba(0,0,0,0.14);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: right 0.26s cubic-bezier(0.4,0,0.2,1);
}
.citation-panel.open { right: 0; }

/* Header */
.citation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #EDE8E3;
  background: #FAF7F4;
  flex-shrink: 0;
}
.citation-panel-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.citation-badge {
  background: #8B1A00;
  color: #fff;
  font-size: 0.68em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.citation-level-badge {
  background: #EDE8E3;
  color: #5A4A3A;
  font-size: 0.68em;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
}
.citation-status-badge {
  font-size: 0.68em;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
}
.citation-status-badge.berlaku { background: #E6F4EA; color: #1A6B2A; }
.citation-status-badge.diubah  { background: #FFF8E6; color: #7A5A00; }
.citation-status-badge.dicabut { background: #FDECEA; color: #8B1A00; }

.citation-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #8A7A6A;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.citation-panel-close:hover { background: #EDE8E3; color: #3D2B1F; }

/* Title + meta */
.citation-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1A1714;
  padding: 14px 18px 2px;
  flex-shrink: 0;
  line-height: 1.35;
}
.citation-panel-nomor {
  font-size: 0.8rem;
  color: #6A5A4A;
  padding: 2px 18px 4px;
  flex-shrink: 0;
}
.citation-panel-pasal {
  font-size: 0.82rem;
  font-weight: 600;
  color: #8B1A00;
  padding: 4px 18px 12px;
  border-bottom: 1px solid #EDE8E3;
  flex-shrink: 0;
}

/* Scrollable body */
.citation-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  -webkit-overflow-scrolling: touch;
}
.citation-loading,
.citation-not-found {
  color: #8A7A6A;
  font-size: 0.88rem;
  text-align: center;
  padding: 40px 0;
  line-height: 1.7;
}
.chunk-block { margin-bottom: 4px; }
.chunk-pasal-ref {
  font-size: 0.75rem;
  font-weight: 700;
  color: #8B1A00;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chunk-section {
  font-size: 0.76rem;
  color: #6A5A4A;
  font-style: italic;
  margin-bottom: 6px;
}
.chunk-text {
  font-size: 0.87rem;
  color: #2A2218;
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: Georgia, 'Times New Roman', serif;
}
.ayat-highlight {
  display: block;
  background: #FFF8E6;
  border-left: 3px solid #C97A00;
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  margin: 2px 0;
}
.citation-embedded-note {
  margin-top: 14px;
  padding: 8px 12px;
  font-size: 11px;
  color: #7a5900;
  background: #fff8e6;
  border-left: 3px solid #e6a817;
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
}
.dark-mode .citation-embedded-note {
  background: #2A2010;
  color: #C8A04A;
  border-left-color: #8A6820;
}

.chunk-divider {
  border-top: 1px dashed #D4C4B8;
  margin: 14px 0;
}

/* JDIH link — only shown after client-side verification passes */
.citation-jdih-wrap {
  border-top: 1px solid #EDE8E3;
  flex-shrink: 0;
  background: #FAF7F4;
}
.citation-jdih-link {
  display: block;
  text-align: center;
  padding: 12px;
  font-size: 0.82rem;
  color: #8B1A00;
  text-decoration: none;
  font-weight: 500;
}
.citation-jdih-link:hover { background: #F2EDE8; text-decoration: underline; }

/* Dark mode */
.dark-mode .citation-panel         { background: #1A1714; box-shadow: -4px 0 32px rgba(0,0,0,0.4); }
.dark-mode .citation-panel-header  { background: #221E1A; border-color: #3D3530; }
.dark-mode .citation-panel-title   { color: #EDE8E3; }
.dark-mode .citation-panel-nomor   { color: #A09080; }
.dark-mode .citation-panel-pasal   { color: #C97A60; border-color: #3D3530; }
.dark-mode .citation-panel-pasal   { border-color: #3D3530; }
.dark-mode .citation-panel-body    { background: #1A1714; }
.dark-mode .ayat-highlight         { background: #2A2010; border-left-color: #C97A60; }
.dark-mode .chunk-text             { color: #D4C4B4; }
.dark-mode .chunk-pasal-ref        { color: #C97A60; }
.dark-mode .chunk-section          { color: #A09080; }
.dark-mode .chunk-divider          { border-color: #3D3530; }
.dark-mode .citation-jdih-wrap     { background: #221E1A; border-color: #3D3530; }
.dark-mode .citation-jdih-link     { color: #C97A60; }
.dark-mode .citation-jdih-link:hover { background: #2A2420; }
.dark-mode .citation-level-badge   { background: #3D3530; color: #C4B4A4; }
.dark-mode .citation-panel-close   { color: #A09080; }
.dark-mode .citation-panel-close:hover { background: #3D3530; color: #EDE8E3; }
.dark-mode .inline-citation        { color: #C97A60; border-color: #C97A60; }
.dark-mode .inline-citation:hover  { background: #2A1A14; }

/* Mobile */
@media (max-width: 768px) {
  .citation-panel { width: 100vw; right: -100vw; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   LIBRARY MODE  —  Complete layout rewrite fixing the page-repeat bug
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Mode tabs ───────────────────────────────────────────────────────────── */
.mode-tabs { display:flex; align-items:center; gap:3px; background:#F3EDE8; border-radius:8px; padding:3px; }
.mode-tab {
  display:flex; align-items:center; gap:5px; padding:5px 14px;
  border:none; border-radius:6px; background:transparent; color:#7A6A60;
  font-size:13px; font-weight:500; cursor:pointer; transition:all .15s;
}
.mode-tab:hover { background:#EDE5DF; color:#3D2B20; }
.mode-tab.active { background:#fff; color:#8B1A1A; font-weight:600; box-shadow:0 1px 3px rgba(0,0,0,.12); }

/* ── FIX: mode-panel replaces the old library-mode display clash ─────────── */
/* Both ask-mode and library-mode are .mode-panel children of .main           */
/* .main is flex-column; only one mode-panel is visible at a time             */
.mode-panel {
  flex: 1;          /* fill remaining height after topbar */
  min-height: 0;    /* allow flex children to shrink */
  overflow: hidden;
  display: none;    /* hidden by default — JS sets display:flex or display:flex */
}
.mode-panel.active {
  display: flex;
}
/* ask-mode is main-body layout (row: chat + right panel) */
#ask-mode.active  { flex-direction: row; }
/* library-mode is column layout */
#library-mode.active { flex-direction: column; background: #FAFAF8; min-height:0; }

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.lib-breadcrumb {
  display:flex; align-items:center; gap:6px;
  padding:9px 20px 0; font-size:13px; color:#9A8A80; flex-shrink:0;
}
.lib-bc-home { color:#8B1A1A; cursor:pointer; }
.lib-bc-home:hover { text-decoration:underline; }
.lib-bc-sep  { color:#C4B4AA; }
.lib-bc-cur  { color:#3D2B20; font-weight:500; }

/* ── Split container ─────────────────────────────────────────────────────── */
.lib-split {
  flex: 1; display:flex; overflow:hidden; min-height:0;
}

/* LEFT column — search + results list */
.lib-left {
  width: 400px;
  min-width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1.5px solid #EDE5DF;
  padding: 12px 16px 0;
}

/* RIGHT column — detail + reader panels */
.lib-right {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}
.lib-right-pane {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px 32px;
}
/* Reader overrides: no padding, no scroll on pane itself — canvas handles it */
#lib-reader-view.lib-right-pane {
  overflow: hidden; padding: 0;
  display: flex; flex-direction: column;
  /* grid is on lib-reader-wrap child, not here */
}

/* ── Search bar ──────────────────────────────────────────────────────────── */
.lib-searchbar-wrap { display:flex; gap:7px; flex-shrink:0; margin-bottom:9px; }
.lib-searchbar {
  flex:1; padding:8px 12px; border:1.5px solid #DDD5CE; border-radius:7px;
  font-size:13px; background:#fff; color:#1A0A06;
}
.lib-searchbar:focus { outline:none; border-color:#8B1A1A; }
.lib-search-btn {
  display:flex; align-items:center; gap:5px; padding:8px 14px;
  background:#8B1A1A; color:#fff; border:none; border-radius:7px;
  font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap;
}
.lib-search-btn:hover { background:#6B1212; }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.lib-filters { display:flex; flex-wrap:wrap; gap:5px; flex-shrink:0; margin-bottom:8px; }
.lib-filter-sel {
  padding:5px 8px; border:1.5px solid #DDD5CE; border-radius:6px;
  font-size:12px; background:#fff; color:#3D2B20; cursor:pointer; flex:1; min-width:90px;
  min-width:160px;
}
.lib-filter-sel:focus { outline:none; border-color:#8B1A1A; }
.lib-filter-inp {
  padding:5px 8px; border:1.5px solid #DDD5CE; border-radius:6px;
  font-size:12px; background:#fff; color:#3D2B20; flex:1; min-width:90px;
}
.lib-filter-inp:focus { outline:none; border-color:#8B1A1A; }
.lib-filter-clear {
  padding:5px 9px; border:1.5px solid #DDD5CE; border-radius:6px;
  font-size:12px; background:#F3EDE8; color:#7A6A60; cursor:pointer; white-space:nowrap;
}
.lib-filter-clear:hover { background:#EDE5DF; }

/* ── Results list ────────────────────────────────────────────────────────── */
.lib-results-meta { font-size:11px; color:#9A8A80; margin-bottom:6px; flex-shrink:0; }
.lib-results-scroll { flex:1; overflow-y:auto; padding-bottom:16px; }
.lib-results { display:flex; flex-direction:column; gap:6px; }

/* Result card */
.lib-card {
  background:#fff; border:1.5px solid #EDE5DF; border-radius:8px;
  padding:10px 12px; cursor:pointer; transition:border-color .15s, box-shadow .15s;
}
.lib-card:hover { border-color:#C4A090; box-shadow:0 2px 6px rgba(139,26,26,.07); }
.lib-card.active { border-color:#8B1A1A; background:#FCEBEB; }
.lib-card-hdr { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:4px; }
.lib-card-nomor { font-size:11px; color:#9A8A80; margin-left:auto; }
.lib-card-title { font-size:13px; font-weight:600; color:#1A0A06; margin:0 0 4px; line-height:1.35; }
.lib-card-abstrak { font-size:12px; color:#6A5A50; margin:0 0 6px; line-height:1.45;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.lib-card-status { border-top:1px solid #F0E8E2; margin:5px 0; padding-top:5px;
  display:flex; flex-direction:column; gap:2px; }
.lib-st-line { font-size:11px; display:flex; align-items:baseline; gap:4px; flex-wrap:wrap; }
.lib-st-label { font-weight:600; white-space:nowrap; }
.lib-sl-diubah-oleh  .lib-st-label { color:#854F0B; }
.lib-sl-dicabut-oleh .lib-st-label { color:#8B1A1A; }
.lib-sl-mengubah     .lib-st-label { color:#185FA5; }
.lib-sl-mencabut     .lib-st-label { color:#5C1A5C; }
.lib-sl-uji-materi   .lib-st-label { color:#0F6E56; }
.lib-st-link { color:#8B1A1A; cursor:pointer; text-decoration:underline;
  text-decoration-color:#C4A090; font-size:11px; }
.lib-st-link:hover { color:#6B1212; }
.lib-st-more { color:#9A8A80; font-size:10px; }
.lib-card-footer { display:flex; align-items:center; gap:6px; margin-top:5px; }
.lib-sector-tag { font-size:10px; padding:1px 6px; background:#F3EDE8; color:#7A6A60;
  border:1px solid #DDD5CE; border-radius:3px;
  max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  display:inline-block; vertical-align:middle; }
.lib-card-actions { margin-left:auto; display:flex; gap:4px; }
.lib-act-btn { font-size:11px; padding:3px 8px; border:1.5px solid #DDD5CE;
  border-radius:5px; background:#F9F5F2; color:#5A4A40; cursor:pointer; }
.lib-act-btn:hover { background:#EDE5DF; border-color:#C4A090; }
.lib-act-ask { border-color:#8B1A1A; color:#8B1A1A; }
.lib-act-ask:hover { background:#FCEBEB; }
.lib-act-read { border-color:#185FA5; color:#185FA5; }
.lib-act-read:hover { background:#E6F1FB; }

/* Pagination */
.lib-pagination { display:flex; gap:4px; justify-content:center; margin-top:14px; flex-wrap:wrap; padding-bottom:8px; }
.lib-page-btn { padding:4px 9px; border:1.5px solid #DDD5CE; border-radius:5px;
  background:#fff; color:#5A4A40; font-size:12px; cursor:pointer; }
.lib-page-btn:hover { background:#F3EDE8; border-color:#C4A090; }
.lib-page-btn.active { background:#8B1A1A; color:#fff; border-color:#8B1A1A; font-weight:600; }

/* Shared badges */
.lib-dt-badge { font-size:10px; font-weight:700; padding:2px 6px; border-radius:3px;
  border:1.5px solid; letter-spacing:.2px; white-space:nowrap; }
.lib-dt-badge-sm { font-size:9px; font-weight:700; padding:1px 5px; border-radius:3px;
  background:#F3EDE8; color:#5A4A40; border:1px solid #DDD5CE; white-space:nowrap; }
.lib-st-badge { font-size:10px; font-weight:600; padding:2px 6px; border-radius:3px; }
.lib-st-badge.berlaku { background:#E6F4EC; color:#1A6B3A; }
.lib-st-badge.diubah  { background:#FFF0DC; color:#854F0B; }
.lib-st-badge.dicabut { background:#FCEBEB; color:#8B1A1A; }
.lib-omnibus-tag { font-size:10px; padding:1px 5px; background:#F3EEFF; color:#4A1A6B;
  border:1px solid #D4B8F8; border-radius:3px; font-weight:600; }

/* Loading / empty / error */
.lib-loading,.lib-empty { padding:32px 16px; text-align:center; color:#9A8A80; font-size:13px; }
.lib-error              { padding:32px 16px; text-align:center; color:#8B1A1A; font-size:13px; }

/* ── Detail view (right panel) ───────────────────────────────────────────── */
.lib-det-card { max-width:760px; }
.lib-det-hdr { display:flex; align-items:flex-start; justify-content:space-between;
  flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.lib-det-badges { display:flex; gap:6px; flex-wrap:wrap; }
.lib-det-links { display:flex; gap:7px; flex-wrap:wrap; }
.lib-det-link { font-size:12px; color:#8B1A1A; text-decoration:none; padding:4px 9px;
  border:1.5px solid #DDD5CE; border-radius:6px; }
.lib-det-link:hover { background:#FCEBEB; border-color:#C4A090; }
.lib-det-title { font-size:17px; font-weight:700; color:#1A0A06; margin:0 0 3px; line-height:1.4; }
.lib-det-nomor { font-size:13px; color:#7A6A60; margin-bottom:12px; }
.lib-det-meta { display:flex; flex-wrap:wrap; gap:6px 20px; padding:8px 12px;
  background:#FAF7F4; border-radius:7px; border:1px solid #EDE5DF; margin-bottom:14px; }
.lib-meta-item { display:flex; flex-direction:column; gap:1px; }
.lib-meta-k { font-size:10px; color:#9A8A80; text-transform:uppercase; letter-spacing:.4px; }
.lib-meta-v { font-size:12px; color:#1A0A06; font-weight:500; }
.lib-det-sec { margin-bottom:18px; }
.lib-det-sec-title { font-size:13px; font-weight:700; color:#3D2B20; margin:0 0 8px;
  padding-bottom:5px; border-bottom:1.5px solid #EDE5DF; }
.lib-prime-title { color:#1A0A06; }
.lib-det-abstrak { font-size:13px; color:#4A3A30; line-height:1.65; margin:0; }
.lib-det-dasar   { font-size:12px; color:#6A5A50; line-height:1.6; margin:0; }
.lib-no-rel      { font-size:12px; color:#9A8A80; font-style:italic; margin:0; }
.lib-admin-notes { font-size:12px; color:#4A3A30; line-height:1.65; white-space:pre-wrap;
  background:#FAF7F4; border:1px solid #EDE5DF; border-left:3px solid #C4A090;
  border-radius:5px; padding:8px 12px; }
.lib-rel-group { margin-bottom:10px; }
.lib-rl-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.4px;
  margin-bottom:4px; padding:2px 6px; border-radius:3px; display:inline-block; }
.lib-rl-mengubah     { background:#E6F1FB; color:#185FA5; }
.lib-rl-mencabut     { background:#F3EEFF; color:#4A1A6B; }
.lib-rl-diubah-oleh  { background:#FFF0DC; color:#854F0B; }
.lib-rl-dicabut-oleh { background:#FCEBEB; color:#8B1A1A; }
.lib-rel-item { display:flex; align-items:baseline; gap:6px; flex-wrap:wrap;
  padding:6px 8px; border-radius:6px; background:#FAF7F4; border:1px solid #EDE5DF;
  margin-bottom:3px; cursor:pointer; transition:background .15s; }
.lib-rel-item:hover { background:#F3EDE8; border-color:#C4A090; }
.lib-rel-title  { font-size:12px; color:#1A0A06; font-weight:500; flex:1; min-width:120px; }
.lib-rel-nomor  { font-size:11px; color:#9A8A80; white-space:nowrap; }
.lib-rel-pasals { font-size:10px; color:#185FA5; background:#E6F1FB; padding:1px 5px;
  border-radius:3px; white-space:nowrap; }
.lib-rel-summary { width:100%; font-size:11px; color:#6A5A50; margin:2px 0 0; line-height:1.5; }
.lib-rel-verb    { font-size:11px; color:#7A6A60; white-space:nowrap; }
.lib-uji-item    { cursor:pointer; }
.lib-uji-verb    { font-size:10px; font-weight:700; padding:1px 5px; border-radius:3px; white-space:nowrap; }
.lib-uji-membatalkan { background:#FCEBEB; color:#8B1A1A; }
.lib-uji-menafsirkan { background:#E6F4EC; color:#1A6B3A; }
.lib-other-item  { cursor:default; }
.lib-ask-wrap { margin-top:18px; padding-top:12px; border-top:1.5px solid #EDE5DF; text-align:center; }
.lib-ask-btn { display:inline-flex; align-items:center; gap:6px; padding:8px 18px;
  background:#8B1A1A; color:#fff; border:none; border-radius:7px;
  font-size:13px; font-weight:600; cursor:pointer; }
.lib-ask-btn:hover { background:#6B1212; }

/* ── Enhanced reader view ────────────────────────────────────────────────── */
.lib-reader-header {
  display:flex; align-items:center; gap:10px; flex-wrap:nowrap;
  padding:10px 16px 10px; border-bottom:1.5px solid #EDE5DF;
  background:#fff; z-index:5; min-height:48px;
}
.lib-reader-title { font-size:14px; font-weight:700; color:#1A0A06; flex:1; min-width:0;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lib-reader-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.lib-reader-ask-btn {
  display:flex; align-items:center; gap:5px;
  padding:4px 11px; font-size:12px; font-weight:600;
  border:1.5px solid #8B1A1A; border-radius:5px;
  background:#8B1A1A; color:#fff; cursor:pointer;
  white-space:nowrap; transition:background .15s;
}
.lib-reader-ask-btn:hover { background:#6B1010; border-color:#6B1010; }
.lib-reader-toggle { display:flex; gap:4px; }
.lib-rtoggle-btn {
  padding:4px 11px; font-size:12px; border:1.5px solid #DDD5CE;
  border-radius:5px; background:#F9F5F2; color:#5A4A40; cursor:pointer;
}
.lib-rtoggle-btn.active { background:#8B1A1A; color:#fff; border-color:#8B1A1A; }
.lib-reader-back { font-size:12px; color:#8B1A1A; cursor:pointer; white-space:nowrap; padding:4px 0; flex-shrink:0; }
.lib-reader-back:hover { text-decoration:underline; }

/* ── Full-width reader: hide lib-left, expand lib-right ─────────────────────── */
/* see lib-right-pane override above */

/* Grid layout: header row gets its natural height, canvas row fills the rest.
   This is the only reliable way to give the canvas a definite height without
   depending on the flex chain above. */
#lib-reader-view .lib-reader-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.lib-right.rdr-fullwidth { width:100%; }

/* PDF iframe */
.lib-pdf-frame { width:100%; height:100%; min-height:600px; border:none; }

/* ── rdr-canvas: sits in the 1fr grid row — always gets a defined height ─────── */
.rdr-canvas {
  display:flex; overflow:hidden;
  align-items:stretch; min-height:0;
}

/* ── Floating toolbar ─────────────────────────────────────────────────────────── */
.rdr-toolbar {
  display:flex; flex-direction:column; align-items:stretch;
  width:86px; flex-shrink:0;
  border-right:1.5px solid #EDE5DF;
  padding:10px 6px; gap:4px;
  background:#FAFAF8; overflow:hidden;
}
.rdr-tool-label {
  font-size:9px; font-weight:700; text-transform:uppercase; letter-spacing:.5px;
  color:#B0A090; text-align:center; margin-bottom:4px;
}
.rdr-tool-btn {
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:8px 4px; border:1.5px solid #EDE5DF; border-radius:7px;
  background:#fff; color:#6A5A50; cursor:pointer; font-size:10px;
  font-weight:500; transition:background .12s, border-color .12s, color .12s;
  text-align:center; line-height:1.2;
}
.rdr-tool-btn:hover { background:#F3EDE8; border-color:#C4A090; color:#1A0A06; }
.rdr-tool-btn.active { background:#8B1A1A; border-color:#8B1A1A; color:#fff; }
.rdr-tool-btn svg { flex-shrink:0; }

/* ── TOC slide-in panel (left of scroll area) ────────────────────────────────── */
.rdr-toc-panel {
  width:0; flex-shrink:0; overflow:hidden;
  border-right:1.5px solid #EDE5DF;
  background:#FAFAF8;
  transition:width .22s ease;
  display:flex; flex-direction:column;
  min-height:0; align-self:stretch;
}
.rdr-toc-panel.open { width:220px; overflow:hidden; }
.rdr-toc-panel-hdr {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px 8px; font-size:11px; font-weight:700; color:#3D2B20;
  border-bottom:1px solid #EDE5DF; flex-shrink:0;
}
.rdr-toc-panel-hdr button { background:none; border:none; cursor:pointer; color:#9A8A80; font-size:14px; padding:0 2px; }
.rdr-toc-panel-hdr button:hover { color:#8B1A1A; }
.rdr-toc-inner { flex:1; min-height:0; overflow-y:auto; padding:8px 8px 20px; }
.rdr-toc-section { margin-bottom:6px; }
.rdr-toc-bab {
  font-size:10px; font-weight:700; color:#4A3A30; padding:3px 6px;
  border-radius:3px; cursor:pointer; line-height:1.4;
  transition:background .1s;
}
.rdr-toc-bab:hover { background:#EDE5DF; color:#8B1A1A; }
.rdr-toc-pasals { padding-left:8px; margin-top:1px; }
.rdr-toc-pasal {
  font-size:11px; color:#6A5A50; padding:2px 5px; border-radius:3px;
  cursor:pointer; transition:background .1s, color .1s;
}
.rdr-toc-pasal:hover { background:#F3EDE8; color:#8B1A1A; }
.rdr-toc-empty { font-size:12px; color:#9A8A80; font-style:italic; padding:6px; }
.rdr-toc-defs-section { margin-top:10px; padding-top:8px; border-top:1px solid #EDE5DF; }
.rdr-toc-def-item { padding:4px 6px; }
.rdr-toc-def-term { display:block; font-size:10px; font-weight:700; color:#8B1A1A; }
.rdr-toc-def-text { display:block; font-size:10px; color:#6A5A50; line-height:1.5; margin-top:1px; }

/* ── Main scroll area ─────────────────────────────────────────────────────────── */
.rdr-scroll {
  flex:1; min-height:0; overflow-y:auto; min-width:0;
  -webkit-overflow-scrolling: touch;
}
.rdr-text-inner {
  max-width:720px; margin:0 auto; padding:24px 32px 60px;
}

/* ── Chunks: clean readable text (no pre-wrap) ───────────────────────────────── */
.lib-chunk { margin-bottom:22px; padding-bottom:18px; border-bottom:1px solid #F0E8E2; }
.lib-chunk:last-child { border-bottom:none; }
.lib-chunk-hdr {
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  margin-bottom:6px;
}
.lib-chunk-ref {
  font-size:11px; font-weight:700; color:#8B1A1A; text-transform:uppercase;
  letter-spacing:.3px; white-space:nowrap;
}
.lib-chunk-section { font-size:10px; color:#9A8A80; }
.lib-chunk-text {
  font-size:13.5px; color:#1A0A06; line-height:1.85;
  white-space:normal; word-break:break-word;
}

/* ── ⚡ Explain button (hidden until tool active) ────────────────────────────── */
.rdr-explain-btn {
  padding:2px 7px; font-size:11px; font-weight:600; cursor:pointer;
  border-radius:4px; transition:background .12s; flex-shrink:0; white-space:nowrap;
  border:1px solid transparent; margin-left:2px;
}
.rdr-btn-explain  { background:#FFF8E6; border-color:#E8D070; color:#7A5A00; }
.rdr-btn-explain:hover  { background:#FFF0C0; }

/* ── EN / 中 translation pills (always visible on each pasal header) ─────────── */
.rdr-trans-pill {
  padding:1px 7px; font-size:10px; font-weight:700; cursor:pointer;
  border-radius:10px; white-space:nowrap; flex-shrink:0; margin-left:2px;
  border:1.5px solid transparent; transition:background .12s, border-color .12s;
}
.rdr-trans-en { background:#E6F1FB; border-color:#B0CFF0; color:#185FA5; }
.rdr-trans-en:hover { background:#D0E8F8; border-color:#185FA5; }
.rdr-trans-zh { background:#F3EEFF; border-color:#C4A0F0; color:#5A1A9A; }
.rdr-trans-zh:hover { background:#EAD8FF; border-color:#5A1A9A; }

/* ── Translation tabs in explain panel ───────────────────────────────────────── */
.rdr-trans-tabs {
  display:flex; gap:0; border-bottom:1.5px solid #EDE5DF; flex-shrink:0;
  background:#FAFAF8; margin:-14px -14px 12px;
}
.rdr-trans-tab {
  flex:1; padding:8px 4px; font-size:12px; font-weight:600;
  border:none; background:none; color:#9A8A80; cursor:pointer;
  border-bottom:2px solid transparent; margin-bottom:-1.5px;
  transition:color .12s, border-color .12s;
}
.rdr-trans-tab.active { color:#8B1A1A; border-bottom-color:#8B1A1A; }
.rdr-trans-tab:hover:not(.active) { color:#3D2B20; }
.rdr-trans-pane { }
.rdr-trans-empty { padding:16px 0; text-align:center; }
.rdr-trans-load-btn {
  padding:6px 14px; font-size:11px; font-weight:600;
  border:1.5px solid #DDD5CE; border-radius:6px; background:#FAF7F4;
  color:#6A5A50; cursor:pointer; transition:background .12s;
}
.rdr-trans-load-btn:hover { background:#F0E8E0; border-color:#C4A090; color:#1A0A06; }

/* ── Impact panel ─────────────────────────────────────────────────────────── */
.rdr-impact-form    { padding:4px 0; }
.rdr-impact-hint    { font-size:12px; color:#6A5A50; margin:0 0 12px; line-height:1.6; }
.rdr-impact-profiles { display:flex; flex-direction:column; gap:6px; }
.rdr-impact-btn {
  padding:8px 12px; border:1.5px solid #DDD5CE; border-radius:7px;
  background:#FAF7F4; color:#3D2B20; font-size:12px; font-weight:500;
  cursor:pointer; text-align:left; transition:background .12s, border-color .12s;
}
.rdr-impact-btn:hover { background:#F3EDE8; border-color:#8B1A1A; color:#8B1A1A; }
.rdr-impact-summary {
  font-size:13px; color:#1A0A06; line-height:1.75; margin-bottom:14px;
  padding-bottom:12px; border-bottom:1px solid #EDE5DF;
}
.rdr-impact-pasal-list { display:flex; flex-direction:column; gap:8px; }
.rdr-impact-pasal {
  padding:8px 10px; border:1px solid #EDE5DF; border-radius:6px;
  background:#FAF7F4; cursor:pointer; transition:background .12s;
}
.rdr-impact-pasal:hover { background:#F3EDE8; border-color:#C4A090; }
.rdr-impact-pasal-ref { font-size:11px; font-weight:700; color:#8B1A1A; margin-bottom:3px; }
.rdr-impact-pasal-rel { font-size:12px; color:#3D2B20; line-height:1.5; }
.rdr-impact-pasal-act { font-size:11px; color:#185FA5; margin-top:3px; }
.rdr-no-impact { font-size:12px; color:#9A8A80; font-style:italic; }

/* ── Cross-ref links ─────────────────────────────────────────────────────────── */
.rdr-xref { color:#185FA5; text-decoration:underline dotted; cursor:pointer; font-weight:500; }
.rdr-xref:hover { text-decoration:underline; }

/* ── Defined term inline highlight ──────────────────────────────────────────── */
.rdr-def-term-inline { cursor:help; }
.rdr-def-term-inline.rdr-defs-active {
  border-bottom:2px dotted #8B1A1A; color:#8B1A1A; font-weight:500;
}

/* ── Definition tooltip ──────────────────────────────────────────────────────── */
.rdr-def-tooltip {
  position:fixed; z-index:9999; max-width:280px;
  background:#1A0A06; color:#FDF8F4; font-size:12px; line-height:1.6;
  padding:8px 12px; border-radius:7px;
  pointer-events:none; box-shadow:0 4px 16px rgba(0,0,0,.25);
}
.rdr-def-tooltip-src { display:block; margin-top:4px; font-size:10px; color:#C4A090; font-style:italic; }

/* Scroll-target highlight pulse */
@keyframes rdrPulse { 0%,100%{background:transparent} 30%{background:#FFF8E6} }
.rdr-highlight { animation: rdrPulse 1.8s ease; border-radius:4px; }

/* ── Flags (hidden until tool active) ───────────────────────────────────────── */
.rdr-flag { font-size:10px; font-weight:600; padding:2px 7px; border-radius:3px; margin-bottom:5px; }
.rdr-flag-mk { background:#FCEBEB; color:#8B1A1A; border:1px solid #F0D0D0; }

/* ── Banners ─────────────────────────────────────────────────────────────────── */
.rdr-banner { font-size:12px; padding:8px 12px; border-radius:6px; margin-bottom:16px; line-height:1.5; }
.rdr-banner-pp { background:#FFF8E6; color:#7A5A00; border:1px solid #E8D070; }

/* ── Explain side panel (right, slide in) ────────────────────────────────────── */
.rdr-explain-panel {
  width:0; flex-shrink:0; overflow:hidden;
  border-left:1.5px solid #EDE5DF; background:#fff;
  display:flex; flex-direction:column;
  transition:width .22s ease;
  min-height:0; align-self:stretch;
}
.rdr-explain-panel.open { width:300px; overflow:hidden; }
.rdr-explain-hdr {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px 8px; border-bottom:1px solid #EDE5DF;
  background:#FAFAF8; flex-shrink:0; min-width:300px;
}
.rdr-explain-title { font-size:12px; font-weight:700; color:#8B1A1A; }
.rdr-explain-close { background:none; border:none; font-size:14px; color:#9A8A80; cursor:pointer; padding:0 2px; }
.rdr-explain-close:hover { color:#1A0A06; }
.rdr-explain-body { flex:1; min-height:0; overflow-y:auto; padding:14px; min-width:300px; -webkit-overflow-scrolling:touch; }
.rdr-explain-text { font-size:13px; color:#1A0A06; line-height:1.75; white-space:pre-wrap; }
.rdr-explain-loading { font-size:13px; color:#9A8A80; font-style:italic; }
.rdr-explain-error { font-size:12px; color:#8B1A1A; }

.dark-mode .lib-rtoggle-btn.active { background:#8B1A1A; color:#fff; border-color:#8B1A1A; }
.dark-mode .lib-reader-title { color:#EDE8E3; }
.dark-mode .lib-reader-header { background:#221E1A; border-color:#3D3530; }
.dark-mode .rdr-toolbar      { background:#1E1A16; border-color:#3D3530; }
.dark-mode .rdr-tool-btn     { background:#2A2420; border-color:#3D3530; color:#A09080; }
.dark-mode .rdr-tool-btn:hover { background:#3D3530; color:#EDE8E3; border-color:#6A5A50; }
.dark-mode .rdr-tool-btn.active { background:#8B1A1A; border-color:#8B1A1A; color:#fff; }
.dark-mode .rdr-toc-panel    { background:#1E1A16; border-color:#3D3530; }
.dark-mode .rdr-toc-panel-hdr { border-color:#3D3530; color:#C4B4A4; }
.dark-mode .rdr-toc-bab      { color:#C4B4A4; }
.dark-mode .rdr-toc-bab:hover { background:#3D3530; color:#E07060; }
.dark-mode .rdr-toc-pasal    { color:#9A8A80; }
.dark-mode .rdr-toc-pasal:hover { background:#2A2420; color:#E07060; }
.dark-mode .rdr-toc-def-term { color:#E07060; }
.dark-mode .rdr-toc-def-text { color:#9A8A80; }
.dark-mode .rdr-scroll       { background:#221E1A; }
.dark-mode .lib-chunk        { border-color:#3D3530; }
.dark-mode .lib-chunk-ref    { color:#E07060; }
.dark-mode .lib-chunk-section { color:#7A6A60; }
.dark-mode .lib-chunk-text   { color:#D4C4B4; }
.dark-mode .rdr-xref         { color:#6CA8D4; }
.dark-mode .rdr-def-term-inline.rdr-defs-active { border-color:#E07060; color:#E07060; }
.dark-mode .rdr-def-tooltip  { background:#EDE8E3; color:#1A0A06; }
.dark-mode .rdr-flag-mk      { background:#3A1010; color:#E08080; border-color:#6A2020; }
.dark-mode .rdr-banner-pp    { background:#2A2000; color:#C4A030; border-color:#6A5000; }
.dark-mode .rdr-explain-panel { border-color:#3D3530; background:#221E1A; }
.dark-mode .rdr-explain-hdr  { background:#1E1A16; border-color:#3D3530; }
.dark-mode .rdr-explain-title { color:#E07060; }
.dark-mode .rdr-explain-text  { color:#D4C4B4; }
.dark-mode .rdr-explain-btn  { background:#2A2420; border-color:#3D3530; color:#A09080; }
.dark-mode .rdr-btn-explain   { background:#2A2000; border-color:#6A5000; color:#C4A030; }
.dark-mode .rdr-trans-pill    { }
.dark-mode .rdr-trans-en      { background:#1A2535; border-color:#2A4A7A; color:#6CA8D4; }
.dark-mode .rdr-trans-en:hover{ background:#1E3050; border-color:#6CA8D4; }
.dark-mode .rdr-trans-zh      { background:#2A1A3A; border-color:#5A3A8A; color:#C0A0E0; }
.dark-mode .rdr-trans-zh:hover{ background:#3A1A5A; border-color:#C0A0E0; }
.dark-mode .rdr-trans-tabs    { background:#1E1A16; border-color:#3D3530; }
.dark-mode .rdr-trans-tab     { color:#7A6A60; }
.dark-mode .rdr-trans-tab.active { color:#E07060; border-bottom-color:#E07060; }
.dark-mode .rdr-trans-load-btn { background:#2A2420; border-color:#3D3530; color:#A09080; }
.dark-mode .rdr-impact-btn    { background:#2A2420; border-color:#3D3530; color:#C4B4A4; }
.dark-mode .rdr-impact-btn:hover { background:#3D3530; border-color:#E07060; color:#E07060; }
.dark-mode .rdr-impact-summary { color:#D4C4B4; border-color:#3D3530; }
.dark-mode .rdr-impact-pasal  { background:#2A2420; border-color:#3D3530; }
.dark-mode .rdr-impact-pasal:hover { background:#3D3530; border-color:#6A5A50; }
.dark-mode .rdr-impact-pasal-ref { color:#E07060; }
.dark-mode .rdr-impact-pasal-rel { color:#C4B4A4; }
.dark-mode .rdr-impact-pasal-act { color:#6CA8D4; }
.dark-mode .lib-loading, .dark-mode .lib-empty { color:#7A6A60; }
.dark-mode .lib-error        { color:#E07060; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lib-left  { width: 100%; border-right: none; }
  .lib-right { display: none !important; }
  .lib-split { flex-direction: column; }
  .lib-card-actions { gap: 3px; }
}
@media (max-width: 768px) {
  .lib-left  { padding: 8px 10px 0; }
  .lib-filters { gap: 4px; }
  .lib-filter-sel { font-size: 11px; min-width: 0; }
  #lib-subsector-browse { max-width: 200px; }
  .lib-filter-inp { min-width: 0; }
}


/* ═══════════════════════════════════════════════════════════════
   CHAPTER XIV — WORKFLOW SYSTEM STYLES
   ═══════════════════════════════════════════════════════════════ */

/* ── Workbench Tabs ──────────────────────────────────────────── */
.workbench-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 12px 14px 8px; border-bottom: 1px solid var(--border);
}
.wb-tab {
  padding: 5px 12px; border: 1px solid var(--border2);
  border-radius: 20px; background: var(--surface2); color: var(--text2);
  font-size: 13px; cursor: pointer; display: flex; align-items: center;
  gap: 6px; transition: all .15s; font-family: var(--font-body); line-height: 1;
}
.wb-tab:hover { border-color: var(--text3); color: var(--text); }
.wb-tab.active { background: var(--accent,#8B1A1A); border-color: var(--accent,#8B1A1A); color: #fff; font-weight: 600; }
.wb-badge { background: rgba(0,0,0,.12); color: inherit; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 8px; min-width: 18px; text-align: center; }
.wb-tab.active .wb-badge { background: rgba(255,255,255,.25); }
.wb-badge-submitted { background: #fff0b0; color: #7a5a00; }
.wb-badge-returned  { background: #fdeaea; color: #7d1c1c; }
.wb-badge-fixated   { background: #d1fae5; color: #065f46; }

/* ── Workflow Status Badges ──────────────────────────────────── */
.ws-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 8px; letter-spacing: .03em;
  text-transform: uppercase; flex-shrink: 0; margin-left: 4px;
}
.ws-draft     { background: #f0f4ff; color: #3B5298; border: 1px solid #c7d3ff; }
.ws-submitted { background: #fff8e6; color: #7a5a00; border: 1px solid #f0d080; }
.ws-returned  { background: #fdeaea; color: #7d1c1c; border: 1px solid #f5a9a9; }
.ws-fixated   { background: #d1fae5; color: #065f46; border: 1px solid #a3d9a5; }

/* ── Workflow Action Buttons ─────────────────────────────────── */
.kb-fixate-btn { color: #065f46 !important; border-color: #a3d9a5 !important; }
.kb-fixate-btn:hover { background: #d1fae5 !important; }
.kb-return-btn { color: #7d1c1c !important; border-color: #f5a9a9 !important; }
.kb-return-btn:hover { background: #fdeaea !important; }
.kb-submit-btn { color: #185FA5 !important; border-color: #b8cff5 !important; }
.kb-submit-btn:hover { background: #e6f0fb !important; }
.kb-submit-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Reviewer Queue ──────────────────────────────────────────── */
.rq-row {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-left: 3px solid #f0d080; border-radius: var(--radius-sm);
  margin-bottom: 8px; transition: border-left-color .15s;
}
.rq-row:hover { border-left-color: #c8a000; }
.rq-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rq-nt    { font-size: 12px; color: var(--text2); font-weight: 500; }
.rq-time  { font-size: 11px; color: var(--text3); margin-left: auto; }
.rq-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.4; }
.rq-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Performance Table ───────────────────────────────────────── */
.perf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perf-table th {
  text-align: left; padding: 8px 10px; background: var(--surface2);
  border-bottom: 2px solid var(--border2); font-size: 12px; color: var(--text3);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.perf-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.perf-table tbody tr:hover td { background: var(--surface2); }
.perf-num   { text-align: right; font-variant-numeric: tabular-nums; }
.perf-total { font-weight: 700; }

/* ── Role Badges ─────────────────────────────────────────────── */
.role-badge { display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 8px; text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap; }
.role-super_admin { background: #f3e8ff; color: #5b21b6; }
.role-doc_admin   { background: #e0f2fe; color: #0369a1; }
.role-reviewer    { background: #fef3c7; color: #92400e; }
.role-auditor     { background: #f3f4f6; color: #374151; }

/* ── Category Checkboxes ─────────────────────────────────────── */
.category-checkbox-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto;
}
.cat-cb-label { display: flex; align-items: center; gap: 7px; font-size: 12px;
  cursor: pointer; padding: 4px 6px; border-radius: 5px; transition: background .1s; user-select: none; }
.cat-cb-label:hover { background: var(--bg); }
.cat-cb { width: 14px; height: 14px; flex-shrink: 0; accent-color: var(--accent,#8B1A1A); cursor: pointer; }
