/* 🌟 iOS ТЕМА И ПЕРЕМЕННЫЕ */
:root { 
    --bg-color: #f2f2f7; 
    --card-bg: #ffffff; 
    --text-color: #000000; 
    --text-muted: #8e8e93;
    --primary: #007aff; 
    --danger: #ff3b30; 
    --success: #34c759; 
    --warning: #ff9500; 
    --info: #5856d6; 
    --border: #c6c6c8; 
    --input-bg: #e3e3e8;
    
    /* 🌟 Переменные для поиска */
    --dropdown-bg: rgba(255, 255, 255, 0.85);
    --dropdown-border: rgba(0, 0, 0, 0.1);
    --item-border: rgba(0, 0, 0, 0.05);
    --item-hover: rgba(0, 0, 0, 0.03);

    --radius-lg: 16px; 
    --radius-md: 12px; 
    --radius-sm: 8px;

    /* ПУТИ К ОФИЦИАЛЬНЫМ ИКОНКАМ APPLE (СВЕТЛЫЕ) */
    --icon-add: url('/img/apple_icons/icons-symbols-meaning-add@2x.png');
    --icon-delete: url('/img/apple_icons/icons-symbols-meaning-delete@2x.png');
    --icon-move: url('/img/apple_icons/icons-symbols-meaning-move@2x.png');
    --icon-search: url('/img/apple_icons/icons-symbols-meaning-search@2x.png');
    --icon-close: url('/img/apple_icons/icons-symbols-meaning-close-cancel@2x.png');
    --icon-edit: url('/img/apple_icons/icons-symbols-meaning-compose@2x.png');
    --icon-print: url('/img/apple_icons/icons-symbols-meaning-print@2x.png');
    --icon-archive: url('/img/apple_icons/icons-symbols-meaning-archive@2x.png');
    --icon-user: url('/img/apple_icons/icons-symbols-meaning-account-user@2x.png');
    --icon-sharing: url('/img/apple_icons/icons-symbols-meaning-sharing@2x.png');
    --icon-correct: url('/img/apple_icons/icons-selection-correct@2x.png');
    --icon-find: url('/img/apple_icons/icons-symbols-meaning-find@2x.png');
    --icon-log: url('/img/apple_icons/icons-symbols-meaning-calendar@2x.png');
    --icon-qr: url('/img/apple_icons/icons-symbols-meaning-qr@2x.png');
    --icon-more: url('/img/apple_icons/icons-symbols-meaning-more@2x.png');
    --icon-take: url('/img/apple_icons/icons-symbols-meaning-take@2x.png');
    --icon-return: url('/img/apple_icons/icons-symbols-meaning-return@2x.png');
    --icon-here: url('/img/apple_icons/icons-symbols-meaning-here@2x.png');
    --icon-select-all: url('/img/apple_icons/icons-symbols-meaning-select-all@2x.png');
    --icon-attach: url('/img/apple_icons/icons-symbols-meaning-attach@2x.png');
    --icon-arrow-back: url('/img/apple_icons/icons-symbols-meaning-arrow-back@2x.png');
    --icon-clear: url('/img/apple_icons/icons-symbols-meaning-deselect-close@2x.png');
    --icon-fullscreen: url('/img/apple_icons/icons-symbols-meaning-fullscreen@2x.png');

    /* 🌟 ИКОНКИ ПЕРЕКЛЮЧЕНИЯ ТЕМ */
    --icon-theme-system: url('/img/apple_icons/icons-symbols-theme-system@2x.png');
    --icon-theme-light: url('/img/apple_icons/icons-symbols-theme-light@2x.png');
    --icon-theme-dark: url('/img/apple_icons/icons-symbols-theme-dark@2x.png');
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; padding: 0; padding-bottom: 120px; -webkit-font-smoothing: antialiased; background-attachment: fixed; transition: background-color 0.3s, color 0.3s; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* 🌟 БЛОКИРОВКА ФОНОВОГО СКРОЛЛА ПРИ ОТКРЫТЫХ ОКНАХ */
body.modal-open { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.5px; }
h1 { font-size: 34px; line-height: 41px; margin-bottom: 5px; }
h2 { font-size: 28px; line-height: 34px; }
h3 { font-size: 20px; line-height: 25px; margin-bottom: 15px; }

.app-brand-title { font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", sans-serif; font-size: 38px; font-weight: 800; color: var(--text-color); letter-spacing: -1.5px; }

#auth-view { max-width: 380px; margin: 80px auto; background: var(--card-bg); padding: 30px; border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
.auth-switch { text-align: center; margin-top: 20px; font-size: 15px; color: var(--primary); cursor: pointer; font-weight: 500; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
header h1 { font-size: 28px; line-height: 1.1; margin: 0; display: flex; align-items: center; gap: 8px; }

.breadcrumbs { font-size: 17px; color: var(--text-muted); margin-bottom: 20px; font-weight: 500; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumbs span { cursor: pointer; color: var(--primary); transition: opacity 0.2s; }
.breadcrumbs span:active { opacity: 0.5; }
.breadcrumbs span:last-child { color: var(--text-color); cursor: default; }
.breadcrumb-sep { color: #c7c7cc; font-size: 14px; margin: 0 2px; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; width: 100%; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
select, input[type="text"], input[type="password"], textarea { background: var(--input-bg); border: none; border-radius: var(--radius-md); padding: 12px 16px; font-size: 16px; color: var(--text-color); outline: none; transition: box-shadow 0.2s, background 0.2s; font-family: inherit; }
select:focus, input:focus, textarea:focus { background: var(--card-bg); box-shadow: 0 0 0 2px var(--primary); }
.checkbox-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--input-bg); border-radius: var(--radius-md); cursor: pointer; }
.checkbox-row input { transform: scale(1.3); margin: 0; accent-color: var(--primary); cursor: pointer; }
.checkbox-row span { font-size: 16px; font-weight: 500; }

button { padding: 12px 18px; border: none; border-radius: var(--radius-md); font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.1s, opacity 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:active { transform: scale(0.96); opacity: 0.8; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-success { background-color: var(--success); color: white; }
.btn-warning { background-color: var(--warning); color: white; }
.btn-info { background-color: var(--info); color: white; }
.btn-alt { background-color: var(--input-bg); color: var(--primary); transition: background-color 0.3s; }

.apple-icon { display: inline-block; width: 26px; height: 26px; background-size: contain; background-repeat: no-repeat; background-position: center; vertical-align: middle; margin-top: -2px; flex-shrink: 0; }
.icon-btn { position: relative; pointer-events: auto; background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: none; border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: transform 0.1s; padding: 0; flex-shrink: 0; }
.icon-btn .apple-icon { transform: scale(1.4); }
.action-btn .apple-icon { transform: scale(1.2); } 

.apple-icon.add { background-image: var(--icon-add); }
.apple-icon.delete { background-image: var(--icon-delete); }
.apple-icon.move { background-image: var(--icon-move); }
.apple-icon.search { background-image: var(--icon-search); }
.apple-icon.close { background-image: var(--icon-close); }
.apple-icon.edit { background-image: var(--icon-edit); }
.apple-icon.print { background-image: var(--icon-print); }
.apple-icon.archive { background-image: var(--icon-archive); }
.apple-icon.user { background-image: var(--icon-user); }
.apple-icon.sharing { background-image: var(--icon-sharing); }
.apple-icon.correct { background-image: var(--icon-correct); }
.apple-icon.find { background-image: var(--icon-find); }
.apple-icon.log { background-image: var(--icon-log); }
.apple-icon.qr { background-image: var(--icon-qr); }
.apple-icon.more { background-image: var(--icon-more); }
.apple-icon.take { background-image: var(--icon-take); }
.apple-icon.return { background-image: var(--icon-return); }
.apple-icon.here { background-image: var(--icon-here); }
.apple-icon.select-all { background-image: var(--icon-select-all); }
.apple-icon.attach { background-image: var(--icon-attach); }
.apple-icon.arrow-back { background-image: var(--icon-arrow-back); }
.apple-icon.clear { background-image: var(--icon-clear); }
.apple-icon.fullscreen { background-image: var(--icon-fullscreen); }

.apple-icon.theme-system { background-image: var(--icon-theme-system); }
.apple-icon.theme-light { background-image: var(--icon-theme-light); }
.apple-icon.theme-dark { background-image: var(--icon-theme-dark); }

.btn-primary .apple-icon, .btn-danger .apple-icon, .btn-success .apple-icon, .btn-info .apple-icon, .fab-main .apple-icon { filter: brightness(0) invert(1); }

details.spoiler-access { background: var(--bg-color); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--border); }
details.spoiler-access summary { font-size: 15px; font-weight: 600; color: var(--text-color); cursor: pointer; outline: none; user-select: none; display: flex; align-items: center; gap: 8px; }
details.spoiler-access summary::marker { color: var(--primary); }
details.spoiler-access .spoiler-content { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid rgba(0,0,0,0.05); padding-top: 12px; }

.fab-wrapper { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px; pointer-events: none;}
.fab-menu { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; opacity: 0; pointer-events: none; transform: translateY(20px); transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.fab-wrapper.open .fab-menu { opacity: 1; pointer-events: auto; transform: translateY(0); }
.fab-main { width: 56px; height: 56px; border-radius: 28px; background: var(--primary); color: white; border: none; box-shadow: 0 6px 16px rgba(0,0,0,0.25); cursor: pointer; transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); display: flex; align-items: center; justify-content: center; padding: 0; pointer-events: auto;}
.fab-wrapper.open .fab-main { transform: rotate(45deg); background: var(--danger); }
.fab-wrapper.open.print-mode-active .fab-main { transform: rotate(0deg); background: var(--primary); }
.fab-menu-btn { background: var(--card-bg); border: none; padding: 12px 18px; border-radius: 20px; font-size: 15px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.15); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; color: var(--text-color); }

.fab-wrapper.select-mode-active .fab-main { background: var(--info); }
.fab-wrapper.select-mode-active.open .fab-main { background: var(--danger); }

.toolbar { 
    background: var(--card-bg); 
    border-radius: var(--radius-lg); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.04); 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    
    /* Начальное состояние: полностью скрыта и схлопнута */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 16px; /* Анимируем только вертикальные отступы */
    margin-bottom: 0;
    pointer-events: none; /* Чтобы нельзя было случайно нажать сквозь невидимую панель */
    
    /* Идеально просчитанные iOS-тайминги анимации */
    transition: max-height 0.28s cubic-bezier(0.25, 1, 0.5, 1), 
                opacity 0.2s ease-out, 
                padding 0.28s cubic-bezier(0.25, 1, 0.5, 1), 
                margin-bottom 0.28s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Состояние, когда панель активна */
.toolbar.visible {
    max-height: 160px; /* Высота с запасом под обе строчки фильтров и поиска */
    opacity: 1;
    padding: 16px;
    margin-bottom: 24px;
    pointer-events: auto;
    overflow: visible !important;
}
.toolbar-filters { display: flex; gap: 10px; width: 100%; }
.toolbar-filters select { flex: 1; background: var(--bg-color); }

.toolbar-search-row { display: flex; gap: 8px; width: 100%; }
.search-container { position: relative; flex: 1; min-width: 0; }
.search-container input { width: 100%; box-sizing: border-box; padding-left: 40px; background: var(--bg-color); }
.search-icon {position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; display: flex; align-items: center; justify-content: center; }
/* 🌟 СТИЛЬ ДЛЯ ВНУТРЕННЕЙ КНОПКИ ПОИСКА */
.search-action-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: none; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; outline: none; }
.search-action-btn:active {
    transform: translateY(-50%) scale(0.96) !important;
}
/* 🌟 ДИНАМИЧЕСКИЕ ПЕРЕМЕННЫЕ ВЫПАДАЮЩЕГО СПИСКА */
.search-dropdown { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--dropdown-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--dropdown-border); border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); max-height: 400px; overflow-y: auto; z-index: 1000; }
.search-item { padding: 12px 16px; border-bottom: 1px solid var(--item-border); cursor: pointer; transition: background 0.2s; }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--item-hover); }
.search-item-title { font-weight: 600; font-size: 16px; color: var(--text-color); display: flex; align-items: center; gap: 6px; }
.search-item-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

#move-banner { display: none; background: #fffbeb; padding: 16px; margin-bottom: 20px; border-radius: var(--radius-lg); border: 2px dashed var(--warning); justify-content: space-between; align-items: center; font-size: 16px; font-weight: 500; flex-wrap: wrap; gap: 10px; color: #000000; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 40px; }
.grid-separator { grid-column: 1 / -1; margin-top: 15px; margin-bottom: 0; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.card { 
    position: relative; 
    width: 100%; 
    border-radius: var(--radius-lg); 
    overflow: hidden; 
    background: #d1d1d6; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
    display: block; 
    transform: translateZ(0); 
    transition: transform 0.2s, border 0.2s; 
    
    /* 🌟 ИСПРАВЛЕНИЕ БАГА SAFARI С ХИТБОКСАМИ */
    contain: paint; /* Жестко запирает зону клика внутри карточки */
    z-index: 1;     /* Заставляет браузер просчитать слой заново */
}
.card.root-space { grid-column: span 6; aspect-ratio: 3 / 2; }
.card.child-space { grid-column: span 3; aspect-ratio: 1 / 1; }
.card.item { grid-column: span 2; aspect-ratio: 1 / 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }

@media (min-width: 600px) { .grid { grid-template-columns: repeat(12, 1fr); gap: 16px; } .card.root-space { grid-column: span 6; } .card.child-space { grid-column: span 4; } .card.item { grid-column: span 3; } }

.card.taken { border: 3px solid var(--warning); }
.card.moving { border: 3px dashed var(--primary); opacity: 0.8; }
.card.ghost { opacity: 0.5; filter: grayscale(50%); }

.fullscreen-trigger-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.5); /* Полупрозрачный фон, чтобы иконку было видно на светлых фото */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: 0.2s;
    z-index: 10;
}
.fullscreen-trigger-btn .apple-icon {
    width: 20px;
    height: 20px;
}
.fullscreen-trigger-btn:active {
    transform: scale(0.9) !important;
}

.select-overlay { position: absolute; top:0; left:0; right:0; bottom:0; z-index: 5; cursor: pointer; }

.selection-circle { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 13px; border: 2px solid white; background: rgba(0,0,0,0.3); z-index: 20; display: none; box-shadow: 0 2px 4px rgba(0,0,0,0.2); background-size: 16px; background-repeat: no-repeat; background-position: center; }
.select-mode .selection-circle { display: block; }
.select-mode .card-top-right { display: none !important; }
.card.selected .selection-circle { background-color: var(--primary); border-color: var(--primary); background-image: url('/img/apple_icons/icons-symbols-meaning-done-save~dark@2x.png'); }
.card.selected { border: 3px solid var(--primary); transform: scale(0.97); }

.card-gallery { display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.card-gallery::-webkit-scrollbar { display: none; }
.card-gallery img, .card-gallery .no-photo { width: 100%; height: 100%; object-fit: cover; flex-shrink: 0; scroll-snap-align: center; pointer-events: none; }
.card-gallery .no-photo { display: flex; align-items: center; justify-content: center; background: #c7c7cc; }
.card-gallery .no-photo .apple-icon { width: 44px; height: 44px; opacity: 0.5; }

.card-gradient-bottom { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, transparent 100%); padding: 20px 12px 12px 12px; color: white; pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; }
.card.child-space .card-gradient-bottom { padding: 15px 48px 8px 8px; } 
.card.item .card-gradient-bottom { padding: 15px 8px 8px 8px; }

.card-title { font-size: 22px; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,0.5); margin-bottom: 2px; line-height: 1.1; word-break: break-word; }
.card-desc { font-size: 14px; color: rgba(255,255,255,0.8); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.child-space .card-title, .card.item .card-title { font-size: 15px; }
.card.child-space .card-desc, .card.item .card-desc { display: none; }

.card-top-right { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 20; }
.card.child-space .card-top-right { flex-direction: column; top: 8px; right: 8px; gap: 8px; }
.card.item .card-top-right { display: none; } 

.card-top-left { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 20; }
.badge { padding: 4px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; color: white; box-shadow: 0 2px 8px rgba(0,0,0,0.2); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); width: max-content; }
.badge.space { background-color: rgba(52, 199, 89, 0.9); }
.badge.item { background-color: rgba(0, 122, 255, 0.9); }
.badge.taken-badge { background-color: rgba(255, 149, 0, 0.9); }
.card.child-space .badge, .card.item .badge { font-size: 10px; padding: 2px 6px; }

.taken-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(255, 255, 255, 0.95); padding: 10px 14px; border-radius: var(--radius-md); box-shadow: 0 10px 20px rgba(0,0,0,0.15); font-size: 13px; font-weight: 600; color: var(--warning); text-align: center; width: max-content; max-width: 85%; pointer-events: none; z-index: 15; }

.synonyms { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; margin-bottom: 12px; }
.tag { background: var(--bg-color); padding: 4px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border); }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 2000; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.modal-content { background: var(--card-bg); border-radius: 24px; width: 100%; max-width: 500px; max-height: 85vh; box-shadow: 0 20px 40px rgba(0,0,0,0.2); position: relative; display: flex; flex-direction: column; overflow: hidden; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.modal-footer { padding: 16px 24px 24px 24px; background: var(--card-bg); border-top: 1px solid rgba(0,0,0,0.05); flex-shrink: 0; display: flex; gap: 10px; }

.log-list { background: var(--bg-color); border-radius: var(--radius-lg); padding: 0 16px; }
.log-entry { padding: 16px 0; border-bottom: 1px solid var(--border); font-size: 15px; line-height: 1.4; }
.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--text-muted); font-size: 13px; display: block; margin-top: 6px; font-weight: 500; }
.log-user { font-weight: 600; color: var(--text-color); }
.log-object-link { color: var(--primary); text-decoration: none; cursor: pointer; font-weight: 600; }
.access-list { background: var(--bg-color); border-radius: var(--radius-md); padding: 4px; border: 1px solid var(--border); }
.access-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.access-row:last-child { border-bottom: none; }

.viewer-gallery-wrapper { position: relative; margin: -24px -24px 20px -24px; }
.viewer-gallery { height: 300px; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; background: #e5e5ea; }
.viewer-gallery::-webkit-scrollbar { display: none; }
.viewer-gallery img { width: 100%; height: 100%; object-fit: cover; flex-shrink: 0; scroll-snap-align: center; }
.viewer-gallery .no-photo { display: flex; width: 100%; align-items: center; justify-content: center; background: #c7c7cc; }
.viewer-gallery .no-photo .apple-icon { width: 64px; height: 64px; opacity: 0.3; }

.gallery-indicators { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; pointer-events: none; z-index: 10; }
.gallery-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.4); transition: transform 0.2s, background 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.gallery-dot.active { background: #ffffff; transform: scale(1.4); }

.edit-gallery-container { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.edit-gallery-container::-webkit-scrollbar { display: none; }

.qr-viewfinder { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); background: #000; margin: 0 auto; }
#qr-canvas { width: 100%; height: 100%; object-fit: cover; }
.qr-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; box-shadow: inset 0 0 0 50px rgba(0,0,0,0.6); pointer-events: none; }
.qr-frame { position: absolute; top: 50px; left: 50px; right: 50px; bottom: 50px; border: 3px solid rgba(255,255,255,0.9); border-radius: 16px; pointer-events: none; }

/* 🌟 ТЕМНАЯ ТЕМА (РУЧНАЯ И СИСТЕМНАЯ) */
html[data-theme="dark"] {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-color: #ffffff;
    --text-muted: #98989d;
    --input-bg: #2c2c2e;
    --border: #3a3a3c;
    
    /* 🌟 Меняем переменные поиска для тёмной темы */
    --dropdown-bg: rgba(28, 28, 30, 0.95);
    --dropdown-border: rgba(255, 255, 255, 0.1);
    --item-border: rgba(255, 255, 255, 0.05);
    --item-hover: rgba(255, 255, 255, 0.05);

    --icon-add: url('/img/apple_icons/icons-symbols-meaning-add~dark@2x.png');
    --icon-delete: url('/img/apple_icons/icons-symbols-meaning-delete~dark@2x.png');
    --icon-move: url('/img/apple_icons/icons-symbols-meaning-move~dark@2x.png'); 
    --icon-search: url('/img/apple_icons/icons-symbols-meaning-search~dark@2x.png');
    --icon-close: url('/img/apple_icons/icons-symbols-meaning-close-cancel~dark@2x.png');
    --icon-edit: url('/img/apple_icons/icons-symbols-meaning-compose~dark@2x.png');
    --icon-print: url('/img/apple_icons/icons-symbols-meaning-print~dark@2x.png');
    --icon-archive: url('/img/apple_icons/icons-symbols-meaning-archive~dark@2x.png');
    --icon-user: url('/img/apple_icons/icons-symbols-meaning-account-user~dark@2x.png');
    --icon-sharing: url('/img/apple_icons/icons-symbols-meaning-sharing~dark@2x.png');
    --icon-correct: url('/img/apple_icons/icons-selection-correct~dark@2x.png');
    --icon-find: url('/img/apple_icons/icons-symbols-meaning-find~dark@2x.png');
    --icon-log: url('/img/apple_icons/icons-symbols-meaning-calendar~dark@2x.png');
    --icon-qr: url('/img/apple_icons/icons-symbols-meaning-qr~dark@2x.png'); 
    --icon-more: url('/img/apple_icons/icons-symbols-meaning-more~dark@2x.png');
    --icon-take: url('/img/apple_icons/icons-symbols-meaning-take~dark@2x.png');
    --icon-return: url('/img/apple_icons/icons-symbols-meaning-return~dark@2x.png');
    --icon-here: url('/img/apple_icons/icons-symbols-meaning-here~dark@2x.png');
    --icon-select-all: url('/img/apple_icons/icons-symbols-meaning-select-all~dark@2x.png'); 
    --icon-attach: url('/img/apple_icons/icons-symbols-meaning-attach~dark@2x.png');
    --icon-arrow-back: url('/img/apple_icons/icons-symbols-meaning-arrow-back~dark@2x.png');
    --icon-clear: url('/img/apple_icons/icons-symbols-meaning-deselect-close~dark@2x.png');
    --icon-fullscreen: url('/img/apple_icons/icons-symbols-meaning-fullscreen~dark@2x.png');
}

html[data-theme="dark"] body { background-color: var(--bg-color) !important; }
html[data-theme="dark"] .container { background-color: var(--bg-color); }
html[data-theme="dark"] .modal-content { background: var(--card-bg) !important; }
html[data-theme="dark"] .card-gallery img, html[data-theme="dark"] .viewer-gallery img { filter: brightness(0.8); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { color: white !important; }
html[data-theme="dark"] .log-user { color: #ffffff; }
html[data-theme="dark"] .toolbar, html[data-theme="dark"] .modal-footer { background: var(--card-bg) !important; }
html[data-theme="dark"] .icon-btn { background: rgba(0, 0, 0, 0.45) !important; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important; }
html[data-theme="dark"] .btn-primary .apple-icon, html[data-theme="dark"] .btn-danger .apple-icon, html[data-theme="dark"] .btn-success .apple-icon, html[data-theme="dark"] .btn-info .apple-icon, html[data-theme="dark"] .fab-main .apple-icon { filter: none; }
html[data-theme="dark"] .icon-btn .apple-icon { filter: none; }
html[data-theme="dark"] select:focus, html[data-theme="dark"] input:focus, html[data-theme="dark"] textarea:focus { background: var(--input-bg) !important; color: #ffffff !important; box-shadow: 0 0 0 2px var(--primary); }

/* Принудительно делаем белыми иконки переключателя тем, если включена темная тема */
html[data-theme="dark"] .apple-icon.theme-system, 
html[data-theme="dark"] .apple-icon.theme-light, 
html[data-theme="dark"] .apple-icon.theme-dark {
    filter: brightness(0) invert(1);
}
