/* Holy Notes - Global Styles */
:root {
  --primary: #4a6fa5;
  --primary-dark: #3a5a8a;
  --primary-light: #6a8fc5;
  --accent: #e8a838;
  --accent-dark: #c88a20;
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-dark: #2c3e50;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-inverse: #ffffff;
  --border: #dce1e8;
  --border-light: #eef0f4;
  --success: #27ae60;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
  --warning: #f39c12;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --primary: #8a9bb5;
  --primary-dark: #7a8ba5;
  --primary-light: #a0b0c8;
  --accent: #e8a838;
  --accent-dark: #c88a20;
  --bg: #1a1816;
  --bg-card: #262220;
  --bg-dark: #151311;
  --text: #e0dcd8;
  --text-light: #a09890;
  --text-inverse: #ffffff;
  --border: #3d3632;
  --border-light: #302a26;
  --success: #2ecc71;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
  --warning: #f39c12;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Custom scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
button:active, .btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: var(--text-inverse); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: var(--text-inverse); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); color: var(--text-inverse); }
.btn-danger:hover { background: var(--danger-dark); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--primary); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.btn-icon:hover { background: var(--bg); }

.logout-btn {
  color: var(--text-inverse);
  border-color: rgba(255,255,255,0.2);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.logout-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
}

/* Layout */
.navbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-dark);
  color: var(--text-inverse);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .logo {
  position: absolute;
  left: 24px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: -0.5px;
}

.navbar nav { display: flex; align-items: center; gap: 16px; }
.navbar nav a {
  color: var(--text-inverse);
  opacity: 0.8;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
  border-radius: 6px;
  position: relative;
}
.navbar nav a:hover { opacity: 1; }
.navbar nav a.active { opacity: 1; }
.navbar nav a.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.navbar nav a svg { display: block; width: 20px; height: 20px; }
.navbar nav .admin-nav-link { display: none !important; }
.navbar nav .admin-nav-link.visible { display: inline-flex !important; }
.navbar nav .nav-msg-link,
.navbar nav .nav-preachers-link { position: relative; }
.navbar nav .nav-msg-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #e84545;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.navbar .user-area {
  position: absolute;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.container { max-width: 1800px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

/* Native select dropdowns */
.native-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.native-select {
  flex: 1;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  appearance: auto;
}
.native-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}
.native-select-add-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.native-select-add-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.native-select-view-link {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s;
}
.native-select-view-link:hover {
  color: var(--primary);
}

/* Preacher searchable select */
.preacher-select {
  position: relative;
}
.preacher-select-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.preacher-select-input {
  width: 100%;
  padding: 8px 52px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition);
}
.preacher-select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}
.preacher-select-input::placeholder {
  color: var(--text-light);
}
.preacher-select-clear {
  position: absolute;
  right: 28px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  transition: color var(--transition);
}
.preacher-select-clear:hover {
  color: var(--danger);
}
.preacher-select-arrow {
  position: absolute;
  right: 10px;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  transition: transform var(--transition);
  user-select: none;
}
.preacher-select-arrow.open {
  transform: rotate(180deg);
}

.preacher-select-view {
  position: absolute;
  right: 8px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 14px;
  line-height: 1;
  padding: 4px;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preacher-select-view:hover {
  color: var(--primary);
}
.preacher-select.has-view-link .preacher-select-input {
  padding-right: 72px;
}
.preacher-select.has-view-link .preacher-select-clear {
  right: 48px;
}
.preacher-select.has-view-link .preacher-select-arrow {
  right: 30px;
}

.preacher-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}
.preacher-select-dropdown.active {
  display: block;
}
.preacher-select-group {
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.preacher-select-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  transition: background var(--transition);
  outline: none;
}
.preacher-select-item:hover,
.preacher-select-item:focus {
  background: rgba(74, 111, 165, 0.08);
}
.preacher-select-item.active {
  background: rgba(74, 111, 165, 0.15);
  font-weight: 600;
}
.preacher-select-item[tabindex] { tabindex: 0; }

.preacher-select-name {
  flex: 1;
}
.preacher-select-name mark {
  background: rgba(232, 168, 56, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.preacher-select-dienst {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.preacher-select-add {
  color: var(--primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
  margin-bottom: 2px;
}
.preacher-select-add:hover {
  background: rgba(74, 111, 165, 0.08);
}

.preacher-select-empty {
  padding: 12px 14px;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
  text-align: center;
}

/* Location searchable select (reuses preacher-select pattern) */
.location-select {
  position: relative;
}
.location-select-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.location-select-input {
  width: 100%;
  padding: 8px 52px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition);
}
.location-select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}
.location-select-input::placeholder {
  color: var(--text-light);
}
.location-select-clear {
  position: absolute;
  right: 28px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  transition: color var(--transition);
}
.location-select-clear:hover {
  color: var(--danger);
}
.location-select-arrow {
  position: absolute;
  right: 10px;
  color: var(--text-light);
  font-size: 12px;
  cursor: pointer;
  transition: transform var(--transition);
  user-select: none;
}
.location-select-arrow.open {
  transform: rotate(180deg);
}
.location-select-view-link {
  position: absolute;
  right: 50px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s;
}
.location-select-view-link:hover {
  color: var(--primary);
}
.preacher-select .location-select-input {
  padding-right: 78px;
}
.location-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 120;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}
.location-select-dropdown.active {
  display: block;
}
.location-select-group {
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}
.location-select-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  transition: background var(--transition);
  outline: none;
}
.location-select-item:hover,
.location-select-item:focus {
  background: rgba(74, 111, 165, 0.08);
}
.location-select-item.active {
  background: rgba(74, 111, 165, 0.15);
  font-weight: 600;
}
.location-select-enter-address {
  color: var(--primary);
  border-top: 1px solid var(--border-light);
  margin-top: 2px;
  padding-top: 10px;
}
.location-select-empty {
  padding: 8px 14px;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}
.location-select-input[readonly] {
  cursor: pointer;
}
.location-select-name {
  flex: 1;
}
.location-select-name mark {
  background: rgba(232, 168, 56, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.location-select-empty {
  padding: 12px 14px;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
  text-align: center;
}

.note-card-location {
  font-size: 12px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* Dark mode */
[data-theme="dark"] .location-select-input {
  background: var(--bg);
  color: var(--text);
}
[data-theme="dark"] .location-select-name mark {
  background: rgba(232, 168, 56, 0.25);
}
[data-theme="dark"] .preacher-select-input {
  background: var(--bg);
  color: var(--text);
}
[data-theme="dark"] .preacher-select-name mark {
  background: rgba(232, 168, 56, 0.25);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Church/Preacher profile logo inline next to title (transparent — freigestellt) */
.profile-card { position: relative; }
.profile-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.profile-logo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.profile-title-text {
  min-width: 0;
  flex: 1;
}
.profile-title-text .profile-name {
  margin: 0;
  line-height: 1.1;
}
.profile-full-name {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-card-hero .profile-full-name {
  color: rgba(255, 255, 255, 0.85);
}
@media (max-width: 600px) {
  .profile-logo { width: 44px; height: 44px; }
  .profile-title-row { gap: 10px; }
}

/* Detail pages: unified top bar with back link + action buttons */
.detail-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.detail-top-bar .back-link { margin: 0; }
.detail-top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}
.detail-top-actions .btn-icon {
  position: static !important;
  top: auto !important;
  right: auto !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.detail-top-actions .btn-icon:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.detail-top-actions .profile-fav-btn:hover {
  color: #e74c3c;
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}
.detail-top-actions .profile-fav-btn.active {
  color: #e74c3c;
  border-color: #e74c3c;
}
.detail-top-actions .profile-broadcast-btn,
.detail-top-actions .profile-broadcast-btn:hover {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.detail-top-actions .profile-broadcast-btn:hover {
  background: var(--primary-dark);
}

/* Mobile kebab dropdown for detail action bar — quarter-arc of round icon
   buttons radiating from the kebab toward the lower-left quadrant, matching
   the editor's note-actions-menu look. Hidden on desktop. */
.detail-actions-menu-wrap {
  position: relative;
  display: none;
}
.detail-actions-menu-wrap.hidden { display: none !important; }
.detail-actions-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 1000;
}
.detail-actions-menu.hidden { display: none; }
.detail-actions-menu-item {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md, 0 2px 6px rgba(0,0,0,0.25));
  cursor: pointer;
  color: var(--text);
}
.detail-actions-menu-item:hover { background: var(--bg-hover, rgba(0,0,0,0.05)); }
.detail-actions-menu-item.hidden { display: none !important; }
.detail-actions-menu-item svg { flex-shrink: 0; }
.detail-actions-menu-item:nth-child(1) { left: -100px; top: 0;    }
.detail-actions-menu-item:nth-child(2) { left: -87px;  top: 50px; }
.detail-actions-menu-item:nth-child(3) { left: -50px;  top: 87px; }
.detail-actions-menu-item:nth-child(4) { left: 0;      top: 100px; }

@media (max-width: 768px) {
  .detail-top-actions .profile-edit-btn,
  .detail-top-actions .profile-share-btn,
  .detail-top-actions .profile-streams-btn,
  .detail-top-actions .profile-broadcast-btn { display: none !important; }
  .detail-top-actions .detail-actions-menu-wrap:not(.hidden) { display: inline-block; }
}

/* Color picker row (Church logo background) */
.color-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-picker-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}
.color-picker-row input[type="text"] {
  flex: 1;
  max-width: 140px;
  font-family: monospace;
}

/* Church-card logo tile (full-bleed tile replacing the banner picture when a logo is set) */
.church-logo-tile {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}
.church-logo-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.church-card .church-full-name {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-light { color: var(--text-light); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-light);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Confirm dialog */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 250;
  justify-content: center;
  align-items: center;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 400px;
  text-align: center;
}
.confirm-box p { margin-bottom: 20px; }
.confirm-box .actions { display: flex; justify-content: center; gap: 12px; }

/* Theme toggle button */
.theme-toggle {
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: var(--text-inverse);
  cursor: pointer;
  transition: background var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); }

/* Quill editor dark mode */
[data-theme="dark"] .ql-toolbar.ql-snow { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .ql-container.ql-snow { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .ql-editor { color: var(--text); }
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text-light); }
[data-theme="dark"] .ql-snow .ql-fill { fill: var(--text-light); }
[data-theme="dark"] .ql-snow .ql-picker-label { color: var(--text-light); }
[data-theme="dark"] .ql-snow .ql-picker-options { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .ql-snow .ql-picker-item { color: var(--text); }
[data-theme="dark"] .ql-editor.ql-blank::before { color: var(--text-light); }

/* Dark mode form inputs */
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

/* Navbar back button — mobile only, shared across all pages */
.navbar-back-btn {
  display: none;
  color: var(--text-inverse);
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  text-decoration: none;
  opacity: 0.85;
}
.navbar-back-btn:hover,
.navbar-back-btn:focus { opacity: 1; }
.navbar-back-btn svg { display: block; width: 20px; height: 20px; }
.navbar-back-btn.hidden { display: none !important; }

/* Note actions: kebab dropdown — quarter-arc of round icon buttons.
   Shared between editor (mobile navbar) and notes-detail-header. */
.note-actions-menu-wrap {
  position: relative;
  display: inline-block;
}
.note-actions-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 1000;
}
.note-actions-item {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md, 0 2px 6px rgba(0,0,0,0.25));
  cursor: pointer;
  color: var(--text);
}
.note-actions-item:hover {
  background: var(--bg-hover, rgba(0,0,0,0.05));
}
.note-actions-item:nth-child(1) { left: -100px; top: 0;    }
.note-actions-item:nth-child(2) { left: -87px;  top: 50px; }
.note-actions-item:nth-child(3) { left: -50px;  top: 87px; }
.note-actions-item:nth-child(4) { left: 0;      top: 100px; }
.note-actions-item.hidden { display: none !important; }
.note-actions-item svg { flex-shrink: 0; }
.note-actions-danger { color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .navbar { padding: 0 12px; gap: 8px; }
  .navbar .logo { display: none; }
  .navbar nav { gap: 10px; }
  .navbar nav a { font-size: 12px; padding: 7px; }
  .navbar .user-area { gap: 8px; font-size: 12px; }
  .navbar .user-area #user-name { display: none; }
  .navbar-back-btn { display: inline-flex; position: absolute; left: 12px; z-index: 2; }
  .navbar-back-btn.hidden { display: none !important; }
  /* Hide in-content back links on mobile — they now live in the navbar */
  .container > .back-link,
  .container .detail-top-bar .back-link,
  #page-header-chapter #chapter-back-btn { display: none !important; }
  .toast-container { right: 12px; left: 12px; }
  .toast { font-size: 13px; }
  .confirm-box { max-width: 90vw; padding: 20px; }
  .modal { padding: 20px; width: 95%; }
}

@media (max-width: 480px) {
  .container { padding: 12px; }
  .navbar { height: 52px; padding: 0 10px; }
  .navbar nav { gap: 6px; }
  .navbar nav a { font-size: 11px; padding: 6px; }
  .navbar .user-area .btn { font-size: 11px; padding: 3px 8px; }
  .toast-container { top: 56px; right: 8px; left: 8px; }
  button, .btn { padding: 8px 12px; font-size: 13px; }
  .btn-sm { padding: 4px 8px; font-size: 11px; }
}

/* === RTL (Arabic, Hebrew, Persian) === */
html[dir="rtl"] body { text-align: right; }

html[dir="rtl"] .navbar { flex-direction: row-reverse; }
html[dir="rtl"] .navbar .logo { left: auto; right: 24px; }
html[dir="rtl"] .navbar nav { flex-direction: row-reverse; }
html[dir="rtl"] .navbar .user-area { flex-direction: row-reverse; }

html[dir="rtl"] .toast-container { left: 24px; right: auto; }
html[dir="rtl"] .toast { text-align: right; }

html[dir="rtl"] .modal-close,
html[dir="rtl"] .close-btn,
html[dir="rtl"] [class*="close"][class*="btn"] { left: 10px; right: auto; }

html[dir="rtl"] .dropdown-menu { left: 0; right: auto; }

html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select { text-align: right; }

html[dir="rtl"] .setting-row { flex-direction: row-reverse; }
html[dir="rtl"] .setting-info { text-align: right; }

@media (max-width: 768px) {
  html[dir="rtl"] .toast-container { left: 12px; right: 12px; }
}

@media (max-width: 480px) {
  html[dir="rtl"] .toast-container { right: 8px; left: 8px; }
}
