.photo-drag-handle,
.album-drag-handle {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--muted);
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease, color 0.2s ease;
}

.photo-drag-handle {
  top: 0.35rem;
  left: 0.35rem;
  width: 1.75rem;
  height: 1.75rem;
}

.album-drag-handle {
  top: 0.5rem;
  left: 0.5rem;
  width: 2rem;
  height: 2rem;
}

.photo-drag-handle:hover,
.album-drag-handle:hover {
  background: #fff;
  color: var(--text);
}

.photo-drag-handle:active,
.album-drag-handle:active {
  cursor: grabbing;
}

.photo-delete-btn,
.album-edit-btn {
  position: absolute;
  top: 0.35rem;
  z-index: 2;
  border: none;
  border-radius: 50%;
  width: 1.75rem;
  height: 1.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease;
}

.photo-delete-btn {
  right: 0.35rem;
  background: rgba(220, 53, 69, 0.85);
  color: #fff;
}

.photo-delete-btn:hover {
  background: #c82333;
}

.photo-view-count {
  position: absolute;
  bottom: 10px;
  right: 5px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

.photo-view-count::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'%3E%3C/path%3E%3Ccircle cx='12' cy='12' r='3'%3E%3C/circle%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.photo-select {
  position: absolute;
  bottom: calc(0.35rem + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #3b82f6;
  cursor: pointer;
  margin: 0;
}

.photo-comments-count {
  position: absolute;
  bottom: 10px;
  left: 5px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

.photo-comments-count::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.album-edit-btn {
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}

.album-edit-btn::after,
.album-share-btn::after,
.album-drag-handle::after,
.photo-drag-handle::after,
.photo-delete-btn::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.album-edit-btn:hover::after,
.album-share-btn:hover::after,
.album-drag-handle:hover::after,
.photo-drag-handle:hover::after,
.photo-delete-btn:hover::after {
  opacity: 1;
}

.album-edit-btn:hover {
  background: #fff;
}

.album-share-btn {
  position: absolute;
  top: 0.5rem;
  right: 6rem;
  width: 2rem;
  height: 2rem;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  border: none;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease;
  z-index: 2;
}

.album-share-btn:hover {
  background: #fff;
}

/* ===== Базовые стили диалогов ===== */
.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  background: var(--panel);
  box-shadow: var(--shadow-dialog);
}

.dialog::backdrop {
  background: rgba(10, 15, 21, 0.5);
}

.dialog h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.dialog .form-group {
  margin-bottom: 1rem;
}

.dialog .form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.dialog .form-group input {
  box-sizing: border-box;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
}

.dialog .form-group input:focus {
  outline: none;
  border-color: var(--muted);
}

.dialog .dialog-actions,
.create-album-actions,
.album-edit-actions,
.delete-album-actions,
.cover-selector-actions,
.sort-photos-actions,
.confirm-dialog-actions,
.upload-actions,
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ===== Общие стили кнопок ===== */
.btn-primary {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  background: var(--text);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--line);
}

.btn-danger {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  background: #d32f2f;
  color: #fff;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-action.btn-danger {
  background: rgba(220, 53, 69, 0.1);
  color: #d32f2f;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

.btn-action.btn-danger:hover {
  background: rgba(220, 53, 69, 0.2);
  border-color: rgba(220, 53, 69, 0.5);
}

/* ===== Dark theme — диалоги и кнопки ===== */
[data-theme="dark"] .dialog h3 {
  color: #e2e8f0;
}

[data-theme="dark"] .dialog .form-group input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
  color-scheme: dark;
}

[data-theme="dark"] .dialog .form-group input:focus {
  border-color: #475569;
}

[data-theme="dark"] .btn-primary {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="dark"] .btn-secondary {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #475569;
}

[data-theme="dark"] .btn-danger {
  background: #ef4444;
}

[data-theme="dark"] .btn-danger:hover {
  background: #dc2626;
}

[data-theme="dark"] .btn-action.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .btn-action.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

/* ===== Cover selector ===== */
.cover-selector-dialog {
  padding: 0;
  max-width: 600px;
}

.cover-selector-content {
  padding: 1.5rem;
}

.cover-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.cover-selector-item {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.cover-selector-item:hover {
  transform: scale(1.03);
}

.cover-selector-item.selected {
  border-color: #3b82f6;
}

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

.cover-selector-grid .no-images {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2rem 1rem;
}

[data-theme="dark"] .cover-selector-item {
  background: var(--bg);
}

.cover-selector-content h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

[data-theme="dark"] .cover-selector-content h3 {
  color: #e2e8f0;
}

[data-theme="dark"] .cover-selector-actions .btn-secondary {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .cover-selector-actions .btn-secondary:hover {
  background: #475569;
}

/* ===== Login dialog ===== */
[data-theme="dark"] .login-error {
  color: #ef4444;
}

.admin-dialog::backdrop {
  background: rgba(10, 15, 21, 0.5);
}

.admin-dialog-content h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.admin-dialog .form-group {
  margin-bottom: 1rem;
}

.admin-dialog .form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-dialog .form-group input {
  box-sizing: border-box;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
}

.admin-dialog .form-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-dialog .btn-primary,
.admin-dialog .btn-secondary {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

.admin-dialog .btn-primary {
  background: var(--text);
  color: #fff;
}

.admin-dialog .btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.admin-dialog .login-error {
  margin: 0.75rem 0 0;
  color: #d32f2f;
  font-size: 0.9rem;
}

[data-theme="dark"] .admin-dialog .form-group input {
  color-scheme: dark;
}

[data-theme="dark"] .admin-dialog-content h3 {
  color: #e2e8f0;
}

[data-theme="dark"] .admin-dialog .btn-primary {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="dark"] .admin-dialog .btn-secondary:hover {
  background: var(--line);
}

/* ===== Create album dialog ===== */
.create-album-dialog {
  max-width: 450px;
}

.create-album-dialog-content .form-group label {
  color: var(--text);
}

.create-album-dialog-content .form-group input[type="text"],
.create-album-dialog-content .form-group input[type="number"],
.create-album-dialog-content .form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.create-album-dialog-content .form-group input:focus,
.create-album-dialog-content .form-group select:focus {
  outline: none;
  border-color: var(--muted);
}

.create-album-dialog-content .album-edit-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}

.create-album-dialog-content .album-edit-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--text);
}

.create-album-error {
  margin: 0.75rem 0 0;
  color: #d32f2f;
  font-size: 0.9rem;
}

[data-theme="dark"] .create-album-dialog-content .form-group input,
[data-theme="dark"] .create-album-dialog-content .form-group select {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .create-album-dialog-content .form-group input:focus,
[data-theme="dark"] .create-album-dialog-content .form-group select:focus {
  border-color: #475569;
}

/* ===== Album edit dialog ===== */
.album-edit-dialog {
  padding: 0;
  max-width: 420px;
}

.album-edit-dialog-content {
  padding: 1.5rem;
}

.album-edit-dialog .album-edit-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.album-edit-dialog .album-edit-row label {
  min-width: 52px;
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}

.album-edit-dialog .album-edit-row input,
.album-edit-dialog .album-edit-row select {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
}

.album-edit-dialog .album-edit-row textarea {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  resize: vertical;
}

.album-edit-dialog .album-edit-row-comment {
  align-items: flex-start;
}

.album-edit-dialog .album-edit-row-comment label {
  padding-top: 0.45rem;
}

.album-edit-dialog .album-edit-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.album-edit-dialog .album-edit-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--text);
}

.album-edit-toggles {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.album-edit-row-accesskey {
  position: relative;
}

.accesskey-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.accesskey-wrapper input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  background: var(--panel);
  color: var(--text);
}

.btn-regen-key {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-regen-key:hover {
  background: var(--bg);
  color: var(--text);
}

.cover-preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  flex: 1;
}

.cover-preview {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  display: none;
}

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

.album-edit-dialog .btn-select-cover {
  flex: 1;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease;
}

.album-edit-dialog .btn-select-cover:hover {
  background: var(--bg);
}

.album-edit-error {
  margin: 0.75rem 0 0;
  color: #d32f2f;
  font-size: 0.9rem;
}

[data-theme="dark"] .album-edit-error {
  color: #ef4444;
}

[data-theme="dark"] .album-edit-dialog .album-edit-row label {
  color: #94a3b8;
}

[data-theme="dark"] .album-edit-dialog .album-edit-row input,
[data-theme="dark"] .album-edit-dialog .album-edit-row select,
[data-theme="dark"] .album-edit-dialog .album-edit-row textarea,
[data-theme="dark"] .accesskey-wrapper input {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .btn-regen-key {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .btn-regen-key:hover {
  background: #334155;
  color: #e2e8f0;
}

/* ===== Delete album dialog ===== */
.delete-album-dialog {
  max-width: 450px;
}

.delete-album-dialog-content h3 {
  color: #d32f2f;
}

.delete-album-warning {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.delete-album-error {
  margin: 0.75rem 0 0;
  color: #d32f2f;
  font-size: 0.9rem;
}

[data-theme="dark"] .delete-album-dialog-content h3 {
  color: #ef4444;
}

[data-theme="dark"] .delete-album-warning {
  color: #e2e8f0;
}

.delete-album-dialog::backdrop {
  background: rgba(10, 15, 21, 0.5);
}

.album-delete-btn {
  position: absolute;
  bottom: 0.35rem;
  left: 0.35rem;
  z-index: 2;
  border: none;
  border-radius: 50%;
  width: 1.75rem;
  height: 1.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease;
  background: rgba(220, 53, 69, 0.85);
  color: #fff;
}

.album-delete-btn:hover {
  background: #c82333;
}

.album-delete-btn::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.album-delete-btn:hover::after {
  opacity: 1;
}

[data-theme="dark"] .album-delete-btn::after {
  color: #e2e8f0;
}

/* ===== Upload dialog ===== */
.upload-photos-dialog {
  padding: 0;
  max-width: 480px;
}

.upload-photos-content {
  padding: 1.5rem;
}

.upload-drop-zone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
}

.upload-drop-zone svg {
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.upload-drop-zone p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.upload-browse-link {
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
}

.upload-hint {
  font-size: 0.8rem !important;
  margin-top: 0.25rem !important;
  opacity: 0.7;
}

.upload-file-list {
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.upload-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.upload-file-item:last-child {
  border-bottom: none;
}

.upload-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.upload-file-size {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.upload-file-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.upload-file-remove:hover {
  color: #ef4444;
}

.upload-progress {
  margin-top: 1rem;
}

.upload-progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 3px;
  transition: width 0.2s ease;
  width: 0%;
}

.upload-progress-text {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.upload-error {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 0.85rem;
}

[data-theme="dark"] .upload-drop-zone {
  border-color: #334155;
}

[data-theme="dark"] .upload-drop-zone:hover,
[data-theme="dark"] .upload-drop-zone.dragover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

[data-theme="dark"] .upload-file-name {
  color: #e2e8f0;
}

[data-theme="dark"] .upload-file-remove:hover {
  color: #f87171;
}

[data-theme="dark"] .upload-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* ===== Sort photos dialog ===== */
.sort-photos-dialog {
  padding: 0;
  max-width: 400px;
}

.sort-photos-content {
  padding: 1.5rem;
}

.sort-photos-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.sort-photos-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sort-option-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sort-option-btn:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.sort-option-btn svg {
  flex-shrink: 0;
  color: var(--muted);
}

.sort-photos-error {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #ef4444;
  font-size: 0.85rem;
}

[data-theme="dark"] .sort-option-btn {
  color: #e2e8f0;
}

[data-theme="dark"] .sort-option-btn:hover {
  background: #334155;
}

[data-theme="dark"] .sort-photos-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* ===== Confirm dialog ===== */
.confirm-dialog {
  max-width: 400px;
}

.confirm-dialog-message {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

[data-theme="dark"] .confirm-dialog-message {
  color: #e2e8f0;
}

/* ===== Панель пакетных операций ===== */
.batch-toolbar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  width: 100%;
  box-sizing: border-box;
}

.batch-toolbar .btn-action,
.gallery-head-actions .btn-action {
  display: flex;
  align-items: center;
  height: 2.2rem;
}

.batch-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  margin-right: auto;
}

[data-theme="dark"] .batch-count {
  color: #94a3b8;
}

/* ===== Share album dialog (QR-код) ===== */
.share-album-dialog {
  max-width: 400px;
}

.share-album-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.share-album-qr {
  display: flex;
  justify-content: center;
  margin: 0 auto 1rem;
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  width: fit-content;
}

.share-album-url {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  margin-bottom: 1rem;
  outline: none;
}

.share-album-url:focus {
  border-color: #3b82f6;
}

[data-theme="dark"] .share-album-hint {
  color: #94a3b8;
}

[data-theme="dark"] .share-album-url {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .share-album-qr {
  border-color: #334155;
}

/* ===== Admin toggle, theme toggle, card style toggle, scroll top ===== */
.admin-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease, color 0.2s ease, border-radius 0.2s ease;
}

.admin-toggle:hover {
  color: var(--text);
}

[data-card-style="square"] .admin-toggle {
  border-radius: 0;
}

.theme-toggle {
  position: fixed;
  bottom: 4.5rem;
  right: 1rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease, color 0.2s ease, border-radius 0.2s ease;
}

.card-style-toggle {
  position: fixed;
  bottom: 8rem;
  right: 1rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease, color 0.2s ease, border-radius 0.2s ease;
}

.card-style-toggle:hover {
  color: var(--text);
}

[data-card-style="square"] .card-style-toggle {
  border-radius: 0;
}

.scroll-top-btn {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-handle);
  transition: background 0.2s ease, color 0.2s ease, border-radius 0.2s ease, opacity 0.2s ease;
}

.scroll-top-btn:hover {
  color: var(--text);
}

[data-card-style="square"] .scroll-top-btn {
  border-radius: 0;
}

[data-card-style="square"] .theme-toggle {
  border-radius: 0;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-icon-moon {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-moon {
  display: inline;
}

/* ===== Карта альбома ===== */
.album-map-container {
  width: 100%;
  margin: 0 0 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}

.album-map {
  width: 100%;
  height: 420px;
}

@media (max-width: 768px) {
  .album-map {
    height: 300px;
  }
}

[data-theme="dark"] .album-map-container {
  border-color: #334155;
}

/* ===== Админские страницы статистики ===== */
.admin-stats-page {
  max-width: 960px;
  margin: 0 auto;
}

/* Хлебные крошки (переменные темы покрывают оба режима). */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--text);
  text-decoration: underline;
}

.breadcrumbs-sep {
  color: var(--muted);
}

.breadcrumbs-current {
  color: var(--text);
  font-weight: 500;
}

.admin-stats-head {
  margin-bottom: 1.25rem;
}

.admin-stats-head h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 700;
}

.admin-stats-head p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.admin-stats-form {
  margin-bottom: 1.25rem;
}

.admin-stats-form-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.admin-stats-form-row label {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.admin-stats-form-row select,
.admin-stats-form-row input[type="date"],
.admin-stats-form-row input[type="number"] {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.admin-stats-form-row select:focus,
.admin-stats-form-row input[type="date"]:focus,
.admin-stats-form-row input[type="number"]:focus {
  outline: none;
  border-color: var(--muted);
}

.admin-stats-form-row input[type="number"] {
  width: 5.5rem;
}

.admin-stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.9rem;
}

.admin-stats-table th,
.admin-stats-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-stats-table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg);
}

.admin-stats-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-stats-table tbody tr:hover {
  background: var(--bg);
}

.admin-stats-rank {
  color: var(--muted);
  font-weight: 600;
}

.admin-stats-photo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
}

.admin-stats-photo img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.admin-stats-photo span {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-all;
}

.admin-stats-photo:hover span {
  color: var(--text);
}

.admin-stats-album {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.admin-stats-album:hover {
  text-decoration: underline;
}

.admin-stats-private {
  margin-left: 0.5rem;
}

.admin-stats-number {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.admin-stats-empty {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
}

.admin-comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-comment-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.admin-comment-item .admin-stats-photo img {
  width: 56px;
  height: 56px;
}

.admin-comment-body {
  flex: 1;
  min-width: 0;
}

.admin-comment-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.admin-comment-meta .comment-date {
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-comment-text {
  margin: 0 0 0.35rem;
  color: var(--text);
  white-space: pre-line;
  word-break: break-word;
}

.admin-comment-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-comment-delete {
  flex-shrink: 0;
}

[data-theme="dark"] .admin-stats-form-row select,
[data-theme="dark"] .admin-stats-form-row input[type="date"],
[data-theme="dark"] .admin-stats-form-row input[type="number"] {
  border-color: #334155;
  background: #1e293b;
  color: #e2e8f0;
}

[data-theme="dark"] .admin-stats-form-row select:focus,
[data-theme="dark"] .admin-stats-form-row input[type="date"]:focus,
[data-theme="dark"] .admin-stats-form-row input[type="number"]:focus {
  border-color: #475569;
}

[data-theme="dark"] .admin-stats-table th {
  background: #1e293b;
}

/* ===== Дашборд статистики ===== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.dashboard-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-cards);
  padding: 1.25rem;
  text-align: center;
}

.dashboard-card-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.dashboard-card-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1rem;
}

.dashboard-chart-container {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-cards);
  padding: 1rem;
}

.dashboard-chart-container h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }
}
