/* components.css — Buttons, inputs, modals, tags, checkboxes */

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--hover-bg);
  border-color: var(--scrollbar-thumb);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.9;
  border-color: var(--primary-color);
  background: var(--primary-color);
}

.btn-danger {
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.btn-danger:hover {
  background: var(--danger-color);
  color: #ffffff;
}

.btn-ghost {
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--hover-bg);
  border-color: transparent;
}

.btn-sm {
  padding: 4px 8px;
  font-size: var(--text-xs);
}

.btn-icon {
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

/* ─── Inputs ─── */

.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: max(var(--text-sm), 16px);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
  transition: background-color 5000s ease-in-out 0s;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

/* ─── Form groups ─── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-label-normal {
  text-transform: none;
  letter-spacing: normal;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-row .form-label {
  margin-bottom: 0;
}

.field-remove-btn {
  padding: 4px;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.field-remove-btn:hover {
  opacity: 1;
  color: var(--danger-color);
}

/* Field row: input + remove button inline */
.field-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-input-row .input,
.field-input-row .tag-input-container {
  flex: 1;
  min-width: 0;
}

.field-input-row-top {
  align-items: flex-start;
  padding-top: 4px;
}

/* ─── Tags / Chips ─── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tag:hover {
  border-color: var(--scrollbar-thumb);
  color: var(--text-primary);
}

.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  font-size: var(--text-sm);
  padding: 0;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
}

.tag-remove:hover {
  opacity: 1;
}

/* ─── Status badge ─── */

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.04em;
}

.status-inbox {
  background: var(--hover-bg);
  color: var(--text-muted);
}

.status-reviewed {
  background: rgba(0, 157, 95, 0.15);
  color: var(--primary-color);
}

.status-important {
  background: rgba(255, 68, 72, 0.15);
  color: var(--danger-color);
}

/* ─── Checkbox custom ─── */

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: transparent;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox:checked {
  background: var(--secondary-color);
  border-color: var(--secondary-color);
}

.checkbox:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--secondary-color) 25%, transparent);
}

/* ─── Modal / Overlay ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  animation: fadeIn 200ms ease;
}

.modal {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 250ms ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent);
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

/* ─── Type selector ─── */

.type-selector {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ─── Tag input ─── */

.tag-input-wrap {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-height: 38px;
  cursor: text;
  transition: border-color var(--transition-fast);
}

.tag-input-wrap:focus-within {
  border-color: var(--primary-color);
}

.tag-input-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-input-field {
  flex: 1;
  min-width: 80px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: max(var(--text-sm), 16px);
  outline: none;
  padding: 0.1rem 0;
}

.tag-input-field::placeholder {
  color: var(--text-muted);
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 10;
  max-height: 180px;
  overflow-y: auto;
}

.tag-suggestion-item {
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.tag-suggestion-item:hover {
  background: var(--hover-bg);
}

/* ─── Bulk actions bar ─── */

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

/* ─── More details toggle ─── */

.more-details-wrap {
  position: relative;
  margin: 0.75rem 0 0.5rem;
}

.more-details-btn {
  color: var(--primary-color);
  font-size: var(--text-xs);
}

.more-details-btn:hover {
  color: var(--link-hover);
}

.field-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.field-picker-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.field-picker-item:hover {
  color: var(--text-primary);
  border-color: var(--scrollbar-thumb);
}

.field-picker-item:has(input:checked) {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.field-picker-item input[type="checkbox"] {
  display: none;
}

/* ─── File input ─── */

.file-input {
  padding: 8px;
}

.file-input::file-selector-button {
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 4px 12px;
  font-size: var(--text-xs);
  cursor: pointer;
  margin-right: 0.5rem;
  transition: all var(--transition-fast);
}

.file-input::file-selector-button:hover {
  background: var(--border-color);
}

/* ─── File previews (thumbnails grid) ─── */

.file-previews {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.file-previews::-webkit-scrollbar {
  height: 10px;
}

.file-previews::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 5px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.file-previews::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  border: 3px solid transparent;
  background-clip: padding-box;
}

.file-thumb {
  flex-shrink: 0;
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--hover-bg);
  cursor: pointer;
}

.file-thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: none;
}


.file-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.file-thumb:hover .file-thumb-remove {
  opacity: 1;
}

/* ─── File upload progress overlays ─── */

.file-thumb-upload-pending,
.file-thumb-upload-active,
.file-thumb-upload-done,
.file-thumb-upload-error {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  pointer-events: none;
}

.file-thumb-upload-pending {
  background: rgba(0, 0, 0, 0.5);
}

.file-thumb-upload-active {
  background: rgba(0, 0, 0, 0.35);
}

.file-thumb-upload-active::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: thumbSpin 0.6s linear infinite;
}

@keyframes thumbSpin {
  to { transform: rotate(360deg); }
}

.file-thumb-upload-done {
  background: rgba(0, 157, 95, 0.25);
}

.file-thumb-upload-done::after {
  content: '✓';
  color: var(--primary-color);
  font-size: 18px;
  font-weight: 700;
}

.file-thumb-upload-error {
  background: rgba(255, 85, 85, 0.3);
}

.file-thumb-upload-error::after {
  content: '✕';
  color: var(--danger-color);
  font-size: 18px;
  font-weight: 700;
}

/* ─── Lightbox ─── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 150ms ease;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 32px;
  min-height: 0;
}

/* ─── Lightbox strip ─── */

.lightbox-strip {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  max-width: 100%;
  flex-shrink: 0;
  scrollbar-width: none;
}

.lightbox-strip::-webkit-scrollbar {
  display: none;
}

.lightbox-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.5;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.lightbox-thumb:hover {
  opacity: 0.8;
}

.lightbox-thumb.active {
  opacity: 1;
  border-color: #ffffff;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-thumb-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}

.lightbox-thumb-delete {
  position: absolute;
  inset: 0;
  background: rgba(200, 50, 50, 0.65);
  border: none;
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.lightbox-thumb.active .lightbox-thumb-delete {
  display: flex;
}

.lightbox-item-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  max-height: 100%;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox-video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
}

.lightbox-file-placeholder {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.4);
}

.lightbox-file-clickable {
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lightbox-file-clickable:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lightbox-audio-placeholder {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  transition: background 0.2s, color 0.2s;
}

.lightbox-audio-placeholder:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lightbox-audio-playing {
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-color);
}

.lightbox-audio-playing:hover {
  color: var(--primary-color);
}

.lightbox-audio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-item-name {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Markdown entries ─── */

.markdown-entry {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 8px;
}

.markdown-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--hover-bg);
  border-bottom: 1px solid var(--border-color);
}

.markdown-entry-header .form-label {
  margin-bottom: 0;
  font-size: var(--text-xs);
}

.markdown-entry-remove {
  font-size: var(--text-base);
  color: var(--text-muted);
  padding: 4px;
}

.markdown-entry-remove:hover {
  color: var(--danger-color);
}

.markdown-entry .input {
  border: none;
  border-radius: 0;
}

/* ─── Markdown editor ─── */

.md-editor {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.md-editor-toggle {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--hover-bg);
}

.md-toggle-btn {
  border-radius: 0 !important;
  border: none !important;
  background: transparent !important;
  padding: 8px 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.md-toggle-btn:hover {
  color: var(--text-primary);
  background: transparent !important;
}

.md-toggle-btn.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--primary-color);
}

.md-editor-input.input {
  border: none !important;
  border-radius: 0;
  background: var(--input-bg);
  resize: vertical;
  min-height: 60px;
  box-shadow: none;
}

.md-editor-input.input:focus {
  border: none !important;
  box-shadow: none;
}

.md-editor-preview {
  padding: 12px 16px;
  background: var(--input-bg);
  min-height: 60px;
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* ─── Rendered markdown ─── */

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--accent);
  font-weight: 600;
  margin-top: 1em;
  margin-bottom: 0.4em;
  letter-spacing: -0.02em;
}

.markdown-body h1 { font-size: var(--text-xl); }
.markdown-body h2 { font-size: var(--text-lg); }
.markdown-body h3 { font-size: var(--text-base); }
.markdown-body h4 { font-size: var(--text-sm); }

.markdown-body p {
  margin-bottom: 0.6em;
}

.markdown-body a {
  color: var(--primary-color);
}

.markdown-body a:hover {
  color: var(--link-hover);
}

.markdown-body strong {
  font-weight: 600;
  color: var(--accent);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.35em;
  background: var(--hover-bg);
  border-radius: var(--radius-sm);
}

.markdown-body pre {
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  overflow-x: auto;
  margin: 0.6em 0;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
  margin-bottom: 0.6em;
}

.markdown-body li {
  margin-bottom: 0.25em;
}

.markdown-body blockquote {
  border-left: 3px solid var(--primary-color);
  padding-left: 0.85rem;
  color: var(--text-muted);
  margin: 0.6em 0;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1em 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.markdown-body del {
  text-decoration: line-through;
  color: var(--text-muted);
}

.markdown-body input[type="checkbox"] {
  margin-right: 0.4em;
  accent-color: var(--secondary-color);
}

/* ─── Bottom Sheet ─── */

.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 250;
}

.bottom-sheet-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.bottom-sheet-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: sheetUp 250ms ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin: 12px auto 8px;
  flex-shrink: 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.bottom-sheet-header-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent);
}

.bottom-sheet-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}

.bottom-sheet-close:hover {
  color: var(--text-primary);
}

.bottom-sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

@keyframes sheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes sheetDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

.bottom-sheet-exit .bottom-sheet-panel {
  animation: sheetDown 200ms ease forwards;
}

.bottom-sheet-exit .bottom-sheet-overlay {
  animation: fadeOut 200ms ease forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Desktop: render as centered modal instead */
@media (min-width: 769px) {
  .bottom-sheet-panel {
    position: absolute;
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    max-width: 540px;
    width: calc(100% - 2rem);
    max-height: 85vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    animation: fadeIn 200ms ease;
  }

  .bottom-sheet-exit .bottom-sheet-panel {
    animation: fadeOut 200ms ease forwards;
  }

  .bottom-sheet-handle {
    display: none;
  }

  .bottom-sheet-content {
    padding: 16px;
  }
}

/* ─── Toasts ─── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  max-width: 420px;
  width: calc(100% - 2rem);
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: 100%;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-exit {
  animation: toastOut 0.25s ease forwards;
}

.toast-success { border-left: 3px solid var(--primary-color); }
.toast-error { border-left: 3px solid var(--danger-color); }
.toast-warning { border-left: 3px solid #e6a817; }
.toast-info { border-left: 3px solid var(--text-muted); }

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

.toast-action {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

.toast-action:hover {
  opacity: 0.8;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-base);
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  opacity: 1;
}

@media (max-width: 768px) {
  .toast-container {
    bottom: auto;
    top: 1rem;
    flex-direction: column;
  }

  body.pwa-ios-body .toast-container {
    top: calc(44px + 0.5rem);
  }

  body.pwa-ios-body .lightbox-close {
    top: calc(44px + 0.5rem);
  }
}

/* ─── Animations ─── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

/* ─── Sync prompt ─── */

.sync-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: syncOverlayIn 0.15s ease-out;
}

@keyframes syncOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sync-prompt {
  background: rgba(30, 30, 30, 0.6);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 2rem 1.75rem 1.5rem;
  max-width: 340px;
  width: calc(100% - 2rem);
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: syncDialogIn 0.2s ease-out;
}

@keyframes syncDialogIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

[data-theme="light"] .sync-prompt {
  background: rgba(240, 237, 230, 0.55);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.sync-prompt-icon {
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.sync-prompt-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}

.sync-prompt-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.sync-prompt-text strong {
  color: var(--text-primary);
}

.sync-prompt-actions {
  display: flex;
  gap: 0.625rem;
}

.sync-prompt-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  border-radius: 10px;
  border: none;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.sync-prompt-skip {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.sync-prompt-skip:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

[data-theme="light"] .sync-prompt-skip {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .sync-prompt-skip:hover {
  background: rgba(0, 0, 0, 0.1);
}

.sync-prompt-confirm {
  background: var(--primary-color);
  color: #fff;
}

.sync-prompt-confirm:hover {
  opacity: 0.85;
}
