:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #71adfd;
  --primary-hover: #4338ca;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 20px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0; 
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg); 
  color: var(--text);
  transition: background-color 0.3s, color 0.3s;
}

.hidden { display: none !important; }

/* Header & Tabs */
header {
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  padding: 1rem 2rem; 
  background: var(--surface); 
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.3s ease;
}

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

.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: 0.5rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: 0.2s;
}
.icon-btn:hover { background: var(--border); }

.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.tab-btn.oval {
  padding: 0.5rem 1.25rem;
  border-radius: 50px; /* Овальная форма */
  border: 1px solid transparent;
  background: var(--border);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn.oval:hover:not(.static) { background: var(--text-muted); color: var(--surface); }
.tab-btn.oval.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.tab-btn.oval.outline { background: transparent; border-color: var(--border); }
.tab-btn.oval.outline:hover { border-color: var(--text-muted); }
.tab-btn.oval.static { cursor: default; background: transparent; border-color: var(--primary); color: var(--primary); }
.tab-btn.oval.action-btn { background: var(--surface); border: 1px solid var(--primary); color: var(--primary); }
.tab-btn.oval.action-btn:hover { background: var(--primary); color: #fff; }
.tab-btn.oval.danger { background: var(--surface); border: 1px solid var(--danger); color: var(--danger); }
.tab-btn.oval.danger:hover { background: var(--danger); color: #fff; }

#shared-tab-target.drag-over {
  background-color: var(--primary); color: #fff; transform: scale(1.05);
}

/* Layout */
.main-container { display: flex; height: calc(100vh - 73px); }

.content { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  height: 100%; 
}

/* Галерея */
.gallery-grid {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
  gap: 1.5rem;
  align-content: start;
}

.file-card {
  position: relative; 
  background: var(--surface);
  border-radius: var(--radius); 
  overflow: hidden;
  box-shadow: var(--shadow-md); 
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s;
  aspect-ratio: 1 / 1;
}
.file-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.file-card:active { cursor: grabbing; transform: translateY(-2px); }

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

/* Круглый современный чекбокс */
.file-checkbox {
  appearance: none;
  position: absolute; 
  top: 4px; 
  left: 4px; 
  width: 40px; 
  height: 40px;
  background-color: #4285f442;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer; 
  z-index: 10;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.file-checkbox:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
  border-color: var(--primary);
}

.file-checkbox:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: 18px;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Зона загрузки (Внизу контента) */
.dropzone.always-visible {
  margin: 0 2rem 2rem 2rem;
  padding: 1.5rem; 
  border: 2px dashed var(--text-muted); 
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center; 
  color: var(--text-muted); 
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.dropzone.always-visible:hover { border-color: var(--primary); color: var(--primary); background: rgba(79, 70, 229, 0.05); }
.dropzone.dragover { background: rgba(79, 70, 229, 0.1) !important; border-color: var(--primary) !important; transform: scale(1.01); }

/* Модалка */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content { background: var(--surface); padding: 2.5rem; border-radius: var(--radius); text-align: center; box-shadow: var(--shadow-lg); }
.modal-actions { margin-top: 2rem; display: flex; gap: 1rem; justify-content: center; }
.btn-ok { padding: 0.75rem 2rem; background: var(--primary); color: white; border: none; border-radius: 50px; cursor: pointer; font-weight: 600; transition: 0.2s;}
.btn-ok:hover { background: var(--primary-hover); }
.btn-cancel { padding: 0.75rem 2rem; background: var(--border); color: var(--text); border: none; border-radius: 50px; cursor: pointer; font-weight: 600; transition: 0.2s;}
.btn-cancel:hover { background: var(--text-muted); color: white; }

/* Адаптация под мобильные устройства и планшеты */
@media (max-width: 1024px) {
  .header-actions { order: 3; width: 100%; justify-content: center; margin-top: 0.5rem; }
}

@media (max-width: 768px) {
  header { padding: 1rem; flex-direction: column; align-items: flex-start; }
  .header-left { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .tabs { width: 100%; overflow-x: auto; padding-bottom: 0.5rem; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .header-right { align-self: flex-end; width: 100%; display: flex; justify-content: flex-end; }
  .header-actions { flex-wrap: wrap; }
  
  .main-container { height: auto; display: block; }
  .content { display: block; height: auto; }
  .gallery-grid { padding: 1rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
  .dropzone.always-visible { margin: 1rem; padding: 1rem; }
}